From 971213eb5501563494fce9ecd02b7fd73a21483c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 10 Jul 2017 14:06:45 +0200 Subject: [PATCH 001/126] ENH: add dictionary searcher methods - csearch(), search(), csearchScoped(), searchScoped() methods can be used to find an entry and also retain the enclosing dictionary context. - To avoid ambiguity between a dot (.) as a scoping character and legal part of a keyword, entries can now be accessed directly using slash-scoping semantics similar to file-names: * cfindScopedDictPtr, findScopedDictPtr - To get or create a sub-dictionary entry: * makeScopedDictPtr, which behaves similarly to mkdirp in that it will create any intermediate dictionaries as required. --- src/OpenFOAM/Make/files | 1 + src/OpenFOAM/db/dictionary/dictionary.C | 581 +++--------- src/OpenFOAM/db/dictionary/dictionary.H | 833 ++++++++++++------ src/OpenFOAM/db/dictionary/dictionaryIO.C | 24 - src/OpenFOAM/db/dictionary/dictionarySearch.C | 719 +++++++++++++++ .../db/dictionary/dictionaryTemplates.C | 32 +- src/OpenFOAM/db/dictionary/entry/entryIO.C | 24 +- 7 files changed, 1425 insertions(+), 789 deletions(-) create mode 100644 src/OpenFOAM/db/dictionary/dictionarySearch.C diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 4a6adb98a16..80b6239039a 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -203,6 +203,7 @@ $(Pstreams)/PstreamBuffers.C dictionary = db/dictionary $(dictionary)/dictionary.C $(dictionary)/dictionaryIO.C +$(dictionary)/dictionarySearch.C entry = $(dictionary)/entry $(entry)/entry.C diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 33acac0ace1..46cee88d67d 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -45,157 +45,6 @@ bool Foam::dictionary::writeOptionalEntries ); -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ - // file-scope - //- Walk lists of patterns and regexps for an exact match - // or regular expression match - template<class WcIterator, class ReIterator> - static bool findInPatterns - ( - const bool patternMatch, - const word& keyword, - WcIterator& wcIter, - ReIterator& reIter - ) - { - while (wcIter.found()) - { - if - ( - patternMatch - ? reIter()->match(keyword) - : wcIter()->keyword() == keyword - ) - { - return true; - } - - ++reIter; - ++wcIter; - } - - return false; - } -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr -( - const word& keyword, - bool recursive, - bool patternMatch -) const -{ - string::size_type dotPos = keyword.find('.'); - - if (dotPos == string::npos) - { - // Non-scoped lookup - return lookupEntryPtr(keyword, recursive, patternMatch); - } - else if (dotPos == 0) - { - // Starting with a '.' -> go up for every further '.' found - ++dotPos; - - const dictionary* dictPtr = this; - for - ( - string::const_iterator it = keyword.begin()+1; - it != keyword.end() && *it == '.'; - ++dotPos, ++it - ) - { - // Go to parent - if (&dictPtr->parent_ != &dictionary::null) - { - dictPtr = &dictPtr->parent_; - } - else - { - FatalIOErrorInFunction - ( - *this - ) << "No parent of current dictionary when searching for " - << keyword.substr(1) - << exit(FatalIOError); - - return nullptr; - } - } - - return dictPtr->lookupScopedSubEntryPtr - ( - keyword.substr(dotPos), - false, - patternMatch - ); - } - else - { - // The first word - const entry* entPtr = lookupScopedSubEntryPtr - ( - keyword.substr(0, dotPos), - false, - patternMatch - ); - - if (!entPtr) - { - // Fall back to finding key with '.' so e.g. if keyword is - // a.b.c.d it would try - // a.b, a.b.c, a.b.c.d - - while (true) - { - dotPos = keyword.find('.', dotPos+1); - - entPtr = lookupEntryPtr - ( - keyword.substr(0, dotPos), - false, - patternMatch - ); - - if (dotPos == string::npos) - { - // Parsed the whole word. Return entry or null. - return entPtr; - } - - if (entPtr && entPtr->isDict()) - { - return entPtr->dict().lookupScopedSubEntryPtr - ( - keyword.substr(dotPos), - false, - patternMatch - ); - } - } - } - - if (entPtr->isDict()) - { - return entPtr->dict().lookupScopedSubEntryPtr - ( - keyword.substr(dotPos), - false, - patternMatch - ); - } - } - - return nullptr; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::dictionary::dictionary() @@ -395,29 +244,7 @@ bool Foam::dictionary::found bool patternMatch ) const { - if (hashedEntries_.found(keyword)) - { - return true; - } - - if (patternMatch && patterns_.size()) - { - pattern_const_iterator wcLink = patterns_.begin(); - regexp_const_iterator reLink = regexps_.begin(); - - // Find in patterns using regular expressions only - if (findInPatterns(patternMatch, keyword, wcLink, reLink)) - { - return true; - } - } - - if (recursive && &parent_ != &dictionary::null) - { - return parent_.found(keyword, recursive, patternMatch); - } - - return false; + return csearch(keyword, recursive, patternMatch).found(); } @@ -428,31 +255,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr bool patternMatch ) const { - auto iter = hashedEntries_.cfind(keyword); - - if (iter.found()) - { - return iter(); - } - - if (patternMatch && patterns_.size()) - { - pattern_const_iterator wcLink = patterns_.begin(); - regexp_const_iterator reLink = regexps_.begin(); - - // Find in patterns using regular expressions only - if (findInPatterns(patternMatch, keyword, wcLink, reLink)) - { - return wcLink(); - } - } - - if (recursive && &parent_ != &dictionary::null) - { - return parent_.lookupEntryPtr(keyword, recursive, patternMatch); - } - - return nullptr; + return csearch(keyword, recursive, patternMatch).ptr(); } @@ -463,36 +266,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr bool patternMatch ) { - auto iter = hashedEntries_.find(keyword); - - if (iter.found()) - { - return iter(); - } - - if (patternMatch && patterns_.size()) - { - pattern_iterator wcLink = patterns_.begin(); - regexp_iterator reLink = regexps_.begin(); - - // Find in patterns using regular expressions only - if (findInPatterns(patternMatch, keyword, wcLink, reLink)) - { - return wcLink(); - } - } - - if (recursive && &parent_ != &dictionary::null) - { - return const_cast<dictionary&>(parent_).lookupEntryPtr - ( - keyword, - recursive, - patternMatch - ); - } - - return nullptr; + return search(keyword, recursive, patternMatch).ptr(); } @@ -503,9 +277,9 @@ const Foam::entry& Foam::dictionary::lookupEntry bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); + auto finder = csearch(keyword, recursive, patternMatch); - if (entryPtr == nullptr) + if (!finder.found()) { FatalIOErrorInFunction ( @@ -515,7 +289,7 @@ const Foam::entry& Foam::dictionary::lookupEntry << exit(FatalIOError); } - return *entryPtr; + return finder.ref(); } @@ -537,29 +311,37 @@ const Foam::entry* Foam::dictionary::lookupScopedEntryPtr bool patternMatch ) const { - if ((keyword[0] == ':' || keyword[0] == '^')) + return csearchScoped(keyword, recursive, patternMatch).ptr(); +} + + +bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry) +{ + if (keyword.size() < 2) { - // Go up to top level - const dictionary* dictPtr = this; - while (&dictPtr->parent_ != &dictionary::null) + return false; + } + + // Drop leading '$' to get the var-name, already validated as word. + const word varName(keyword.substr(1), false); + + // Lookup the variable name in the given dictionary + const_searcher finder = csearch(varName, true, true); + + // If defined insert its entries into this dictionary + if (finder.found()) + { + const dictionary& addDict = finder.dict(); + + forAllConstIters(addDict, iter) { - dictPtr = &dictPtr->parent_; + add(iter(), mergeEntry); } - return dictPtr->lookupScopedSubEntryPtr - ( - keyword.substr(1), - false, - patternMatch - ); + return true; } - return lookupScopedSubEntryPtr - ( - keyword, - recursive, - patternMatch - ); + return false; } @@ -569,16 +351,21 @@ bool Foam::dictionary::substituteScopedKeyword bool mergeEntry ) { - // Drop first character of keyword to get the var-name, already validated. + if (keyword.size() < 2) + { + return false; + } + + // Drop leading '$' to get the var-name, already validated as word. const word varName(keyword.substr(1), false); // Lookup the variable name in the given dictionary - const entry* ePtr = lookupScopedEntryPtr(varName, true, true); + const_searcher finder = csearchScoped(varName, true, true); // If defined insert its entries into this dictionary - if (ePtr != nullptr) + if (finder.found()) { - const dictionary& addDict = ePtr->dict(); + const dictionary& addDict = finder.dict(); forAllConstIter(parent_type, addDict, iter) { @@ -595,54 +382,30 @@ bool Foam::dictionary::substituteScopedKeyword bool Foam::dictionary::isDict(const word& keyword) const { // Find non-recursive with patterns - const entry* entryPtr = lookupEntryPtr(keyword, false, true); - - if (entryPtr) - { - return entryPtr->isDict(); - } - else - { - return false; - } + return csearch(keyword, false, true).isDict(); } const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const { - const entry* entryPtr = lookupEntryPtr(keyword, false, true); - - if (entryPtr) - { - return &entryPtr->dict(); - } - else - { - return nullptr; - } + // Find non-recursive with patterns + return csearch(keyword, false, true).dictPtr(); } Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) { - entry* entryPtr = lookupEntryPtr(keyword, false, true); - - if (entryPtr) - { - return &entryPtr->dict(); - } - else - { - return nullptr; - } + // Find non-recursive with patterns + return search(keyword, false, true).dictPtr(); } const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const { - const entry* entryPtr = lookupEntryPtr(keyword, false, true); + // Find non-recursive with patterns + auto finder = csearch(keyword, false, true); - if (entryPtr == nullptr) + if (!finder.found()) { FatalIOErrorInFunction ( @@ -651,15 +414,17 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const << name() << exit(FatalIOError); } - return entryPtr->dict(); + + return finder.dict(); } Foam::dictionary& Foam::dictionary::subDict(const word& keyword) { - entry* entryPtr = lookupEntryPtr(keyword, false, true); + // Find non-recursive with patterns + auto finder = search(keyword, false, true); - if (entryPtr == nullptr) + if (!finder.found()) { FatalIOErrorInFunction ( @@ -668,7 +433,8 @@ Foam::dictionary& Foam::dictionary::subDict(const word& keyword) << name() << exit(FatalIOError); } - return entryPtr->dict(); + + return finder.dict(); } @@ -678,29 +444,35 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict const bool mustRead ) const { - const entry* entryPtr = lookupEntryPtr(keyword, false, true); + // Find non-recursive with patterns + auto finder = csearch(keyword, false, true); - if (entryPtr == nullptr) + if (finder.isDict()) { - if (mustRead) - { - FatalIOErrorInFunction - ( - *this - ) << "keyword " << keyword << " is undefined in dictionary " - << name() - << exit(FatalIOError); - return entryPtr->dict(); - } - else - { - return dictionary(*this, dictionary(name() + '.' + keyword)); - } + // Found and a sub-dictionary + return finder.dict(); } - else + + if (mustRead) { - return entryPtr->dict(); + FatalIOErrorInFunction + ( + *this + ) << "keyword " << keyword + << " is not a sub-dictionary in dictionary " + << name() + << exit(FatalIOError); } + + if (finder.found()) + { + IOWarningInFunction((*this)) + << "keyword " << keyword + << " found but not a sub-dictionary in dictionary " + << name() << endl; + } + + return dictionary(*this, dictionary(name() + '.' + keyword)); } @@ -709,16 +481,23 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict const word& keyword ) const { - const entry* entryPtr = lookupEntryPtr(keyword, false, true); + auto finder = csearch(keyword, false, true); - if (entryPtr) + if (finder.isDict()) { - return entryPtr->dict(); + // Found and a sub-dictionary + return finder.dict(); } - else + + if (finder.found()) { - return *this; + IOWarningInFunction((*this)) + << "keyword " << keyword + << " found but not a sub-dictionary in dictionary " + << name() << endl; } + + return *this; } @@ -726,10 +505,10 @@ Foam::wordList Foam::dictionary::toc() const { wordList keys(size()); - label nKeys = 0; - forAllConstIter(parent_type, *this, iter) + label n = 0; + forAllConstIters(*this, iter) { - keys[nKeys++] = iter().keyword(); + keys[n++] = iter().keyword(); } return keys; @@ -746,15 +525,15 @@ Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const { List<keyType> keys(size()); - label nKeys = 0; - forAllConstIter(parent_type, *this, iter) + label n = 0; + forAllConstIters(*this, iter) { if (iter().keyword().isPattern() ? patterns : !patterns) { - keys[nKeys++] = iter().keyword(); + keys[n++] = iter().keyword(); } } - keys.setSize(nKeys); + keys.setSize(n); return keys; } @@ -844,55 +623,55 @@ void Foam::dictionary::add(const entry& e, bool mergeEntry) } -void Foam::dictionary::add(const keyType& k, const word& w, bool overwrite) +void Foam::dictionary::add(const keyType& k, const word& v, bool overwrite) { - add(new primitiveEntry(k, token(w)), overwrite); + add(new primitiveEntry(k, token(v)), overwrite); } void Foam::dictionary::add ( const keyType& k, - const Foam::string& s, + const Foam::string& v, bool overwrite ) { - add(new primitiveEntry(k, token(s)), overwrite); + add(new primitiveEntry(k, token(v)), overwrite); } -void Foam::dictionary::add(const keyType& k, const label l, bool overwrite) +void Foam::dictionary::add(const keyType& k, const label v, bool overwrite) { - add(new primitiveEntry(k, token(l)), overwrite); + add(new primitiveEntry(k, token(v)), overwrite); } -void Foam::dictionary::add(const keyType& k, const scalar s, bool overwrite) +void Foam::dictionary::add(const keyType& k, const scalar v, bool overwrite) { - add(new primitiveEntry(k, token(s)), overwrite); + add(new primitiveEntry(k, token(v)), overwrite); } void Foam::dictionary::add ( const keyType& k, - const dictionary& d, + const dictionary& v, bool mergeEntry ) { - add(new dictionaryEntry(k, *this, d), mergeEntry); + add(new dictionaryEntry(k, *this, v), mergeEntry); } void Foam::dictionary::set(entry* entryPtr) { // Find non-recursive with patterns - entry* existingPtr = lookupEntryPtr(entryPtr->keyword(), false, true); + auto finder = search(entryPtr->keyword(), false, true); // Clear dictionary so merge acts like overwrite - if (existingPtr && existingPtr->isDict()) + if (finder.isDict()) { - existingPtr->dict().clear(); + finder.dict().clear(); } add(entryPtr, true); } @@ -904,134 +683,14 @@ void Foam::dictionary::set(const entry& e) } -void Foam::dictionary::set(const keyType& k, const dictionary& d) -{ - set(new dictionaryEntry(k, *this, d)); -} - - -bool Foam::dictionary::remove(const word& keyword) +void Foam::dictionary::set(const keyType& k, const dictionary& v) { - auto iter = hashedEntries_.find(keyword); - - if (iter.found()) - { - // Delete from patterns - pattern_iterator wcLink = patterns_.begin(); - regexp_iterator reLink = regexps_.begin(); - - // Find in pattern using exact match only - if (findInPatterns(false, keyword, wcLink, reLink)) - { - patterns_.remove(wcLink); - regexps_.remove(reLink); - } - - parent_type::remove(iter()); - delete iter(); - hashedEntries_.erase(iter); - - return true; - } - else - { - return false; - } -} - - -bool Foam::dictionary::changeKeyword -( - const keyType& oldKeyword, - const keyType& newKeyword, - bool forceOverwrite -) -{ - // No change - if (oldKeyword == newKeyword) - { - return false; - } - - // Check that oldKeyword exists and can be changed - auto iter = hashedEntries_.find(oldKeyword); - - if (!iter.found()) - { - return false; - } - - if (iter()->keyword().isPattern()) - { - FatalIOErrorInFunction - ( - *this - ) << "Old keyword "<< oldKeyword - << " is a pattern." - << "Pattern replacement not yet implemented." - << exit(FatalIOError); - } - - - auto iter2 = hashedEntries_.find(newKeyword); - - // newKeyword already exists - if (iter2.found()) - { - if (forceOverwrite) - { - if (iter2()->keyword().isPattern()) - { - // Delete from patterns - pattern_iterator wcLink = patterns_.begin(); - regexp_iterator reLink = regexps_.begin(); - - // Find in patterns using exact match only - if (findInPatterns(false, iter2()->keyword(), wcLink, reLink)) - { - patterns_.remove(wcLink); - regexps_.remove(reLink); - } - } - - parent_type::replace(iter2(), iter()); - delete iter2(); - hashedEntries_.erase(iter2); - } - else - { - IOWarningInFunction - ( - *this - ) << "cannot rename keyword "<< oldKeyword - << " to existing keyword " << newKeyword - << " in dictionary " << name() << endl; - return false; - } - } - - // Change name and HashTable, but leave DL-List untouched - iter()->keyword() = newKeyword; - iter()->name() = name() + '.' + newKeyword; - hashedEntries_.erase(oldKeyword); - hashedEntries_.insert(newKeyword, iter()); - - if (newKeyword.isPattern()) - { - patterns_.insert(iter()); - regexps_.insert - ( - autoPtr<regExp>(new regExp(newKeyword)) - ); - } - - return true; + set(new dictionaryEntry(k, *this, v)); } bool Foam::dictionary::merge(const dictionary& dict) { - // Check for assignment to self if (this == &dict) { FatalIOErrorInFunction(*this) @@ -1041,7 +700,7 @@ bool Foam::dictionary::merge(const dictionary& dict) bool changed = false; - forAllConstIter(parent_type, dict, iter) + forAllConstIters(dict, iter) { auto fnd = hashedEntries_.find(iter().keyword()); @@ -1112,7 +771,6 @@ Foam::ITstream& Foam::dictionary::operator[](const word& keyword) const void Foam::dictionary::operator=(const dictionary& rhs) { - // Check for assignment to self if (this == &rhs) { FatalIOErrorInFunction(*this) @@ -1126,7 +784,7 @@ void Foam::dictionary::operator=(const dictionary& rhs) // Create clones of the entries in the given dictionary // resetting the parentDict to this dictionary - forAllConstIter(parent_type, rhs, iter) + forAllConstIters(rhs, iter) { add(iter().clone(*this).ptr()); } @@ -1135,7 +793,6 @@ void Foam::dictionary::operator=(const dictionary& rhs) void Foam::dictionary::operator+=(const dictionary& rhs) { - // Check for assignment to self if (this == &rhs) { FatalIOErrorInFunction(*this) @@ -1143,7 +800,7 @@ void Foam::dictionary::operator+=(const dictionary& rhs) << abort(FatalIOError); } - forAllConstIter(parent_type, rhs, iter) + forAllConstIters(rhs, iter) { add(iter().clone(*this).ptr()); } @@ -1152,7 +809,6 @@ void Foam::dictionary::operator+=(const dictionary& rhs) void Foam::dictionary::operator|=(const dictionary& rhs) { - // Check for assignment to self if (this == &rhs) { FatalIOErrorInFunction(*this) @@ -1160,7 +816,7 @@ void Foam::dictionary::operator|=(const dictionary& rhs) << abort(FatalIOError); } - forAllConstIter(parent_type, rhs, iter) + forAllConstIters(rhs, iter) { if (!found(iter().keyword())) { @@ -1172,7 +828,6 @@ void Foam::dictionary::operator|=(const dictionary& rhs) void Foam::dictionary::operator<<=(const dictionary& rhs) { - // Check for assignment to self if (this == &rhs) { FatalIOErrorInFunction(*this) @@ -1180,7 +835,7 @@ void Foam::dictionary::operator<<=(const dictionary& rhs) << abort(FatalIOError); } - forAllConstIter(parent_type, rhs, iter) + forAllConstIters(rhs, iter) { set(iter().clone(*this).ptr()); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index f0c66b97a85..783c6436563 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -41,10 +41,13 @@ Description Note Within dictionaries, entries can be referenced by using the '$' syntax - familiar from shell programming. A '.' separator is used when referencing - sub-dictionary entries. Leading '.' prefixes can be used to specify - an entry from a parent directory. A leading ':' or '^' prefix specifies - starting from the top-level entry. For example, + familiar from shell programming. + A '.' separator is used when referencing sub-dictionary entries. + Leading '.' prefixes can be used to specify an entry from a parent + dictionary. + An initial '^' anchor (or ':' for backward compatibility) specifies + starting from the top-level entry. + For example, \verbatim key1 val1; @@ -70,6 +73,7 @@ Note SourceFiles dictionary.C dictionaryIO.C + dictionarySearch.C SeeAlso - Foam::entry @@ -89,6 +93,7 @@ SeeAlso #include "HashTable.H" #include "wordList.H" #include "className.H" +#include <type_traits> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -148,22 +153,20 @@ public: const word dictName() const { const word scopedName = name_.name(); - const std::string::size_type i = scopedName.rfind('.'); + const auto i = scopedName.rfind('.'); if (i == std::string::npos) { return scopedName; } - else - { - return scopedName.substr(i+1); - } + + return scopedName.substr(i+1); } }; /*---------------------------------------------------------------------------*\ - Class dictionary Declaration + Class dictionary Declaration \*---------------------------------------------------------------------------*/ class dictionary @@ -171,15 +174,157 @@ class dictionary public dictionaryName, public IDLList<entry> { +public: + + // Searching + + //- Generic const/non-const dictionary entry %searcher. + // A %searcher provides a uniform means of finding and returning + // an entry pointer as well as the dictionary \a context in which + // the entry was located. + // + // Note that the constructors and set methods are protected such + // that only friends of the class can set things. This safeguards + // against inconsistencies in context/entry. + template<bool Const> + class Searcher + { + public: + friend dictionary; + + //- The const/non-const type for the context and sub-dictionaries + typedef typename std::conditional + <Const, const dictionary, dictionary>::type dict_type; + + //- The const/non-const type for entries + typedef typename std::conditional + <Const, const entry, entry>::type value_type; + + //- A pointer to a const/non-const dictionary + typedef dict_type* dict_pointer; + + //- A reference to a const/non-const dictionary + typedef dict_type& dict_reference; + + //- A pointer to a const/non-const entry + typedef value_type* pointer; + + //- A reference to a const/non-const entry + typedef value_type& reference; + + + protected: + + //- The dictionary context for the entry + dict_pointer dict_; + + //- The entry or nullptr + pointer eptr_; + + + //- Construct null + Searcher() + : + dict_(nullptr), + eptr_(nullptr) + {} + + //- Construct for the given dictionary context + Searcher(dict_pointer dict) + : + dict_(dict), + eptr_(nullptr) + {} + + //- Assign the entry + void set(pointer eptr) + { + eptr_ = eptr; + } + + + public: + + //- Entry was found. + inline bool found() const + { + return eptr_; + } + + //- The containing dictionary context + inline dict_reference context() const + { + return *dict_; + } + + //- A pointer to the entry (nullptr if not found) + inline pointer ptr() const + { + return eptr_; + } + + //- A reference to the entry (Error if not found) + inline reference ref() const + { + return *eptr_; + } + + //- True if found entry is a dictionary. + inline bool isDict() const + { + return eptr_ && eptr_->isDict(); + } + + //- Pointer to the found entry as a dictionary or nullptr otherwise. + inline dict_pointer dictPtr() const + { + return eptr_ && eptr_->isDict() ? eptr_->dictPtr() : nullptr; + } + + //- Reference the found entry as a dictionary. + // (Error if not found, or not a dictionary). + inline dict_reference dict() const + { + return eptr_->dict(); + } + + //- Permit an explicit cast to the other (const/non-const) searcher + inline explicit operator const Searcher<!Const>&() const + { + return *reinterpret_cast<const Searcher<!Const>*>(this); + } + }; + + + //- Searcher with const access + typedef Searcher<true> const_searcher; + + //- Searcher with non-const access + typedef Searcher<false> searcher; + + + // Friends + + //- Declare friendship with the entry class for IO + friend class entry; + + //- Declare friendship with the searcher classes + friend const_searcher; + friend searcher; + + +private: + // Private data //- Report optional keywords and values if not present in dictionary + // Set/unset via an InfoSwitch static bool writeOptionalEntries; //- Parent dictionary const dictionary& parent_; - //- HashTable of the entries held on the IDLList for quick lookup + //- Quick lookup of the entries held on the IDLList HashTable<entry*> hashedEntries_; //- Entries of matching patterns @@ -196,27 +341,48 @@ class dictionary typedef DLList<entry*>::iterator pattern_iterator; typedef DLList<entry*>::const_iterator pattern_const_iterator; + typedef DLList<autoPtr<regExp>>::iterator regexp_iterator; typedef DLList<autoPtr<regExp>>::const_iterator regexp_const_iterator; // Private Member Functions - //- Find and return an entry data stream pointer if present - // otherwise return nullptr. Allows scoping using '.' - const entry* lookupScopedSubEntryPtr + //- Search using a '.' for scoping. + // A leading dot means to use the parent dictionary. + // An intermediate dot separates a sub-dictionary or sub-entry. + // However, the use of dots is unfortunately ambiguous. + // The value "a.b.c.d" could be a first-level entry, a second-level + // entry (eg, "a" with "b.c.d", "a.b" with "c.d" etc), + // or just about any other combination. + // The heuristic tries sucessively longer top-level entries + // until there is a suitable match. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + const_searcher csearchDotScoped ( const word& keyword, bool recursive, bool patternMatch ) const; + //- Search using a '/' for scoping. + // Semantics as per normal files: an intermediate "." is the current + // dictionary level, an intermediate ".." is the parent dictionary. + // Note that since a slash is not a valid word character, there is no + // ambiguity between separator and content. + // No possibility or need for recursion. + // + // \param patternMatch use regular expressions + const_searcher csearchSlashScoped + ( + const word& keyword, + bool patternMatch + ) const; -public: - - //- Declare friendship with the entry class for IO - friend class entry; +public: // Declare name of the class and its debug switch ClassName("dictionary"); @@ -234,7 +400,7 @@ public: explicit dictionary(const fileName& name); //- Construct given the entry name, parent dictionary and Istream, - // reading entries until lastEntry or EOF + // reading entries until EOF dictionary ( const fileName& name, @@ -251,7 +417,7 @@ public: dictionary(Istream& is, const bool keepHeader); //- Construct as copy given the parent dictionary - dictionary(const dictionary& parentDict, const dictionary&); + dictionary(const dictionary& parentDict, const dictionary& dict); //- Construct top-level dictionary as copy dictionary(const dictionary& dict); @@ -303,284 +469,413 @@ public: tokenList tokens() const; - // Search and lookup - - //- Search dictionary for given keyword - // If recursive, search parent dictionaries - // If patternMatch, use regular expressions - bool found - ( - const word& keyword, - bool recursive = false, - bool patternMatch = true - ) const; - - //- Find and return an entry data stream pointer if present - // otherwise return nullptr. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions - const entry* lookupEntryPtr - ( - const word& keyword, - bool recursive, - bool patternMatch - ) const; - - //- Find and return an entry data stream pointer for manipulation - // if present otherwise return nullptr. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - entry* lookupEntryPtr - ( - const word& keyword, - bool recursive, - bool patternMatch - ); - - //- Find and return an entry data stream if present otherwise error. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - const entry& lookupEntry - ( - const word& keyword, - bool recursive, - bool patternMatch - ) const; - - //- Find and return an entry data stream - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - ITstream& lookup - ( - const word& keyword, - bool recursive = false, - bool patternMatch = true - ) const; - - //- Find and return a T, - // if not found throw a fatal error. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - template<class T> - T lookupType - ( - const word&, - bool recursive=false, - bool patternMatch=true - ) const; - - //- Find and return a T, or return the given default value - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - template<class T> - T lookupOrDefault - ( - const word& keyword, - const T& deflt, - bool recursive = false, - bool patternMatch = true - ) const; - - //- Find and return a T, if not found return the given - // default value, and add to dictionary. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - template<class T> - T lookupOrAddDefault - ( - const word& keyword, - const T& deflt, - bool recursive = false, - bool patternMatch = true - ); - - //- Find an entry if present, and assign to T - // Returns true if the entry was found. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - template<class T> - bool readIfPresent - ( - const word& keyword, - T& val, - bool recursive = false, - bool patternMatch = true - ) const; - - //- Find and return an entry data stream pointer if present - // otherwise return nullptr. Allows scoping using '.'. - // Special handling for ':' at start of keyword and '..'. - const entry* lookupScopedEntryPtr - ( - const word& keyword, - bool recursive, - bool patternMatch - ) const; - - //- Check if entry is a sub-dictionary - bool isDict(const word& keyword) const; - - //- Find and return a sub-dictionary pointer if present - // otherwise return nullptr. - const dictionary* subDictPtr(const word& keyword) const; - - //- Find and return a sub-dictionary pointer if present - // otherwise return nullptr. - dictionary* subDictPtr(const word& keyword); - - //- Find and return a sub-dictionary - const dictionary& subDict(const word& keyword) const; - - //- Find and return a sub-dictionary for manipulation - dictionary& subDict(const word& keyword); - - //- Find and return a sub-dictionary as a copy, or - // return an empty dictionary if the sub-dictionary does not exist - dictionary subOrEmptyDict - ( - const word& keyword, - const bool mustRead = false - ) const; - - //- Find and return a sub-dictionary if found - // otherwise return this dictionary - const dictionary& optionalSubDict(const word&) const; - - //- Return the table of contents - wordList toc() const; - - //- Return the sorted table of contents - wordList sortedToc() const; - - //- Return table of contents sorted using the specified comparator - template<class Compare> - wordList sortedToc(const Compare& comp) const; - - //- Return the list of available keys or patterns - List<keyType> keys(bool patterns = false) const; - - - // Editing - - //- Substitute the given keyword prepended by '$' with the - // corresponding sub-dictionary entries - bool substituteKeyword(const word& keyword, bool mergeEntry=false); - - //- Substitute the given scoped keyword prepended by '$' with the - // corresponding sub-dictionary entries - bool substituteScopedKeyword - ( - const word& keyword, - bool mergeEntry=false - ); - - //- Add a new entry - // With the merge option, dictionaries are interwoven and - // primitive entries are overwritten - bool add(entry* entryPtr, bool mergeEntry=false); - - //- Add an entry - // With the merge option, dictionaries are interwoven and - // primitive entries are overwritten - void add(const entry& e, bool mergeEntry=false); - - //- Add a word entry - // optionally overwrite an existing entry - void add(const keyType& k, const word& w, bool overwrite=false); - - //- Add a string entry - // optionally overwrite an existing entry - void add(const keyType& k, const string& s, bool overwrite=false); + // Search and lookup - //- Add a label entry - // optionally overwrite an existing entry - void add(const keyType&, const label l, bool overwrite=false); + //- Search dictionary for given keyword + // If recursive, search parent dictionaries + // If patternMatch, use regular expressions + // (default search: non-recursive with patterns). + bool found + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ) const; - //- Add a scalar entry - // optionally overwrite an existing entry - void add(const keyType&, const scalar s, bool overwrite=false); + //- Find and return an entry data stream pointer if present + // otherwise return nullptr. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions + const entry* lookupEntryPtr + ( + const word& keyword, + bool recursive, + bool patternMatch + ) const; - //- Add a dictionary entry - // optionally merge with an existing sub-dictionary - void add - ( - const keyType& k, - const dictionary& d, - bool mergeEntry = false - ); + //- Find and return an entry data stream pointer for manipulation + // if present otherwise return nullptr. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. + entry* lookupEntryPtr + ( + const word& keyword, + bool recursive, + bool patternMatch + ); - //- Add a T entry - // optionally overwrite an existing entry - template<class T> - void add(const keyType& k, const T& t, bool overwrite=false); + //- Find and return an entry data stream if present otherwise error. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. + const entry& lookupEntry + ( + const word& keyword, + bool recursive, + bool patternMatch + ) const; - //- Assign a new entry, overwrite any existing entry - void set(entry* entryPtr); + //- Find and return an entry data stream + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. + // (default search: non-recursive with patterns). + ITstream& lookup + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ) const; - //- Assign a new entry, overwrite any existing entry - void set(const entry& e); + //- Find and return a T, + // if not found throw a fatal error. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. + // (default search: non-recursive with patterns). + template<class T> + T lookupType + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Find and return a T, or return the given default value + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. + // (default search: non-recursive with patterns). + template<class T> + T lookupOrDefault + ( + const word& keyword, + const T& deflt, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Find and return a T, if not found return the default value + // and add it to dictionary. + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + template<class T> + T lookupOrAddDefault + ( + const word& keyword, + const T& deflt, + bool recursive = false, + bool patternMatch = true + ); + + //- Find an entry if present, and assign to T val. + // Default search: non-recursive with patterns. + // + // \param val the value to read + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + // + // \return true if the entry was found. + template<class T> + bool readIfPresent + ( + const word& keyword, + T& val, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Find and return an entry pointer if present, or return a nullptr. + // Allows scoping using '.'. + // Special handling for an absolute anchor (^) at start of the keyword + // and for '..' to ascend into the parent dictionaries. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + const entry* lookupScopedEntryPtr + ( + const word& keyword, + bool recursive, + bool patternMatch + ) const; + + //- Check if entry exists and is a sub-dictionary. + // (search type: non-recursive with patterns) + bool isDict(const word& keyword) const; + + //- Find and return a sub-dictionary pointer if present + // (and a sub-dictionary) otherwise return nullptr. + // (search type: non-recursive with patterns) + const dictionary* subDictPtr(const word& keyword) const; + + //- Find and return a sub-dictionary pointer if present + // (and a sub-dictionary) otherwise return nullptr. + // + // Search type: non-recursive with patterns. + dictionary* subDictPtr(const word& keyword); + + //- Find and return a sub-dictionary. + // Fatal if the entry does not exist or is not a sub-dictionary. + // (search type: non-recursive with patterns) + const dictionary& subDict(const word& keyword) const; + + //- Find and return a sub-dictionary for manipulation. + // Fatal if the entry does not exist or is not a sub-dictionary. + // (search type: non-recursive with patterns) + dictionary& subDict(const word& keyword); + + //- Find and return a sub-dictionary as a copy, otherwise return + // an empty dictionary. + // Warn if the entry exists but is not a sub-dictionary. + // (search type: non-recursive with patterns) + dictionary subOrEmptyDict + ( + const word& keyword, + const bool mustRead = false + ) const; + + //- Find and return a sub-dictionary, otherwise return this dictionary. + // Warn if the entry exists but is not a sub-dictionary. + // (search type: non-recursive with patterns) + const dictionary& optionalSubDict(const word& keyword) const; + + //- Return the table of contents + wordList toc() const; + + //- Return the sorted table of contents + wordList sortedToc() const; + + //- Return table of contents sorted using the specified comparator + template<class Compare> + wordList sortedToc(const Compare& comp) const; + + //- Return the list of available keys or patterns + List<keyType> keys(bool patterns = false) const; + + + // Editing + + //- Substitute the given keyword (which is prefixed by '$') + // with the corresponding sub-dictionary entries + bool substituteKeyword + ( + const word& keyword, + bool mergeEntry = false + ); + + //- Substitute the given scoped keyword (which is prefixed by '$') + // with the corresponding sub-dictionary entries + bool substituteScopedKeyword + ( + const word& keyword, + bool mergeEntry = false + ); + + //- Add a new entry + // With the merge option, dictionaries are interwoven and + // primitive entries are overwritten + bool add(entry* entryPtr, bool mergeEntry=false); + + //- Add an entry + // With the merge option, dictionaries are interwoven and + // primitive entries are overwritten + void add(const entry& e, bool mergeEntry=false); + + //- Add a word entry + // optionally overwrite an existing entry + void add(const keyType& k, const word& v, bool overwrite=false); + + //- Add a string entry + // optionally overwrite an existing entry + void add(const keyType& k, const string& v, bool overwrite=false); + + //- Add a label entry + // optionally overwrite an existing entry + void add(const keyType& k, const label v, bool overwrite=false); + + //- Add a scalar entry + // optionally overwrite an existing entry + void add(const keyType& k, const scalar v, bool overwrite=false); - //- Assign a dictionary entry, overwrite any existing entry - void set(const keyType& k, const dictionary& d); + //- Add a dictionary entry + // optionally merge with an existing sub-dictionary + void add + ( + const keyType& k, + const dictionary& d, + bool mergeEntry = false + ); + + //- Add a T entry + // optionally overwrite an existing entry + template<class T> + void add(const keyType& k, const T& v, bool overwrite=false); + + //- Assign a new entry, overwrite any existing entry + void set(entry* entryPtr); + + //- Assign a new entry, overwrite any existing entry + void set(const entry& e); + + //- Assign a dictionary entry, overwrite any existing entry + void set(const keyType& k, const dictionary& v); - //- Assign a T entry, overwrite any existing entry - template<class T> - void set(const keyType& k, const T& t); + //- Assign a T entry, overwrite any existing entry + template<class T> + void set(const keyType& k, const T& v); - //- Remove an entry specified by keyword - bool remove(const word& Keyword); + //- Remove an entry specified by keyword + bool remove(const word& keyword); - //- Change the keyword for an entry, - // optionally forcing overwrite of an existing entry - bool changeKeyword - ( - const keyType& oldKeyword, - const keyType& newKeyword, - bool forceOverwrite=false - ); + //- Change the keyword for an entry, + // optionally forcing overwrite of an existing entry + bool changeKeyword + ( + const keyType& oldKeyword, + const keyType& newKeyword, + bool forceOverwrite=false + ); + + //- Merge entries from the given dictionary. + // Also merge sub-dictionaries as required. + bool merge(const dictionary& dict); - //- Merge entries from the given dictionary. - // Also merge sub-dictionaries as required. - bool merge(const dictionary& dict); + //- Clear the dictionary + void clear(); - //- Clear the dictionary - void clear(); + //- Transfer the contents of the argument and annul the argument. + void transfer(dictionary& dict); - //- Transfer the contents of the argument and annul the argument. - void transfer(dictionary& dict); + //- Transfer contents to the Xfer container + Xfer<dictionary> xfer(); - //- Transfer contents to the Xfer container - Xfer<dictionary> xfer(); + // Read + + //- Read dictionary from Istream + bool read(Istream& is); + + //- Read dictionary from Istream, optionally keeping the header + bool read(Istream& is, const bool keepHeader); - // Read - //- Read dictionary from Istream - bool read(Istream& is); + // Write - //- Read dictionary from Istream, optionally keeping the header - bool read(Istream& is, const bool keepHeader); + //- Write sub-dictionary with the keyword as its header + void writeEntry(const keyType& keyword, Ostream& os) const; + //- Write dictionary entries. + // Optionally with extra new line between entries for + // "top-level" dictionaries + void writeEntries(Ostream& os, const bool extraNewLine=false) const; + + //- Write dictionary, normally with sub-dictionary formatting + void write(Ostream& os, const bool subDict=true) const; + + + // Searching + + //- Search dictionary for given keyword + // If recursive, search parent dictionaries + // If patternMatch, use regular expressions + // (default search: non-recursive with patterns). + const_searcher csearch + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Search dictionary for given keyword + // If recursive, search parent dictionaries + // If patternMatch, use regular expressions + // (default search: non-recursive with patterns). + const_searcher search + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Search dictionary for given keyword + // If recursive, search parent dictionaries + // If patternMatch, use regular expressions + // (default search: non-recursive with patterns). + searcher search + ( + const word& keyword, + bool recursive = false, + bool patternMatch = true + ); + + //- Search using scoping. + // There are two types of scoping available: + // -# dot-scoping, where a '.' is used to delineate the scope + // -# slash-scoping, where a '/' is used to delineate the scope + // + // For dot-scoping, a leading '^' traverses to the top-level + // dictionary, leading dots mean use the parent dictionary and an + // intermediate dot separates a sub-dictionary or sub-entry. + // However, since the use of dots is ambiguous ("a.b.c" could be + // an entry itself or represent a "bc" entry from dictionary "a" etc), + // the heuristic backtracks and attempts successively longer + // top-level entries until a suitable match is found. + // + // For slash-scoping, semantics similar to directory structures are + // used. A leading '/' traverses to the top-level dictionary, + // a single leading or intermediate '.' references the current + // dictionary level. A '..' pair references the parent dictionary. + // Any doubled slashes are silently ignored. + // Since a slash is not a valid keyword character, there is no + // ambiguity between separator and content. + const_searcher csearchScoped + ( + const word& keyword, + bool recursive, + bool patternMatch + ) const; + + //- Search using dot or slash scoping. + const_searcher searchScoped + ( + const word& keyword, + bool recursive, + bool patternMatch + ) const; + + //- Search using dot or slash scoping. + searcher searchScoped + ( + const word& keyword, + bool recursive, + bool patternMatch + ); - // Write + //- Locate a sub-dictionary using slash-scoping + // \return nullptr if the dictionary path does not exist + const dictionary* cfindScopedDictPtr(const fileName& dictPath) const; - //- Write sub-dictionary with the keyword as its header - void writeEntry(const keyType& keyword, Ostream& os) const; + //- Locate a sub-dictionary using slash-scoping + // \return nullptr if the dictionary path does not exist + const dictionary* findScopedDictPtr(const fileName& dictPath) const; - //- Write dictionary entries. - // Optionally with extra new line between entries for - // "top-level" dictionaries - void writeEntries(Ostream& os, const bool extraNewLine=false) const; + //- Locate a sub-dictionary using slash-scoping + // \return nullptr if the dictionary path does not exist + dictionary* findScopedDictPtr(const fileName& dictPath); - //- Write dictionary, normally with sub-dictionary formatting - void write(Ostream& os, const bool subDict=true) const; + //- Locate existing or create sub-dictionary using slash-scoping + // \return nullptr if the dictionary path could not be created + dictionary* makeScopedDictPtr(const fileName& dictPath); // Member Operators - //- Find and return entry + //- Find and return an entry data stream (identical to #lookup method). + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions ITstream& operator[](const word& keyword) const; + //- Copy assignment void operator=(const dictionary& rhs); //- Include entries from the given dictionary. diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index ddc505c661e..9c1e36c1b52 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -128,30 +128,6 @@ bool Foam::dictionary::read(Istream& is) } -bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry) -{ - const word varName = keyword.substr(1); - - // Lookup the variable name in the given dictionary - const entry* ePtr = lookupEntryPtr(varName, true, true); - - // If defined insert its entries into this dictionary - if (ePtr != nullptr) - { - const dictionary& addDict = ePtr->dict(); - - forAllConstIter(parent_type, addDict, iter) - { - add(iter(), mergeEntry); - } - - return true; - } - - return false; -} - - // * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * // Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict) diff --git a/src/OpenFOAM/db/dictionary/dictionarySearch.C b/src/OpenFOAM/db/dictionary/dictionarySearch.C new file mode 100644 index 00000000000..93c5bcb884a --- /dev/null +++ b/src/OpenFOAM/db/dictionary/dictionarySearch.C @@ -0,0 +1,719 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "dictionary.H" +#include "dictionaryEntry.H" +#include "stringOps.H" + +/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ + +namespace Foam +{ + // file-scope + //- Walk lists of patterns and regexps for an exact match + // or regular expression match + template<class WcIterator, class ReIterator> + static bool findInPatterns + ( + const bool patternMatch, + const word& keyword, + WcIterator& wcIter, + ReIterator& reIter + ) + { + while (wcIter.found()) + { + if + ( + patternMatch + ? reIter()->match(keyword) + : wcIter()->keyword() == keyword + ) + { + return true; + } + + ++reIter; + ++wcIter; + } + + return false; + } +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped +( + const word& keyword, + bool recursive, + bool patternMatch +) const +{ + std::string::size_type scopePos = keyword.find('.'); + + if (scopePos == string::npos) + { + // Normal, non-scoped search + return csearch(keyword, recursive, patternMatch); + } + + if (scopePos == 0) + { + // Starting with a '.' -> go up for every further '.' found + ++scopePos; + + const dictionary* dictPtr = this; + for + ( + string::const_iterator it = keyword.begin()+1; + it != keyword.end() && *it == '.'; + ++scopePos, ++it + ) + { + // Go to parent + if (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = &dictPtr->parent_; + } + else + { + FatalIOErrorInFunction + ( + *this + ) << "No parent of current dictionary when searching for " + << keyword.substr(1) + << exit(FatalIOError); + + return nullptr; + } + } + + return dictPtr->csearchDotScoped + ( + keyword.substr(scopePos), + false, + patternMatch + ); + } + + // The first word + const_searcher finder = csearchDotScoped + ( + keyword.substr(0, scopePos), + false, + patternMatch + ); + + // Fall back to finding key with '.' so e.g. if keyword is + // a.b.c.d it would try + // a.b, a.b.c, a.b.c.d + + if (!finder.found()) + { + while (!finder.isDict()) + { + scopePos = keyword.find('.', scopePos+1); + + // Local entry: + finder = csearch(keyword.substr(0, scopePos), false, patternMatch); + + if (scopePos == string::npos) + { + // Parsed the whole word. Return entry or null. + return finder; + } + } + } + + if (finder.isDict()) + { + return finder.dict().csearchDotScoped + ( + keyword.substr(scopePos), + false, + patternMatch + ); + } + + return finder; +} + + +Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped +( + const word& keyword, + bool patternMatch +) const +{ + const dictionary* dictPtr = this; + + const auto slash = keyword.find('/'); + + if (slash == string::npos) + { + // No slashes: + // Can use normal (non-scoped) search at the current dictionary level + return csearch(keyword, false, patternMatch); + } + else if (slash == 0) + { + // (isAbsolute) + // Ascend to top-level + while (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = &dictPtr->parent_; + } + } + + // Split on '/' + auto cmpts = stringOps::split<std::string>(keyword, '/'); + auto remaining = cmpts.size(); + + for (const auto& cmpt : cmpts) + { + --remaining; // Decrement now so we can check (remaining == 0) + + if (cmpt == ".") + { + // "." - ignore + } + else if (cmpt == "..") + { + // ".." - go to parent + if (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = &dictPtr->parent_; + } + else + { + FatalIOErrorInFunction + ( + *dictPtr + ) << "No parent of current dictionary when searching for " + << keyword << " at " << cmpt + << exit(FatalIOError); + break; + } + } + else + { + // Find entry + const word key = word::validate(cmpt); + + auto finder = dictPtr->csearch(key, false, patternMatch); + + if (finder.found()) + { + if (remaining) + { + // Intermediate must be a dictionary + if (finder.isDict()) + { + dictPtr = finder.dictPtr(); + } + else + { + return const_searcher(dictPtr); + } + } + else + { + // Last entry - done + return finder; + } + } + else + { + break; + } + } + } + + // Failed at this dictionary level + return const_searcher(dictPtr); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::dictionary::const_searcher Foam::dictionary::csearch +( + const word& keyword, + bool recursive, + bool patternMatch +) const +{ + const_searcher finder(this); + + auto iter = hashedEntries_.cfind(keyword); + + if (iter.found()) + { + finder.set(iter.object()); + return finder; + } + + if (patternMatch && patterns_.size()) + { + pattern_const_iterator wcLink = patterns_.begin(); + regexp_const_iterator reLink = regexps_.begin(); + + // Find in patterns using regular expressions only + if (findInPatterns(patternMatch, keyword, wcLink, reLink)) + { + finder.set(*wcLink); + return finder; + } + } + + if (recursive && &parent_ != &dictionary::null) + { + return parent_.csearch + ( + keyword, + recursive, + patternMatch + ); + } + + return finder; +} + + +Foam::dictionary::const_searcher Foam::dictionary::search +( + const word& keyword, + bool recursive, + bool patternMatch +) const +{ + return csearch(keyword, recursive, patternMatch); +} + + +Foam::dictionary::searcher Foam::dictionary::search +( + const word& keyword, + bool recursive, + bool patternMatch +) +{ + const_searcher finder = csearch(keyword, recursive, patternMatch); + + return static_cast<const searcher&>(finder); +} + + +Foam::dictionary::const_searcher Foam::dictionary::csearchScoped +( + const word& keyword, + bool recursive, + bool patternMatch +) const +{ + if (keyword.find('/') != string::npos) + { + return csearchSlashScoped(keyword, patternMatch); + } + + if (keyword[0] == ':' || keyword[0] == '^') + { + // Ascend to top-level + const dictionary* dictPtr = this; + while (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = &dictPtr->parent_; + } + + return dictPtr->csearchDotScoped + ( + keyword.substr(1), + false, + patternMatch + ); + } + + return csearchDotScoped(keyword, recursive, patternMatch); +} + + +Foam::dictionary::const_searcher Foam::dictionary::searchScoped +( + const word& keyword, + bool recursive, + bool patternMatch +) const +{ + return csearchScoped(keyword, recursive, patternMatch); +} + + +Foam::dictionary::searcher Foam::dictionary::searchScoped +( + const word& keyword, + bool recursive, + bool patternMatch +) +{ + const_searcher finder = csearchScoped(keyword, recursive, patternMatch); + + return static_cast<const searcher&>(finder); +} + + +const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr +( + const fileName& dictPath +) const +{ + // Or warning + if (dictPath.empty()) + { + return nullptr; + } + + const dictionary* dictPtr = this; + if (fileName::isAbsolute(dictPath)) + { + // Ascend to top-level + while (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = &dictPtr->parent_; + } + } + + fileName path = dictPath.clean(); + const wordList cmpts = path.components(); + + for (const word& cmpt : cmpts) + { + if (cmpt == ".") + { + // "." - ignore + } + else if (cmpt == "..") + { + // ".." - go to parent + if (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = &dictPtr->parent_; + } + else + { + FatalIOErrorInFunction + ( + *dictPtr + ) << "No parent for dictionary while searching " + << path + << exit(FatalIOError); + + return nullptr; + } + } + else + { + // Non-recursive, no patternMatch + // -> can do direct lookup, without csearch(cmpt, false, false); + + auto iter = dictPtr->hashedEntries_.cfind(cmpt); + + if (iter.found()) + { + const entry *eptr = iter.object(); + + if (eptr->isDict()) + { + dictPtr = eptr->dictPtr(); + } + else + { + FatalIOErrorInFunction + ( + *dictPtr + ) << "Found entry '" << cmpt + << "' but not a dictionary, while searching scoped" + << nl + << " " << path + << exit(FatalIOError); + + return nullptr; + } + } + else + { + return nullptr; + } + } + } + + return dictPtr; +} + + +const Foam::dictionary* Foam::dictionary::findScopedDictPtr +( + const fileName& dictPath +) const +{ + return cfindScopedDictPtr(dictPath); +} + + +Foam::dictionary* Foam::dictionary::findScopedDictPtr +( + const fileName& dictPath +) +{ + const dictionary* ptr = cfindScopedDictPtr(dictPath); + return const_cast<dictionary*>(ptr); +} + + +Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath) +{ + // Or warning + if (dictPath.empty()) + { + return nullptr; + } + + dictionary* dictPtr = this; + if (fileName::isAbsolute(dictPath)) + { + // Ascend to top-level + while (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = const_cast<dictionary*>(&dictPtr->parent_); + } + } + + // Work on a copy, without any assumptions + std::string path = dictPath; + fileName::clean(path); + + // Split on '/' + auto cmpts = stringOps::split(path, '/'); + + for (const auto& cmpt : cmpts) + { + if (cmpt == ".") + { + // "." - ignore + } + else if (cmpt == "..") + { + // ".." - go to parent + if (&dictPtr->parent_ != &dictionary::null) + { + dictPtr = const_cast<dictionary*>(&dictPtr->parent_); + } + else + { + FatalIOErrorInFunction + ( + *dictPtr + ) << "No parent for dictionary while searching " + << path + << exit(FatalIOError); + + return nullptr; + } + } + else + { + // Non-recursive, no patternMatch + // -> can do direct lookup, without csearch(cmptName, false, false); + const word cmptName(cmpt.str(), false); + + auto iter = dictPtr->hashedEntries_.find(cmptName); + + if (iter.found()) + { + entry *eptr = iter.object(); + + if (eptr->isDict()) + { + dictPtr = eptr->dictPtr(); + } + else + { + FatalIOErrorInFunction + ( + *dictPtr + ) << "Cannot create sub-dictionary entry '" << cmptName + << "' - a non-dictionary entry is in the way" + << nl << "Encountered in scope" << nl + << " " << path + << exit(FatalIOError); + + return nullptr; + } + } + else + { + dictionaryEntry *eptr = + new dictionaryEntry(cmptName, *dictPtr, dictionary()); + + // Add *without* merging, since we just checked that the entry + // doesn't exist and to ensure that the pointer remains valid. + + if (dictPtr->add(eptr, false)) // NO merge + { + dictPtr = eptr; + } + else + { + return nullptr; + } + } + } + } + + return dictPtr; +} + + +bool Foam::dictionary::remove(const word& keyword) +{ + auto iter = hashedEntries_.find(keyword); + + if (iter.found()) + { + // Delete from patterns + pattern_iterator wcLink = patterns_.begin(); + regexp_iterator reLink = regexps_.begin(); + + // Find in pattern using exact match only + if (findInPatterns(false, keyword, wcLink, reLink)) + { + patterns_.remove(wcLink); + regexps_.remove(reLink); + } + + parent_type::remove(iter()); + delete iter(); + hashedEntries_.erase(iter); + + return true; + } + else + { + return false; + } +} + + +bool Foam::dictionary::changeKeyword +( + const keyType& oldKeyword, + const keyType& newKeyword, + bool forceOverwrite +) +{ + // No change + if (oldKeyword == newKeyword) + { + return false; + } + + // Check that oldKeyword exists and can be changed + auto iter = hashedEntries_.find(oldKeyword); + + if (!iter.found()) + { + return false; + } + + if (iter()->keyword().isPattern()) + { + FatalIOErrorInFunction + ( + *this + ) << "Old keyword "<< oldKeyword + << " is a pattern." + << "Pattern replacement not yet implemented." + << exit(FatalIOError); + } + + + auto iter2 = hashedEntries_.find(newKeyword); + + // newKeyword already exists + if (iter2.found()) + { + if (forceOverwrite) + { + if (iter2()->keyword().isPattern()) + { + // Delete from patterns + pattern_iterator wcLink = patterns_.begin(); + regexp_iterator reLink = regexps_.begin(); + + // Find in patterns using exact match only + if (findInPatterns(false, iter2()->keyword(), wcLink, reLink)) + { + patterns_.remove(wcLink); + regexps_.remove(reLink); + } + } + + parent_type::replace(iter2(), iter()); + delete iter2(); + hashedEntries_.erase(iter2); + } + else + { + IOWarningInFunction + ( + *this + ) << "cannot rename keyword "<< oldKeyword + << " to existing keyword " << newKeyword + << " in dictionary " << name() << endl; + return false; + } + } + + // Change name and HashTable, but leave DL-List untouched + iter()->keyword() = newKeyword; + iter()->name() = name() + '.' + newKeyword; + hashedEntries_.erase(oldKeyword); + hashedEntries_.insert(newKeyword, iter()); + + if (newKeyword.isPattern()) + { + patterns_.insert(iter()); + regexps_.insert + ( + autoPtr<regExp>(new regExp(newKeyword)) + ); + } + + return true; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index 1e46e5da33b..d0446b6770f 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -43,9 +43,9 @@ T Foam::dictionary::lookupType bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); + auto finder = csearch(keyword, recursive, patternMatch); - if (entryPtr == nullptr) + if (!finder.found()) { FatalIOErrorInFunction ( @@ -55,7 +55,7 @@ T Foam::dictionary::lookupType << exit(FatalIOError); } - return pTraits<T>(entryPtr->stream()); + return pTraits<T>(finder.ptr()->stream()); } @@ -68,11 +68,11 @@ T Foam::dictionary::lookupOrDefault bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); + auto finder = csearch(keyword, recursive, patternMatch); - if (entryPtr) + if (finder.found()) { - return pTraits<T>(entryPtr->stream()); + return pTraits<T>(finder.ptr()->stream()); } else { @@ -98,11 +98,11 @@ T Foam::dictionary::lookupOrAddDefault bool patternMatch ) { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); + auto finder = csearch(keyword, recursive, patternMatch); - if (entryPtr) + if (finder.found()) { - return pTraits<T>(entryPtr->stream()); + return pTraits<T>(finder.ptr()->stream()); } else { @@ -129,11 +129,11 @@ bool Foam::dictionary::readIfPresent bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); + auto finder = csearch(keyword, recursive, patternMatch); - if (entryPtr) + if (finder.found()) { - entryPtr->stream() >> val; + finder.ptr()->stream() >> val; return true; } else @@ -152,16 +152,16 @@ bool Foam::dictionary::readIfPresent template<class T> -void Foam::dictionary::add(const keyType& k, const T& t, bool overwrite) +void Foam::dictionary::add(const keyType& k, const T& v, bool overwrite) { - add(new primitiveEntry(k, t), overwrite); + add(new primitiveEntry(k, v), overwrite); } template<class T> -void Foam::dictionary::set(const keyType& k, const T& t) +void Foam::dictionary::set(const keyType& k, const T& v) { - set(new primitiveEntry(k, t)); + set(new primitiveEntry(k, v)); } diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index b8a75380ab5..f6879570d23 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -224,17 +224,12 @@ bool Foam::entry::New const word varName = keyword.substr(1); // Lookup the variable name in the given dictionary - const entry* ePtr = parentDict.lookupScopedEntryPtr - ( - varName, - true, - true - ); + const auto finder = parentDict.csearchScoped(varName, true, true); - if (ePtr) + if (finder.found()) { // Read as primitiveEntry - const keyType newKeyword(ePtr->stream()); + const keyType newKeyword(finder.ptr()->stream()); return parentDict.add ( @@ -285,14 +280,9 @@ bool Foam::entry::New bool mergeEntry = false; // See (using exact match) if entry already present - entry* existingPtr = parentDict.lookupEntryPtr - ( - keyword, - false, - false - ); + auto finder = parentDict.search(keyword, false, false); - if (existingPtr) + if (finder.found()) { if (mode == inputMode::MERGE) { @@ -301,9 +291,9 @@ bool Foam::entry::New else if (mode == inputMode::OVERWRITE) { // Clear existing dictionary so merge acts like overwrite - if (existingPtr->isDict()) + if (finder.isDict()) { - existingPtr->dict().clear(); + finder.dict().clear(); } mergeEntry = true; } -- GitLab From c880d7dc7d11b25370647542ebeed8cf891535fe Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 13 Jul 2017 09:46:07 +0200 Subject: [PATCH 002/126] ENH: support '/' separators in foamDictionary - convenience -diffEtc option that behaves like -diff, but invokes foamEtcFile searching STYLE: modernize code. --- .../foamDictionary/foamDictionary.C | 367 ++++++++++-------- src/OpenFOAM/db/dictionary/dictionary.C | 61 ++- src/OpenFOAM/db/dictionary/dictionary.H | 157 ++++---- src/OpenFOAM/db/dictionary/dictionarySearch.C | 4 +- .../db/dictionary/dictionaryTemplates.C | 58 ++- 5 files changed, 353 insertions(+), 294 deletions(-) diff --git a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C index e4c31862614..57210c5a576 100644 --- a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C +++ b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,7 +33,7 @@ Usage - \par -entry \<name\> Selects an entry - - \par -keywords \<name\> + - \par -keywords Prints the keywords (of the selected entry or of the top level if no entry was selected @@ -50,6 +50,10 @@ Usage Write differences with respect to the specified dictionary (or sub entry if -entry specified) + - \par -diffEtc \<dictionary\> + Write differences with respect to the specified dictionary + (or sub entry if -entry specified) + - \par -expand Read the specified dictionary file, expand the macros etc. and write the resulting dictionary to standard output. @@ -90,13 +94,13 @@ Usage - Write the differences with respect to a template dictionary: \verbatim - foamDictionary 0/U -diff $FOAM_ETC/templates/closedVolume/0/U + foamDictionary 0/U -diffEtc templates/closedVolume/0/U \endverbatim - Write the differences in boundaryField with respect to a template dictionary: \verbatim - foamDictionary 0/U -diff $FOAM_ETC/templates/closedVolume/0/U \ + foamDictionary 0/U -diffEtc templates/closedVolume/0/U \ -entry boundaryField \endverbatim @@ -115,50 +119,78 @@ Usage #include "profiling.H" #include "Time.H" #include "Fstream.H" +#include "etcFiles.H" #include "includeEntry.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Converts old scope syntax to new syntax -word scope(const fileName& entryName) +//- Convert older ':' scope syntax to newer '.' scope syntax, +// but leave anything with '/' delimiters untouched +bool upgradeScope(word& entryName) { - if (entryName.find(':') != string::npos) + if + ( + entryName.find('/') == string::npos + && entryName.find(':') != string::npos + ) { - wordList entryNames(entryName.components(':')); + const wordList names(fileName(entryName).components(':')); + + entryName.resize(0); - word entry(entryNames[0]); - for (label i = 1; i < entryNames.size(); i++) + for (const word& name : names) { - entry += word('.') + entryNames[i]; + if (entryName.size()) entryName.append("."); + + entryName.append(name); } - return entry; - } - else - { - return entryName; + + return true; } + + // Nothing changed + return false; } -//- Extracts dict name and keyword -Pair<word> dictAndKeyword(const word& scopedName) +//- Split into dictionary name and the entry name +class dictAndKeyword { - string::size_type i = scopedName.find_last_of("."); - if (i != string::npos) + word dict_; + word key_; + +public: + dictAndKeyword(const word& scopedName) { - return Pair<word> - ( - scopedName.substr(0, i), - scopedName.substr(i+1, string::npos) - ); + string::size_type i = scopedName.rfind('/'); + if (i == string::npos) + { + i = scopedName.rfind('.'); + } + + if (i != string::npos) + { + dict_ = scopedName.substr(0, i); + key_ = scopedName.substr(i+1); + } + else + { + key_ = scopedName; + } } - else + + inline const word& dict() const { - return Pair<word>("", scopedName); + return dict_; } -} + + inline const word& key() const + { + return key_; + } +}; const dictionary& lookupScopedDict @@ -167,71 +199,56 @@ const dictionary& lookupScopedDict const word& subDictName ) { - if (subDictName == "") + if (subDictName.empty()) { return dict; } - else + + const entry* eptr = dict.lookupScopedEntryPtr(subDictName, false, false); + + if (!eptr || !eptr->isDict()) { - const entry* entPtr = dict.lookupScopedEntryPtr - ( - subDictName, - false, - false - ); - if (!entPtr || !entPtr->isDict()) - { - FatalIOErrorInFunction(dict) - << "keyword " << subDictName - << " is undefined in dictionary " - << dict.name() << " or is not a dictionary" - << endl - << "Valid keywords are " << dict.keys() - << exit(FatalIOError); - } - return entPtr->dict(); + FatalIOErrorInFunction(dict) + << "keyword " << subDictName + << " is undefined in dictionary " + << dict.name() << " or is not a dictionary" + << endl + << "Valid keywords are " << dict.keys() + << exit(FatalIOError); } + + return eptr->dict(); } -void remove(dictionary& dict, const dictionary& removeDict) +void removeDict(dictionary& dict, const dictionary& dictToRemove) { - forAllConstIter(dictionary, removeDict, iter) + for (const entry& refEntry : dictToRemove) { - const entry* entPtr = dict.lookupEntryPtr - ( - iter().keyword(), - false, - false - ); + auto finder = dict.search(refEntry.keyword(), false, false); - if (entPtr) + bool purge = false; + + if (finder.isDict()) { - if (entPtr->isDict()) - { - if (iter().isDict()) - { - remove - ( - const_cast<dictionary&>(entPtr->dict()), - iter().dict() - ); - - // Check if dictionary is empty - if (!entPtr->dict().size()) - { - dict.remove(iter().keyword()); - } - } - } - else if (!iter().isDict()) + if (refEntry.isDict()) { - if (*entPtr == iter()) - { - dict.remove(iter().keyword()); - } + removeDict(finder.dict(), refEntry.dict()); + + // Purge if dictionary is empty + purge = finder.dict().empty(); } } + else if (finder.found() && !refEntry.isDict()) + { + // Purge if entries match + purge = (finder.ref() == refEntry); + } + + if (purge) + { + dict.remove(refEntry.keyword()); + } } } @@ -243,7 +260,7 @@ int main(int argc, char *argv[]) argList::noBanner(); argList::noJobInfo(); argList::validArgs.append("dictionary"); - argList::addBoolOption("keywords", "list keywords"); + argList::addBoolOption("keywords", "List keywords"); argList::addOption("entry", "name", "report/select the named entry"); argList::addBoolOption ( @@ -273,6 +290,12 @@ int main(int argc, char *argv[]) "dict", "Write differences with respect to the specified dictionary" ); + argList::addOption + ( + "diffEtc", + "dict", + "As per -diff, but locate the file as per foamEtcFile" + ); argList::addBoolOption ( "includes", @@ -303,13 +326,12 @@ int main(int argc, char *argv[]) const bool disableEntries = args.optionFound("disableFunctionEntries"); if (disableEntries) { - Info<< "Not expanding variables or dictionary directives" - << endl; + Info<< "Not expanding variables or dictionary directives" << endl; entry::disableFunctionEntries = true; } - fileName dictFileName(args[1]); + const fileName dictFileName(args[1]); autoPtr<IFstream> dictFile(new IFstream(dictFileName)); if (!dictFile().good()) @@ -341,28 +363,55 @@ int main(int argc, char *argv[]) } - // Second dictionary for -diff + // Has "diff" or "diffEtc" + bool optDiff = false; + + // Reference dictionary for -diff / -diffEtc dictionary diffDict; - fileName diffFileName; - if (args.optionReadIfPresent("diff", diffFileName)) { - autoPtr<IFstream> diffFile(new IFstream(diffFileName)); - if (!diffFile().good()) + fileName diffFileName; + if (args.optionReadIfPresent("diff", diffFileName)) { - FatalErrorInFunction - << "Cannot open file " << diffFileName - << exit(FatalError, 1); + IFstream diffFile(diffFileName); + if (!diffFile.good()) + { + FatalErrorInFunction + << "Cannot open file " << diffFileName + << exit(FatalError, 1); + } + + // Read but preserve headers + diffDict.read(diffFile, true); + optDiff = true; } + else if (args.optionReadIfPresent("diffEtc", diffFileName)) + { + fileName foundName = findEtcFile(diffFileName); + if (foundName.empty()) + { + FatalErrorInFunction + << "Cannot find etcFile " << diffFileName + << exit(FatalError, 1); + } - // Read but preserve headers - diffDict.read(diffFile(), true); - } + IFstream diffFile(foundName); + if (!diffFile.good()) + { + FatalErrorInFunction + << "Cannot open file " << foundName + << exit(FatalError, 1); + } + // Read but preserve headers + diffDict.read(diffFile, true); + optDiff = true; + } + } - word entryName; - if (args.optionReadIfPresent("entry", entryName)) + word scopedName; // Actually fileName, since it can contain '/' scoping + if (args.optionReadIfPresent("entry", scopedName)) { - word scopedName(scope(entryName)); + upgradeScope(scopedName); string newValue; if @@ -371,13 +420,17 @@ int main(int argc, char *argv[]) || args.optionReadIfPresent("add", newValue) ) { - bool overwrite = args.optionFound("set"); + const bool overwrite = args.optionFound("set"); - Pair<word> dAk(dictAndKeyword(scopedName)); + // Dictionary name and keyword + const dictAndKeyword dAk(scopedName); - IStringStream str(string(dAk.second()) + ' ' + newValue + ';'); + // The context for the action + const dictionary& d(lookupScopedDict(dict, dAk.dict())); + + // Create a new entry + IStringStream str(string(dAk.key()) + ' ' + newValue + ';'); entry* ePtr(entry::New(str).ptr()); - const dictionary& d(lookupScopedDict(dict, dAk.first())); if (overwrite) { @@ -390,122 +443,116 @@ int main(int argc, char *argv[]) changed = true; // Print the changed entry - const entry* entPtr = dict.lookupScopedEntryPtr + const auto finder = dict.csearchScoped ( scopedName, false, - true // Support wildcards + true // Support wildcards ); - if (entPtr) + + if (finder.found()) { - Info<< *entPtr; + Info<< finder.ref(); } } else if (args.optionFound("remove")) { - // Extract dictionary name and keyword - Pair<word> dAk(dictAndKeyword(scopedName)); + // Dictionary name and keyword + const dictAndKeyword dAk(scopedName); + + // The context for the action + const dictionary& d(lookupScopedDict(dict, dAk.dict())); - const dictionary& d(lookupScopedDict(dict, dAk.first())); - const_cast<dictionary&>(d).remove(dAk.second()); + const_cast<dictionary&>(d).remove(dAk.key()); changed = true; } else { // Optionally remove a second dictionary - if (args.optionFound("diff")) + if (optDiff) { - Pair<word> dAk(dictAndKeyword(scopedName)); + // Dictionary name and keyword + const dictAndKeyword dAk(scopedName); - const dictionary& d(lookupScopedDict(dict, dAk.first())); - const dictionary& d2(lookupScopedDict(diffDict, dAk.first())); + const dictionary& d1(lookupScopedDict(dict, dAk.dict())); + const dictionary& d2(lookupScopedDict(diffDict, dAk.dict())); - const entry* ePtr = - d.lookupEntryPtr(dAk.second(), false, true); - const entry* e2Ptr = - d2.lookupEntryPtr(dAk.second(), false, true); + const entry* e1Ptr = d1.lookupEntryPtr(dAk.key(), false, true); + const entry* e2Ptr = d2.lookupEntryPtr(dAk.key(), false, true); - if (ePtr && e2Ptr) + if (e1Ptr && e2Ptr) { - if (*ePtr == *e2Ptr) + if (*e1Ptr == *e2Ptr) { - const_cast<dictionary&>(d).remove(dAk.second()); + const_cast<dictionary&>(d1).remove(dAk.key()); } - else if (ePtr->isDict() && e2Ptr->isDict()) + else if (e1Ptr->isDict() && e2Ptr->isDict()) { - remove + removeDict ( - const_cast<dictionary&>(ePtr->dict()), + const_cast<dictionary&>(e1Ptr->dict()), e2Ptr->dict() ); } } } - - const entry* entPtr = dict.lookupScopedEntryPtr + const auto finder = dict.csearchScoped ( scopedName, false, - true // Support wildcards + true // Support wildcards ); - if (entPtr) + if (!finder.found()) { - if (args.optionFound("keywords")) + FatalIOErrorInFunction(dictFile()) + << "Cannot find entry " << scopedName + << exit(FatalIOError, 2); + } + else if (args.optionFound("keywords")) + { + for (const entry& e : finder.dict()) { - const dictionary& dict = entPtr->dict(); - forAllConstIter(dictionary, dict, iter) - { - Info<< iter().keyword() << endl; - } + Info<< e.keyword() << endl; + } + } + else if (args.optionFound("value")) + { + if (finder.isDict()) + { + Info<< finder.dict(); } - else + else if (finder.ref().isStream()) { - if (args.optionFound("value")) + const tokenList& tokens = finder.ref().stream(); + forAll(tokens, i) { - if (entPtr->isStream()) + Info<< tokens[i]; + if (i < tokens.size() - 1) { - const tokenList& tokens = entPtr->stream(); - forAll(tokens, i) - { - Info<< tokens[i]; - if (i < tokens.size() - 1) - { - Info<< token::SPACE; - } - } - Info<< endl; - } - else if (entPtr->isDict()) - { - Info<< entPtr->dict(); + Info<< token::SPACE; } } - else - { - Info<< *entPtr; - } + Info<< endl; } } else { - FatalIOErrorInFunction(dictFile) - << "Cannot find entry " << entryName - << exit(FatalIOError, 2); + Info<< finder.ref(); } } } else if (args.optionFound("keywords")) { - forAllConstIter(dictionary, dict, iter) + for (const entry& e : dict) { - Info<< iter().keyword() << endl; + Info<< e.keyword() << endl; } } - else if (args.optionFound("diff")) + else if (optDiff) { - remove(dict, diffDict); + removeDict(dict, diffDict); dict.write(Info, false); } else diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 46cee88d67d..a39fbf48629 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -171,10 +171,8 @@ const Foam::dictionary& Foam::dictionary::topDict() const { return p.topDict(); } - else - { - return *this; - } + + return *this; } @@ -184,10 +182,8 @@ Foam::label Foam::dictionary::startLineNumber() const { return first()->startLineNumber(); } - else - { - return -1; - } + + return -1; } @@ -197,10 +193,8 @@ Foam::label Foam::dictionary::endLineNumber() const { return last()->endLineNumber(); } - else - { - return -1; - } + + return -1; } @@ -575,16 +569,15 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) return true; } - else - { - IOWarningInFunction((*this)) - << "problem replacing entry "<< entryPtr->keyword() - << " in dictionary " << name() << endl; - parent_type::remove(entryPtr); - delete entryPtr; - return false; - } + + IOWarningInFunction((*this)) + << "problem replacing entry "<< entryPtr->keyword() + << " in dictionary " << name() << endl; + + parent_type::remove(entryPtr); + delete entryPtr; + return false; } @@ -604,16 +597,15 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) return true; } - else - { - IOWarningInFunction((*this)) - << "attempt to add entry "<< entryPtr->keyword() - << " which already exists in dictionary " << name() - << endl; - delete entryPtr; - return false; - } + + IOWarningInFunction((*this)) + << "attempt to add entry "<< entryPtr->keyword() + << " which already exists in dictionary " << name() + << endl; + + delete entryPtr; + return false; } @@ -796,7 +788,8 @@ void Foam::dictionary::operator+=(const dictionary& rhs) if (this == &rhs) { FatalIOErrorInFunction(*this) - << "attempted addition assignment to self for dictionary " << name() + << "attempted addition assignment to self for dictionary " + << name() << abort(FatalIOError); } @@ -812,7 +805,8 @@ void Foam::dictionary::operator|=(const dictionary& rhs) if (this == &rhs) { FatalIOErrorInFunction(*this) - << "attempted assignment to self for dictionary " << name() + << "attempted assignment to self for dictionary " + << name() << abort(FatalIOError); } @@ -831,7 +825,8 @@ void Foam::dictionary::operator<<=(const dictionary& rhs) if (this == &rhs) { FatalIOErrorInFunction(*this) - << "attempted assignment to self for dictionary " << name() + << "attempted assignment to self for dictionary " + << name() << abort(FatalIOError); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 783c6436563..7b3baa055a9 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -471,10 +471,11 @@ public: // Search and lookup - //- Search dictionary for given keyword - // If recursive, search parent dictionaries - // If patternMatch, use regular expressions - // (default search: non-recursive with patterns). + //- Search dictionary for given keyword. + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions bool found ( const word& keyword, @@ -482,10 +483,10 @@ public: bool patternMatch = true ) const; - //- Find and return an entry data stream pointer if present - // otherwise return nullptr. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions + //- Find and return an entry pointer if present, or return a nullptr. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions const entry* lookupEntryPtr ( const word& keyword, @@ -493,10 +494,11 @@ public: bool patternMatch ) const; - //- Find and return an entry data stream pointer for manipulation - // if present otherwise return nullptr. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. + //- Find and return an entry pointer for manipulation if present, + // or return a nullptr. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions entry* lookupEntryPtr ( const word& keyword, @@ -504,9 +506,10 @@ public: bool patternMatch ); - //- Find and return an entry data stream if present otherwise error. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. + //- Find and return an entry if present otherwise error. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions const entry& lookupEntry ( const word& keyword, @@ -514,10 +517,11 @@ public: bool patternMatch ) const; - //- Find and return an entry data stream - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - // (default search: non-recursive with patterns). + //- Find and return an entry data stream. + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions ITstream& lookup ( const word& keyword, @@ -525,11 +529,11 @@ public: bool patternMatch = true ) const; - //- Find and return a T, - // if not found throw a fatal error. - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - // (default search: non-recursive with patterns). + //- Find and return a T. FatalError if not found. + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions template<class T> T lookupType ( @@ -539,9 +543,10 @@ public: ) const; //- Find and return a T, or return the given default value - // If recursive, search parent dictionaries. - // If patternMatch, use regular expressions. - // (default search: non-recursive with patterns). + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions template<class T> T lookupOrDefault ( @@ -598,12 +603,14 @@ public: ) const; //- Check if entry exists and is a sub-dictionary. - // (search type: non-recursive with patterns) + // + // Search type: non-recursive with patterns. bool isDict(const word& keyword) const; //- Find and return a sub-dictionary pointer if present // (and a sub-dictionary) otherwise return nullptr. - // (search type: non-recursive with patterns) + // + // Search type: non-recursive with patterns. const dictionary* subDictPtr(const word& keyword) const; //- Find and return a sub-dictionary pointer if present @@ -614,18 +621,21 @@ public: //- Find and return a sub-dictionary. // Fatal if the entry does not exist or is not a sub-dictionary. - // (search type: non-recursive with patterns) + // + // Search type: non-recursive with patterns. const dictionary& subDict(const word& keyword) const; //- Find and return a sub-dictionary for manipulation. // Fatal if the entry does not exist or is not a sub-dictionary. - // (search type: non-recursive with patterns) + // + // Search type: non-recursive with patterns. dictionary& subDict(const word& keyword); //- Find and return a sub-dictionary as a copy, otherwise return // an empty dictionary. // Warn if the entry exists but is not a sub-dictionary. - // (search type: non-recursive with patterns) + // + // Search type: non-recursive with patterns. dictionary subOrEmptyDict ( const word& keyword, @@ -634,7 +644,8 @@ public: //- Find and return a sub-dictionary, otherwise return this dictionary. // Warn if the entry exists but is not a sub-dictionary. - // (search type: non-recursive with patterns) + // + // Search type: non-recursive with patterns. const dictionary& optionalSubDict(const word& keyword) const; //- Return the table of contents @@ -669,34 +680,34 @@ public: bool mergeEntry = false ); - //- Add a new entry - // With the merge option, dictionaries are interwoven and - // primitive entries are overwritten + //- Add a new entry. + // \param mergeEntry dictionaries are interwoven and primitive + // entries are overwritten bool add(entry* entryPtr, bool mergeEntry=false); - //- Add an entry - // With the merge option, dictionaries are interwoven and - // primitive entries are overwritten + //- Add an entry. + // \param mergeEntry dictionaries are interwoven and primitive + // entries are overwritten void add(const entry& e, bool mergeEntry=false); - //- Add a word entry - // optionally overwrite an existing entry + //- Add a word entry. + // \param overwrite force overwrite of an existing entry. void add(const keyType& k, const word& v, bool overwrite=false); - //- Add a string entry - // optionally overwrite an existing entry + //- Add a string entry. + // \param overwrite force overwrite of an existing entry. void add(const keyType& k, const string& v, bool overwrite=false); - //- Add a label entry - // optionally overwrite an existing entry + //- Add a label entry. + // \param overwrite force overwrite of an existing entry. void add(const keyType& k, const label v, bool overwrite=false); - //- Add a scalar entry - // optionally overwrite an existing entry + //- Add a scalar entry. + // \param overwrite force overwrite of an existing entry. void add(const keyType& k, const scalar v, bool overwrite=false); - //- Add a dictionary entry - // optionally merge with an existing sub-dictionary + //- Add a dictionary entry. + // \param mergeEntry merge into an existing sub-dictionary void add ( const keyType& k, @@ -705,20 +716,20 @@ public: ); //- Add a T entry - // optionally overwrite an existing entry + // \param overwrite force overwrite of existing entry template<class T> void add(const keyType& k, const T& v, bool overwrite=false); - //- Assign a new entry, overwrite any existing entry + //- Assign a new entry, overwriting any existing entry. void set(entry* entryPtr); - //- Assign a new entry, overwrite any existing entry + //- Assign a new entry, overwriting any existing entry. void set(const entry& e); - //- Assign a dictionary entry, overwrite any existing entry + //- Assign a dictionary entry, overwriting any existing entry. void set(const keyType& k, const dictionary& v); - //- Assign a T entry, overwrite any existing entry + //- Assign a T entry, overwriting any existing entry. template<class T> void set(const keyType& k, const T& v); @@ -726,12 +737,12 @@ public: bool remove(const word& keyword); //- Change the keyword for an entry, - // optionally forcing overwrite of an existing entry + // \param overwrite force overwrite of an existing entry. bool changeKeyword ( const keyType& oldKeyword, const keyType& newKeyword, - bool forceOverwrite=false + bool overwrite=false ); //- Merge entries from the given dictionary. @@ -763,8 +774,8 @@ public: void writeEntry(const keyType& keyword, Ostream& os) const; //- Write dictionary entries. - // Optionally with extra new line between entries for - // "top-level" dictionaries + // \param extraNewLine adds additional newline\n between entries + // for "top-level" dictionaries void writeEntries(Ostream& os, const bool extraNewLine=false) const; //- Write dictionary, normally with sub-dictionary formatting @@ -774,9 +785,10 @@ public: // Searching //- Search dictionary for given keyword - // If recursive, search parent dictionaries - // If patternMatch, use regular expressions - // (default search: non-recursive with patterns). + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions const_searcher csearch ( const word& keyword, @@ -785,9 +797,10 @@ public: ) const; //- Search dictionary for given keyword - // If recursive, search parent dictionaries - // If patternMatch, use regular expressions - // (default search: non-recursive with patterns). + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions const_searcher search ( const word& keyword, @@ -796,9 +809,10 @@ public: ) const; //- Search dictionary for given keyword - // If recursive, search parent dictionaries - // If patternMatch, use regular expressions - // (default search: non-recursive with patterns). + // Default search: non-recursive with patterns. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions searcher search ( const word& keyword, @@ -826,6 +840,9 @@ public: // Any doubled slashes are silently ignored. // Since a slash is not a valid keyword character, there is no // ambiguity between separator and content. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions const_searcher csearchScoped ( const word& keyword, @@ -834,6 +851,9 @@ public: ) const; //- Search using dot or slash scoping. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions const_searcher searchScoped ( const word& keyword, @@ -842,6 +862,9 @@ public: ) const; //- Search using dot or slash scoping. + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions searcher searchScoped ( const word& keyword, diff --git a/src/OpenFOAM/db/dictionary/dictionarySearch.C b/src/OpenFOAM/db/dictionary/dictionarySearch.C index 93c5bcb884a..cc711af70a5 100644 --- a/src/OpenFOAM/db/dictionary/dictionarySearch.C +++ b/src/OpenFOAM/db/dictionary/dictionarySearch.C @@ -631,7 +631,7 @@ bool Foam::dictionary::changeKeyword ( const keyType& oldKeyword, const keyType& newKeyword, - bool forceOverwrite + bool overwrite ) { // No change @@ -665,7 +665,7 @@ bool Foam::dictionary::changeKeyword // newKeyword already exists if (iter2.found()) { - if (forceOverwrite) + if (overwrite) { if (iter2()->keyword().isPattern()) { diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index d0446b6770f..9e887c08f61 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -74,18 +74,16 @@ T Foam::dictionary::lookupOrDefault { return pTraits<T>(finder.ptr()->stream()); } - else + + if (writeOptionalEntries) { - if (writeOptionalEntries) - { - IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " returning the default value '" << deflt << "'" - << endl; - } - - return deflt; + IOInfoInFunction(*this) + << "Optional entry '" << keyword << "' is not present," + << " returning the default value '" << deflt << "'" + << endl; } + + return deflt; } @@ -104,19 +102,17 @@ T Foam::dictionary::lookupOrAddDefault { return pTraits<T>(finder.ptr()->stream()); } - else + + if (writeOptionalEntries) { - if (writeOptionalEntries) - { - IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " adding and returning the default value '" << deflt << "'" - << endl; - } - - add(new primitiveEntry(keyword, deflt)); - return deflt; + IOInfoInFunction(*this) + << "Optional entry '" << keyword << "' is not present," + << " adding and returning the default value '" << deflt << "'" + << endl; } + + add(new primitiveEntry(keyword, deflt)); + return deflt; } @@ -136,18 +132,16 @@ bool Foam::dictionary::readIfPresent finder.ptr()->stream() >> val; return true; } - else + + if (writeOptionalEntries) { - if (writeOptionalEntries) - { - IOInfoInFunction(*this) - << "Optional entry '" << keyword << "' is not present," - << " the default value '" << val << "' will be used." - << endl; - } - - return false; + IOInfoInFunction(*this) + << "Optional entry '" << keyword << "' is not present," + << " the default value '" << val << "' will be used." + << endl; } + + return false; } -- GitLab From 2fdc6b161adfe4d537b751f8e398a6c57a72b268 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 20 Jul 2017 10:58:05 +0200 Subject: [PATCH 003/126] ENH: support full-scoping for keywords as lvalue (issue #429) - patterns only supported for the final element. To create an element as a pattern instead of a word, an embedded string quote (single or double) is used for that element. Any of the following examples: "/top/sub/dict/'(p|U).*" 100; "/top/sub/dict/'(p|U).*'" 100; "/top/sub/dict/\"(p|U).*" 100; "/top/sub/dict/\"(p|U).*\"" 100; are equivalent to the longer form: top { sub { dict { "(p|U).*" 100; } } } It is not currently possible to auto-vivify intermediate dictionaries with patterns. NOK "/nonexistent.*/value" 100; OK "/existing.*/value" 100; - full scoping also works for the #remove directive #remove "/dict1/subdict2/entry1" --- applications/test/dictionary/testSubkeyword | 68 +++++++++- src/OpenFOAM/db/dictionary/entry/entryIO.C | 128 +++++++++++++++--- .../functionEntries/removeEntry/removeEntry.C | 34 +++-- .../functionEntries/removeEntry/removeEntry.H | 17 ++- 4 files changed, 211 insertions(+), 36 deletions(-) diff --git a/applications/test/dictionary/testSubkeyword b/applications/test/dictionary/testSubkeyword index f8ee1485011..3465f0623ef 100644 --- a/applications/test/dictionary/testSubkeyword +++ b/applications/test/dictionary/testSubkeyword @@ -17,6 +17,8 @@ FoamFile // #inputMode overwrite key1 val1; +val1 val1; +val2 val2; subdict { @@ -35,19 +37,75 @@ update key3 val3; key2b ${..key2}; key3b $^key1; + key100 100; + key200 200; + key300 300; + key400 400; } } +// expands update into top-level $update -// Can a leading '^' or ':' as anchor for scoping -key3 $^subdict.key1; + +_cleanup +{ + #remove "/subdict/key300" + "/subdict/key400" 400000; + + // Self-destruct not possible + // #remove "/_cleanup" +} + +#remove "/_cleanup" + +// Can use a leading '^' or ':' as anchor for scoping, but slashes are clearer +key3dot ${^subdict.key1}; +key3slash ${/subdict/key1}; key3 ${^update.subdict.key3}; key4 ${:update.subdict...subdict.key1}; -// This is currently not working -#remove update.key1 -// #remove update +// This will not work, but globs would be interesting: +#remove "/update/subdict/key*" + +// This is okay, uses a regexp directly +#remove "val.*" + +#remove "/update/subdict/key100" + +"/subdict/key2" overridden; + + +active +{ + type turbulentIntensityKineticEnergyInlet; + intensity 0.1; + value 100; +} + +// Some more with scoping + +"/active/value(pwd)" 200; +"/active/'(pwd|foo)'" 200; // Can use single or double quotes +"/active/intensity" 0.05; + +// Auto-vivify intermediate dictionaries + +"/active/subdict/type" anotherType; +"/active/subdict/value/type" anotherType; + +// This is an error - cannot change type of intermediate dictionaries! +// "active/value/type/of/things" newType; + +"/active/subdict/value" change; + +"/active/subdict/value" { entry1 value1; entry2 value2; } + +// Handle remove as per changeDictionary? TBD +// Removal: +// "~/active/subdict/value" + +// "~active" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index f6879570d23..3e549c9faf6 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -262,7 +262,7 @@ bool Foam::entry::New } else { - // Normal entry + // Normal or scoped entry token nextToken(is); is.putBack(nextToken); @@ -279,11 +279,25 @@ bool Foam::entry::New // How to manage duplicate entries bool mergeEntry = false; + const bool scoped = + ( + !disableFunctionEntries + && (keyword.find('/') != string::npos) + ); + // See (using exact match) if entry already present - auto finder = parentDict.search(keyword, false, false); + auto finder = + ( + scoped + ? parentDict.searchScoped(keyword, false, false) + : parentDict.search(keyword, false, false) + ); if (finder.found()) { + // Use keyword from the found entry (ie, eliminate scoping chars) + const keyType key = finder.ref().keyword(); + if (mode == inputMode::MERGE) { mergeEntry = true; @@ -306,11 +320,11 @@ bool Foam::entry::New if (nextToken == token::BEGIN_BLOCK) { - dictionaryEntry dummy("dummy", parentDict, is); + dictionaryEntry dummy("dummy", finder.context(), is); } else { - primitiveEntry dummy("dummy", parentDict, is); + primitiveEntry dummy("dummy", finder.context(), is); } entry::disableFunctionEntries = oldFlag; @@ -319,29 +333,109 @@ bool Foam::entry::New else if (mode == inputMode::ERROR) { FatalIOErrorInFunction(is) - << "duplicate entry: " << keyword + << "duplicate entry: " << key << exit(FatalIOError); return false; } - } + // Merge/overwrite data entry - if (nextToken == token::BEGIN_BLOCK) + if (nextToken == token::BEGIN_BLOCK) + { + return finder.context().add + ( + new dictionaryEntry(key, finder.context(), is), + mergeEntry + ); + } + else + { + return finder.context().add + ( + new primitiveEntry(key, finder.context(), is), + mergeEntry + ); + } + } + else if (scoped) { - return parentDict.add - ( - new dictionaryEntry(keyword, parentDict, is), - mergeEntry - ); + // A slash-scoped entry - did not previously exist + + string fullPath(keyword); + fileName::clean(fullPath); + + // Get or create the dictionary-path. + // fileName::path == dictionary-path + dictionary* subDictPtr = + parentDict.makeScopedDictPtr + ( + fileName::path(fullPath) + ); + + if (subDictPtr) + { + // fileName::name == keyword-name + string keyName = fileName::name(fullPath); + keyType key; + + // Patterns allowed for the final element. + // - use if key name begins with a (single|double) quote + + if (keyName.find_first_of("\"'") == 0) + { + // Begins with a quote - treat as pattern + key = keyType(string::validate<keyType>(keyName), true); + } + else + { + // Treat as a word + key = word::validate(keyName, false); + } + + if (nextToken == token::BEGIN_BLOCK) + { + return subDictPtr->add + ( + new dictionaryEntry(key, *subDictPtr, is), + mergeEntry + ); + } + else + { + return subDictPtr->add + ( + new primitiveEntry(key, *subDictPtr, is), + mergeEntry + ); + } + } + else + { + // Some error finding/creating intermediate dictionaries + return false; + } } else { - return parentDict.add - ( - new primitiveEntry(keyword, parentDict, is), - mergeEntry - ); + // A non-scoped entry - did not previously exist + + if (nextToken == token::BEGIN_BLOCK) + { + return parentDict.add + ( + new dictionaryEntry(keyword, parentDict, is), + mergeEntry + ); + } + else + { + return parentDict.add + ( + new primitiveEntry(keyword, parentDict, is), + mergeEntry + ); + } } } } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C index a0c413edd89..ebe2baf2164 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,7 +26,6 @@ License #include "removeEntry.H" #include "dictionary.H" #include "stringListOps.H" -#include "StringStream.H" #include "addToMemberFunctionSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -55,17 +54,36 @@ bool Foam::functionEntries::removeEntry::execute Istream& is ) { - wordList dictKeys = parentDict.toc(); - wordReList patterns = readList<wordRe>(is); + const List<keyType> patterns = readList<keyType>(is); - labelList indices = findStrings(patterns, dictKeys); - - forAll(indices, indexI) + for (const keyType& key : patterns) { - parentDict.remove(dictKeys[indices[indexI]]); + if (key.find('/') != string::npos || !key.isPattern()) + { + // Remove scoped keyword, or keyword in the local scope + dictionary::searcher finder = + parentDict.searchScoped(key, false, false); + + if (finder.found()) + { + finder.context().remove(finder.ptr()->keyword()); + } + } + else + { + // Remove by pattern + const wordList dictKeys = parentDict.toc(); + const labelList indices = findStrings(regExp(key), dictKeys); + + for (const auto idx : indices) + { + parentDict.remove(dictKeys[idx]); + } + } } return true; } + // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H index 5e8fbdd8361..6cdb5441a51 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,17 +27,22 @@ Class Description Remove a dictionary entry. - The \c \#remove directive takes a list or a single wordRe. + The \c \#remove directive takes a list or a single keyType. For example, \verbatim #remove entry0 #remove ( entry1 entry2 entry3 otherEntry ) #remove "entry[1-3]" #remove ( "entry[1-3]" otherEntry ) + #remove ^dict1.subdict2.entry2 + #remove "/dict1/subdict2/entry1" \endverbatim - The removal only occurs in the current context. - Removing sub-entries or parent entries is not supported. +Note + Unless otherwise scoped, the removal occurs in the current context. + To remove from other scopes, a dot-scoped or slash-scoped syntax is + required. The slash-scoped syntax must be quoted to ensure that it + is properly parsed. SourceFiles removeEntry.C @@ -57,7 +62,7 @@ namespace functionEntries { /*---------------------------------------------------------------------------*\ - Class removeEntry Declaration + Class removeEntry Declaration \*---------------------------------------------------------------------------*/ class removeEntry @@ -66,7 +71,7 @@ class removeEntry { public: - //- Remove entries from the current sub-dict context + //- Remove single or multiple entries. Local or scoped entries. static bool execute(dictionary& parentDict, Istream& is); }; -- GitLab From 4e48beffd4add6eb60f745de95bf7e438e3157d0 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 29 Jul 2017 17:44:22 +0200 Subject: [PATCH 004/126] ENH: support "one-shot" changes to the dictionary inputMode (issue #429) - Instead of relying on #inputMode to effect a global change it is now possible (and recommended) to a temporary change in the inputMode for the following entry. #default : provide default value if entry is not already defined #overwrite : silently remove a previously existing entry #warn : warn about duplicate entries #error : error if any duplicate entries occur #merge : merge sub-dictionaries when possible (the default mode) This is generally less cumbersome than the switching the global inputMode. For example to provide a set of fallback values. #includeIfPresent "user-files" ... #default value uniform 10; vs. #includeIfPresent "user-files" #inputMode protect ... value uniform 10; #inputMode merge // _Assuming_ we actually had this before These directives can also be used to suppress the normal dictionary merge semantics: #overwrite dict { entry val; ... } --- applications/test/dictionary/testDict | 19 ++-- etc/caseDicts/foamyHexMeshDict | 2 - .../functionEntries/inputMode/inputMode.C | 95 +++++++++++++++++++ .../functionEntries/inputMode/inputMode.H | 80 ++++++++++++++++ .../system/solverControls | 2 - .../system/solverControls.0 | 2 - .../system/solverControls.20 | 2 - .../system/solverControls.5 | 2 - .../system/solverControls.60 | 2 - .../steady/0.orig/include/initialConditions | 2 - .../0.orig/include/initialConditions | 1 - .../0.orig/include/initialConditions | 1 - 12 files changed, 185 insertions(+), 25 deletions(-) diff --git a/applications/test/dictionary/testDict b/applications/test/dictionary/testDict index 736f4263056..a933c543e3f 100644 --- a/applications/test/dictionary/testDict +++ b/applications/test/dictionary/testDict @@ -13,18 +13,19 @@ FoamFile object testDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#inputMode merge + #includeIfPresent "someUnknownFile" #includeIfPresent "$FOAM_CASE/someUnknownFile" #includeIfPresent "$FOAM_CASE/someUnknownFile-$FOAM_CASENAME" internalField uniform 1; -// use 'protect' to supply defaults -#inputMode protect -internalField uniform 10; -dimensions [ 0 2 -2 0 0 0 0 ]; -#inputMode merge +// supply defaults +#default internalField uniform 10; +#default dimensions [ 1 2 -2 0 0 0 0 ]; +#overwrite dimensions [ 0 2 -2 0 0 0 0 ]; +// #warn dimensions [ 0 2 -2 0 0 0 0 ]; +// #error dimensions [ 0 2 -2 0 0 0 0 ]; active { @@ -86,12 +87,12 @@ boundaryField #remove inactive inlet_7 { ${${varType}}} // Test indirection/recursive expansion - #inputMode overwrite inlet_8 { $active } + + #overwrite inlet_8 { type none; } } -// NB: the inputMode has a global scope -#inputMode merge + #include "testDict2" foo diff --git a/etc/caseDicts/foamyHexMeshDict b/etc/caseDicts/foamyHexMeshDict index 088c1a0b987..ee8abb7e154 100644 --- a/etc/caseDicts/foamyHexMeshDict +++ b/etc/caseDicts/foamyHexMeshDict @@ -14,8 +14,6 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#inputMode merge; - surfaceConformation { pointPairDistanceCoeff 0.1; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C index bdd92de36e9..160d5ec87d8 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C @@ -41,6 +41,51 @@ namespace functionEntries dictionaryIstream, inputMode ); + + addNamedToMemberFunctionSelectionTable + ( + functionEntry, + inputModeDefault, + execute, + dictionaryIstream, + default + ); + + addNamedToMemberFunctionSelectionTable + ( + functionEntry, + inputModeMerge, + execute, + dictionaryIstream, + merge + ); + + addNamedToMemberFunctionSelectionTable + ( + functionEntry, + inputModeOverwrite, + execute, + dictionaryIstream, + overwrite + ); + + addNamedToMemberFunctionSelectionTable + ( + functionEntry, + inputModeWarn, + execute, + dictionaryIstream, + warn + ); + + addNamedToMemberFunctionSelectionTable + ( + functionEntry, + inputModeError, + execute, + dictionaryIstream, + error + ); } } @@ -90,4 +135,54 @@ bool Foam::functionEntries::inputMode::execute } +bool Foam::functionEntries::inputModeDefault::execute +( + dictionary& parentDict, + Istream& is +) +{ + return entry::New(parentDict, is, entry::inputMode::PROTECT); +} + + +bool Foam::functionEntries::inputModeMerge::execute +( + dictionary& parentDict, + Istream& is +) +{ + return entry::New(parentDict, is, entry::inputMode::MERGE); +} + + +bool Foam::functionEntries::inputModeOverwrite::execute +( + dictionary& parentDict, + Istream& is +) +{ + return entry::New(parentDict, is, entry::inputMode::OVERWRITE); +} + + +bool Foam::functionEntries::inputModeWarn::execute +( + dictionary& parentDict, + Istream& is +) +{ + return entry::New(parentDict, is, entry::inputMode::WARN); +} + + +bool Foam::functionEntries::inputModeError::execute +( + dictionary& parentDict, + Istream& is +) +{ + return entry::New(parentDict, is, entry::inputMode::ERROR); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H index c670d9230dc..91f0d6362bc 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H @@ -84,6 +84,86 @@ public: }; +/*---------------------------------------------------------------------------*\ + Class inputModeDefault Declaration +\*---------------------------------------------------------------------------*/ + +//- Temporarily change inputMode to %protect for the following entry +class inputModeDefault +: + public functionEntry +{ +public: + + //- Execute in a sub-dict context + static bool execute(dictionary& parentDict, Istream& is); +}; + + +/*---------------------------------------------------------------------------*\ + Class inputModeMerge Declaration +\*---------------------------------------------------------------------------*/ + +//- Temporarily change inputMode to %merge for the following entry +class inputModeMerge +: + public functionEntry +{ +public: + + //- Execute in a sub-dict context + static bool execute(dictionary& parentDict, Istream& is); +}; + + +/*---------------------------------------------------------------------------*\ + Class inputModeOverwrite Declaration +\*---------------------------------------------------------------------------*/ + +//- Temporarily change inputMode to %overwrite for the following entry +class inputModeOverwrite +: + public functionEntry +{ +public: + + //- Execute in a sub-dict context + static bool execute(dictionary& parentDict, Istream& is); +}; + + +/*---------------------------------------------------------------------------*\ + Class inputModeWarn Declaration +\*---------------------------------------------------------------------------*/ + +//- Temporarily change inputMode to %warn for the following entry +class inputModeWarn +: + public functionEntry +{ +public: + + //- Execute in a sub-dict context + static bool execute(dictionary& parentDict, Istream& is); +}; + + +/*---------------------------------------------------------------------------*\ + Class inputModeError Declaration +\*---------------------------------------------------------------------------*/ + +//- Temporarily change inputMode to %error for the following entry +class inputModeError +: + public functionEntry +{ +public: + + //- Execute in a sub-dict context + static bool execute(dictionary& parentDict, Istream& is); +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace functionEntries diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls index 63d17474fbe..0eae3d794b2 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls @@ -12,6 +12,4 @@ maxCo 12; maxDeltaT 1; -#inputMode merge - // ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0 index f23b6a4f10b..65697b02421 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0 +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0 @@ -12,6 +12,4 @@ maxCo 2.5; maxDeltaT 0.3; -#inputMode merge - // ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20 index c1143ac2dc3..56a2dc921ff 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20 +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20 @@ -12,6 +12,4 @@ maxCo 8; maxDeltaT 1; -#inputMode merge - // ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5 index be96ad74298..9f1c5f5932e 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5 +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5 @@ -12,6 +12,4 @@ maxCo 5; maxDeltaT 1; -#inputMode merge - // ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60 index 63d17474fbe..0eae3d794b2 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60 +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60 @@ -12,6 +12,4 @@ maxCo 12; maxDeltaT 1; -#inputMode merge - // ************************************************************************* // diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions b/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions index 8d82530aae2..30be52d9723 100644 --- a/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions +++ b/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions @@ -12,6 +12,4 @@ turbulentKE 37; turbulentOmega 32; turbulentEpsilon 30; -#inputMode merge - // ************************************************************************* // diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions index aaa6bd1c6ff..d2b995d3b55 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions @@ -10,6 +10,5 @@ flowVelocity (10 0 0); pressure 0; turbulentKE 1.5; turbulentEpsilon 0.88; -#inputMode merge // ************************************************************************* // diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions index e0b2bd996ee..14ab8e962cd 100644 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions @@ -11,6 +11,5 @@ pressure 0; turbulentKE 0.375; turbulentOmega 3.6; turbulentEpsilon 0.12; -#inputMode merge // ************************************************************************* // -- GitLab From e03ca4c4662ed6ade115944c1fcb0f268ed02c74 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 4 Aug 2017 11:09:32 +0200 Subject: [PATCH 005/126] CONFIG: add Cray compiler, cray mpich settings, wmake rules (fixes #558) - the cray C/C++ compilers appear to be option-compatible with gcc. - no wmake rules for 32bit builds (deemed to be unnecessary) --- etc/bashrc | 4 ++-- etc/config.csh/mpi | 22 ++++++++++++++++++++++ etc/config.csh/settings | 9 +++++++-- etc/config.sh/mpi | 22 ++++++++++++++++++++++ etc/config.sh/settings | 9 +++++++-- etc/cshrc | 4 ++-- wmake/rules/General/mplibCRAY-MPICH | 1 + wmake/rules/linux64Cray/c | 16 ++++++++++++++++ wmake/rules/linux64Cray/c++ | 24 ++++++++++++++++++++++++ wmake/rules/linux64Cray/c++Debug | 2 ++ wmake/rules/linux64Cray/c++Opt | 4 ++++ wmake/rules/linux64Cray/c++Prof | 2 ++ wmake/rules/linux64Cray/cDebug | 2 ++ wmake/rules/linux64Cray/cOpt | 2 ++ wmake/rules/linux64Cray/cProf | 2 ++ wmake/rules/linux64Cray/general | 9 +++++++++ wmake/rules/linux64Cray/mplibINTELMPI | 3 +++ wmake/rules/linux64Cray/openmp | 4 ++++ 18 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 wmake/rules/General/mplibCRAY-MPICH create mode 100644 wmake/rules/linux64Cray/c create mode 100644 wmake/rules/linux64Cray/c++ create mode 100644 wmake/rules/linux64Cray/c++Debug create mode 100644 wmake/rules/linux64Cray/c++Opt create mode 100644 wmake/rules/linux64Cray/c++Prof create mode 100644 wmake/rules/linux64Cray/cDebug create mode 100644 wmake/rules/linux64Cray/cOpt create mode 100644 wmake/rules/linux64Cray/cProf create mode 100644 wmake/rules/linux64Cray/general create mode 100644 wmake/rules/linux64Cray/mplibINTELMPI create mode 100644 wmake/rules/linux64Cray/openmp diff --git a/etc/bashrc b/etc/bashrc index e2e887ac646..597d5494d6c 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -65,7 +65,7 @@ export WM_COMPILER_TYPE=system #- Compiler: # WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL -# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL +# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL | Cray export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH @@ -89,7 +89,7 @@ export WM_COMPILE_OPTION=Opt #- MPI implementation: # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI -# | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI +# | MPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI export WM_MPLIB=SYSTEMOPENMPI #- Operating System: diff --git a/etc/config.csh/mpi b/etc/config.csh/mpi index e2ec875e4f2..ae9a7c15a46 100644 --- a/etc/config.csh/mpi +++ b/etc/config.csh/mpi @@ -141,6 +141,28 @@ case MPICH-GM: _foamAddLib $GM_LIB_PATH breaksw +case CRAY-MPICH: + if ( ! $?MPICH_DIR ) setenv MPICH_DIR /dev/null + setenv FOAM_MPI cray-mpich + setenv MPI_ARCH_PATH $MPICH_DIR + + if ($?FOAM_VERBOSE && $?prompt) then + echo "Using $WM_MPLIB" + echo " FOAM_MPI : $FOAM_MPI" + echo " MPICH_DIR : $MPI_ARCH_PATH" + endif + + if ( ! -d "$MPI_ARCH_PATH" ) then + echo "Warning in $WM_PROJECT_DIR/etc/config.csh/mpi:" + echo " Not a valid $WM_MPLIB installation directory." + echo " Please set MPICH_DIR properly." + echo " Currently using '$MPI_ARCH_PATH'" + endif + + # _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib + breaksw + case HPMPI: setenv FOAM_MPI hpmpi setenv MPI_HOME /opt/hpmpi diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 98442b94a1e..40c3df89855 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -214,12 +214,17 @@ if (! $?WM_COMPILER_TYPE ) setenv WM_COMPILER_TYPE system # Adjustments for non-gcc compilers switch ("$WM_COMPILER") case Clang*: - # Using clang - not gcc + # Using clang compiler suite setenv WM_CC 'clang' setenv WM_CXX 'clang++' breaksw +case Cray*: + # Using cray system compilers + setenv WM_CC 'cc' + setenv WM_CXX 'CC' + breaksw case Icc*: - # Using icc - not gcc + # Using intel compilers setenv WM_CC 'icc' setenv WM_CXX 'icpc' breaksw diff --git a/etc/config.sh/mpi b/etc/config.sh/mpi index a2d676d76b5..1a87bf238f9 100644 --- a/etc/config.sh/mpi +++ b/etc/config.sh/mpi @@ -160,6 +160,28 @@ MPICH-GM) _foamAddLib $GM_LIB_PATH ;; +CRAY-MPICH) + export FOAM_MPI=cray-mpich + export MPI_ARCH_PATH=$MPICH_DIR + + if [ "$FOAM_VERBOSE" -a "$PS1" ] + then + echo "Using $WM_MPLIB" 1>&2 + echo " FOAM_MPI : $FOAM_MPI" 1>&2 + echo " MPICH_DIR : $MPI_ARCH_PATH" 1>&2 + fi + + [ -d "$MPI_ARCH_PATH" ] || { + echo "Warning in $WM_PROJECT_DIR/etc/config.sh/mpi:" 1>&2 + echo " Not a valid $WM_MPLIB installation directory." 1>&2 + echo " Please set MPICH_DIR properly" 1>&2 + echo " Currently using '$MPI_ARCH_PATH'" 1>&2 + } + + # _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib + ;; + HPMPI) export FOAM_MPI=hpmpi export MPI_HOME=/opt/hpmpi diff --git a/etc/config.sh/settings b/etc/config.sh/settings index ebc4bf435a7..20821fae2e3 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -216,12 +216,17 @@ _foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN # Adjust for non-gcc compilers case "$WM_COMPILER" in Clang*) - # Using clang - not gcc + # Using clang compiler suite export WM_CC='clang' export WM_CXX='clang++' ;; +Cray*) + # Using cray system compilers + export WM_CC='cc' + export WM_CXX='CC' + ;; Icc*) - # Using icc - not gcc + # Using intel compilers export WM_CC='icc' export WM_CXX='icpc' ;; diff --git a/etc/cshrc b/etc/cshrc index 7b8da52c26d..7cefb2f3830 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -61,7 +61,7 @@ setenv WM_COMPILER_TYPE system #- Compiler: # WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL -# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL +# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL | Cray setenv WM_COMPILER Gcc setenv WM_COMPILER_ARCH # defined but empty unsetenv WM_COMPILER_LIB_ARCH @@ -86,7 +86,7 @@ setenv WM_COMPILE_OPTION Opt #- MPI implementation: # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI -# | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI +# | MPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI setenv WM_MPLIB SYSTEMOPENMPI #- Operating System: diff --git a/wmake/rules/General/mplibCRAY-MPICH b/wmake/rules/General/mplibCRAY-MPICH new file mode 100644 index 00000000000..fdb91c13794 --- /dev/null +++ b/wmake/rules/General/mplibCRAY-MPICH @@ -0,0 +1 @@ +include $(GENERAL_RULES)/mplibMPICH diff --git a/wmake/rules/linux64Cray/c b/wmake/rules/linux64Cray/c new file mode 100644 index 00000000000..d08f4414403 --- /dev/null +++ b/wmake/rules/linux64Cray/c @@ -0,0 +1,16 @@ +SUFFIXES += .c + +cWARN = -Wall + +cc = cc -m64 + +include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION) + +cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC + +ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ + +LINK_LIBS = $(cDBUG) + +LINKLIBSO = $(cc) -shared +LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linux64Cray/c++ b/wmake/rules/linux64Cray/c++ new file mode 100644 index 00000000000..30c2bc762e2 --- /dev/null +++ b/wmake/rules/linux64Cray/c++ @@ -0,0 +1,24 @@ +SUFFIXES += .C + +c++WARN = -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof + +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + +CC = CC -std=c++11 -m64 + +include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION) + +ptFLAGS = -DNoRepository -ftemplate-depth-100 + +c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC + +Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@ +cxxtoo = $(Ctoo) +cctoo = $(Ctoo) +cpptoo = $(Ctoo) + +LINK_LIBS = $(c++DBUG) + +LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linux64Cray/c++Debug b/wmake/rules/linux64Cray/c++Debug new file mode 100644 index 00000000000..19bdb9c3346 --- /dev/null +++ b/wmake/rules/linux64Cray/c++Debug @@ -0,0 +1,2 @@ +c++DBUG = -ggdb3 -DFULLDEBUG +c++OPT = -O0 -fdefault-inline diff --git a/wmake/rules/linux64Cray/c++Opt b/wmake/rules/linux64Cray/c++Opt new file mode 100644 index 00000000000..599e6aba611 --- /dev/null +++ b/wmake/rules/linux64Cray/c++Opt @@ -0,0 +1,4 @@ +c++DBUG = +c++OPT = -O3 + +ROUNDING_MATH = -frounding-math diff --git a/wmake/rules/linux64Cray/c++Prof b/wmake/rules/linux64Cray/c++Prof new file mode 100644 index 00000000000..3bda4dad55e --- /dev/null +++ b/wmake/rules/linux64Cray/c++Prof @@ -0,0 +1,2 @@ +c++DBUG = -pg +c++OPT = -O2 diff --git a/wmake/rules/linux64Cray/cDebug b/wmake/rules/linux64Cray/cDebug new file mode 100644 index 00000000000..72b638f4582 --- /dev/null +++ b/wmake/rules/linux64Cray/cDebug @@ -0,0 +1,2 @@ +cDBUG = -ggdb -DFULLDEBUG +cOPT = -O1 -fdefault-inline -finline-functions diff --git a/wmake/rules/linux64Cray/cOpt b/wmake/rules/linux64Cray/cOpt new file mode 100644 index 00000000000..17318709f1f --- /dev/null +++ b/wmake/rules/linux64Cray/cOpt @@ -0,0 +1,2 @@ +cDBUG = +cOPT = -O3 diff --git a/wmake/rules/linux64Cray/cProf b/wmake/rules/linux64Cray/cProf new file mode 100644 index 00000000000..ca3ac9bf5f0 --- /dev/null +++ b/wmake/rules/linux64Cray/cProf @@ -0,0 +1,2 @@ +cDBUG = -pg +cOPT = -O2 diff --git a/wmake/rules/linux64Cray/general b/wmake/rules/linux64Cray/general new file mode 100644 index 00000000000..a0c807e5d8a --- /dev/null +++ b/wmake/rules/linux64Cray/general @@ -0,0 +1,9 @@ +CPP = cpp -traditional-cpp $(GFLAGS) + +PROJECT_LIBS = -l$(WM_PROJECT) -ldl + +include $(GENERAL_RULES)/standard + +# include $(DEFAULT_RULES)/openmp +include $(DEFAULT_RULES)/c +include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Cray/mplibINTELMPI b/wmake/rules/linux64Cray/mplibINTELMPI new file mode 100644 index 00000000000..278e0b0f22c --- /dev/null +++ b/wmake/rules/linux64Cray/mplibINTELMPI @@ -0,0 +1,3 @@ +PFLAGS = -DMPICH_SKIP_MPICXX +PINC = -isystem $(MPI_ARCH_PATH)/include64 +PLIBS = -L$(MPI_ARCH_PATH)/lib64 -lmpi diff --git a/wmake/rules/linux64Cray/openmp b/wmake/rules/linux64Cray/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linux64Cray/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp -- GitLab From 8b63772882abaff3b4c00eb06e05c775db5871d6 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 9 Aug 2017 13:45:30 +0200 Subject: [PATCH 006/126] ENH: simplify parsing logic in ISstream --- src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C | 211 +++++++++--------- src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H | 7 +- .../db/IOstreams/Sstreams/prefixOSstream.C | 2 +- 3 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C index 15ad568f18f..010eef975bc 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,12 @@ License #include "token.H" #include <cctype> +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +// Truncate error message for readability +static const unsigned errLen = 80; + + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // char Foam::ISstream::nextValid() @@ -43,7 +49,7 @@ char Foam::ISstream::nextValid() // Return if stream is bad - ie, previous get() failed if (bad() || isspace(c)) { - break; + return 0; } // Is this the start of a C/C++ comment? @@ -51,7 +57,7 @@ char Foam::ISstream::nextValid() { if (!get(c)) { - // cannot get another character - return this one + // Cannot get another character - return this one return '/'; } @@ -63,10 +69,10 @@ char Foam::ISstream::nextValid() } else if (c == '*') { - // within a C-style comment + // Within a C-style comment while (true) { - // search for end of C-style comment - '*/' + // Search for end of C-style comment - '*/' if (get(c) && c == '*') { if (get(c)) @@ -99,7 +105,7 @@ char Foam::ISstream::nextValid() } else { - // a valid character - return it + // A valid character - return it return c; } } @@ -124,14 +130,14 @@ void Foam::ISstream::readWordToken(token& t) } else { - t = wPtr; + t = wPtr; // Token takes ownership } } Foam::Istream& Foam::ISstream::read(token& t) { - static const int maxLen = 128; + static const unsigned maxLen = 128; // When parsing labels or scalars static char buf[maxLen]; // Return the put back token if it exists @@ -151,7 +157,7 @@ Foam::Istream& Foam::ISstream::read(token& t) // Set the line number of this token to the current stream line number t.lineNumber() = lineNumber(); - // return on error + // Return on error if (!c) { t.setBad(); @@ -182,7 +188,6 @@ Foam::Istream& Foam::ISstream::read(token& t) return *this; } - // String: enclosed by double quotes. case token::BEGIN_STRING : { @@ -196,24 +201,24 @@ Foam::Istream& Foam::ISstream::read(token& t) } else { - t = sPtr; + t = sPtr; // Token takes ownership } return *this; } + // Possible verbatim string or dictionary functionEntry case token::HASH : { char nextC; if (read(nextC).bad()) { - // Return hash as word + // Return lone '#' as word t = token(word(c)); - return *this; } else if (nextC == token::BEGIN_BLOCK) { - // Verbatim string + // Verbatim string: #{ ... #} string* sPtr = new string; if (readVerbatim(*sPtr).bad()) @@ -223,36 +228,34 @@ Foam::Istream& Foam::ISstream::read(token& t) } else { - t = sPtr; + t = sPtr; // Token takes ownership t.type() = token::tokenType::VERBATIMSTRING; } - - return *this; } else { - // Word beginning with # + // Word beginning with '#'. Eg, "#include" putback(nextC); putback(c); readWordToken(t); - - return *this; } + + return *this; } + // Dictionary variable (as rvalue) case '$': { - // Look ahead char nextC; if (read(nextC).bad()) { - // Return $ as word + // Return lone '$' as word t = token(word(c)); - return *this; } else if (nextC == token::BEGIN_BLOCK) { + // Put back so that "${" is included in the variable putback(nextC); putback(c); @@ -265,18 +268,20 @@ Foam::Istream& Foam::ISstream::read(token& t) } else { - t = sPtr; + t = sPtr; // Token takes ownership t.type() = token::tokenType::VARIABLE; } - return *this; } else { + // Word/variable beginning with '$', but without "{}" + putback(nextC); putback(c); readWordToken(t); - return *this; } + + return *this; } // Number: integer or floating point @@ -292,7 +297,7 @@ Foam::Istream& Foam::ISstream::read(token& t) { bool asLabel = (c != '.'); - int nChar = 0; + unsigned nChar = 0; buf[nChar++] = c; // get everything that could resemble a number and let @@ -343,43 +348,26 @@ Foam::Istream& Foam::ISstream::read(token& t) if (nChar == 1 && buf[0] == '-') { - // a single '-' is punctuation + // A single '-' is punctuation t = token::punctuationToken(token::SUBTRACT); } else { - if (asLabel) + label labelVal; + scalar scalarVal; + + if (asLabel && Foam::read(buf, labelVal)) { - label labelVal = 0; - if (Foam::read(buf, labelVal)) - { - t = labelVal; - } - else - { - // Maybe too big? Try as scalar - scalar scalarVal; - if (readScalar(buf, scalarVal)) - { - t = scalarVal; - } - else - { - t.setBad(); - } - } + t = labelVal; + } + else if (readScalar(buf, scalarVal)) + { + // A scalar or too big to fit as a label + t = scalarVal; } else { - scalar scalarVal; - if (readScalar(buf, scalarVal)) - { - t = scalarVal; - } - else - { - t.setBad(); - } + t.setBad(); } } } @@ -409,28 +397,28 @@ Foam::Istream& Foam::ISstream::read(char& c) Foam::Istream& Foam::ISstream::read(word& str) { - static const int maxLen = 1024; - static const int errLen = 80; // truncate error message for readability + static const unsigned maxLen = 1024; static char buf[maxLen]; - int nChar = 0; - int listDepth = 0; + unsigned nChar = 0; + unsigned depth = 0; // Track depth of "()" nesting char c; while (get(c) && word::valid(c)) { if (c == token::BEGIN_LIST) { - listDepth++; + ++depth; } else if (c == token::END_LIST) { - if (listDepth) + if (depth) { - listDepth--; + --depth; } else { + // Had ')' without a previous '(' ... stop break; } } @@ -449,10 +437,13 @@ Foam::Istream& Foam::ISstream::read(word& str) } } - // we could probably skip this check + // Terminate string with nul char + buf[nChar] = '\0'; + + // We could probably skip this check if (bad()) { - buf[errLen] = buf[nChar] = '\0'; + buf[errLen] = '\0'; FatalIOErrorInFunction(*this) << "problem while reading word '" << buf << "...' after " @@ -468,9 +459,14 @@ Foam::Istream& Foam::ISstream::read(word& str) << "invalid first character found : " << c << exit(FatalIOError); } + else if (depth) + { + IOWarningInFunction(*this) + << "Missing " << depth << " closing ')' while parsing" << nl << nl + << buf << nl << endl; + } - // done reading - buf[nChar] = '\0'; + // Finalize str = buf; putback(c); @@ -480,8 +476,7 @@ Foam::Istream& Foam::ISstream::read(word& str) Foam::Istream& Foam::ISstream::read(string& str) { - static const int maxLen = 1024; - static const int errLen = 80; // truncate error message for readability + static const unsigned maxLen = 1024; static char buf[maxLen]; char c; @@ -505,7 +500,7 @@ Foam::Istream& Foam::ISstream::read(string& str) return *this; } - int nChar = 0; + unsigned nChar = 0; bool escaped = false; while (get(c)) @@ -515,11 +510,11 @@ Foam::Istream& Foam::ISstream::read(string& str) if (escaped) { escaped = false; - nChar--; // overwrite backslash + --nChar; // Overwrite backslash } else { - // done reading + // Done reading buf[nChar] = '\0'; str = buf; return *this; @@ -530,7 +525,7 @@ Foam::Istream& Foam::ISstream::read(string& str) if (escaped) { escaped = false; - nChar--; // overwrite backslash + --nChar; // Overwrite backslash } else { @@ -581,12 +576,11 @@ Foam::Istream& Foam::ISstream::read(string& str) Foam::Istream& Foam::ISstream::readVariable(string& str) { - static const int maxLen = 1024; - static const int errLen = 80; // truncate error message for readability + static const unsigned maxLen = 1024; static char buf[maxLen]; - int nChar = 0; - int blockCount = 0; + unsigned nChar = 0; + unsigned depth = 0; // Track depth of "{}" nesting char c; if (!get(c) || c != '$') @@ -601,8 +595,8 @@ Foam::Istream& Foam::ISstream::readVariable(string& str) // Read next character to see if '{' if (get(c) && c == token::BEGIN_BLOCK) { - // Read, counting brackets buf[nChar++] = c; + ++depth; // Starts with '{' // Also allow '/' between ${...} blocks for slash-scoping of entries while @@ -615,34 +609,35 @@ Foam::Istream& Foam::ISstream::readVariable(string& str) ) ) { - buf[nChar++] = c; - if (nChar == maxLen) - { - buf[errLen] = '\0'; - - FatalIOErrorInFunction(*this) - << "variable '" << buf << "...'\n" - << " is too long (max. " << maxLen << " characters)" - << exit(FatalIOError); - - return *this; - } - if (c == token::BEGIN_BLOCK) { - blockCount++; + ++depth; } else if (c == token::END_BLOCK) { - if (blockCount) + if (depth) { - blockCount--; + --depth; } else { + // Had '}' without a previous '{' ... stop break; } } + + buf[nChar++] = c; + if (nChar == maxLen) + { + buf[errLen] = '\0'; + + FatalIOErrorInFunction(*this) + << "variable '" << buf << "...'\n" + << " is too long (max. " << maxLen << " characters)" + << exit(FatalIOError); + + return *this; + } } } else @@ -666,10 +661,13 @@ Foam::Istream& Foam::ISstream::readVariable(string& str) } } + // Terminate string with nul char + buf[nChar] = '\0'; + // we could probably skip this check if (bad()) { - buf[errLen] = buf[nChar] = '\0'; + buf[errLen] = '\0'; FatalIOErrorInFunction(*this) << "problem while reading string '" << buf << "...' after " @@ -685,31 +683,29 @@ Foam::Istream& Foam::ISstream::readVariable(string& str) << "invalid first character found : " << c << exit(FatalIOError); } - - // done reading - buf[nChar] = '\0'; - str = buf; - - // Note: check if we exited due to '}' or just !word::valid. - if (c != token::END_BLOCK) + else if (depth) { - putback(c); + IOWarningInFunction(*this) + << "Missing " << depth << " closing '}' while parsing" << nl << nl + << buf << nl << endl; } + // Finalize + str = buf; + putback(c); + return *this; } Foam::Istream& Foam::ISstream::readVerbatim(string& str) { - static const int maxLen = 8000; - static const int errLen = 80; // truncate error message for readability + static const unsigned maxLen = 8000; static char buf[maxLen]; + unsigned nChar = 0; char c; - int nChar = 0; - while (get(c)) { if (c == token::HASH) @@ -718,6 +714,7 @@ Foam::Istream& Foam::ISstream::readVerbatim(string& str) get(nextC); if (nextC == token::END_BLOCK) { + // The closing "#}" found buf[nChar] = '\0'; str = buf; return *this; diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H index 4a2b510b5b1..e446272f857 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,9 +69,12 @@ class ISstream //- Read a verbatim string (excluding block delimiters). + // The leading "#{" has been removed prior to calling, + // continues until the closing "#}" has been found. Istream& readVerbatim(string& str); - //- Read a variable name (includes '{') + //- Read a variable name starting with '$'. + // Handles both "$var" and "${var}" forms. Istream& readVariable(string& str); //- Disallow default bitwise assignment diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C index cb28408f7de..42a2df76c97 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C @@ -102,7 +102,7 @@ Foam::Ostream& Foam::prefixOSstream::write(const char* str) checkWritePrefix(); OSstream::write(str); - size_t len = strlen(str); + const size_t len = strlen(str); if (len && str[len-1] == token::NL) { printPrefix_ = true; -- GitLab From 79f2466ca525bfbd037c2ae7d30167a465e20272 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Mon, 18 Sep 2017 10:17:24 +0100 Subject: [PATCH 007/126] BUG: DESModelRegions - added missing field write() - see #591 --- src/functionObjects/field/DESModelRegions/DESModelRegions.C | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/functionObjects/field/DESModelRegions/DESModelRegions.C b/src/functionObjects/field/DESModelRegions/DESModelRegions.C index bb94a127677..ba308764315 100644 --- a/src/functionObjects/field/DESModelRegions/DESModelRegions.C +++ b/src/functionObjects/field/DESModelRegions/DESModelRegions.C @@ -172,6 +172,8 @@ bool Foam::functionObjects::DESModelRegions::write() << " writing field " << DESModelRegions.name() << nl << endl; + DESModelRegions.write(); + return true; } -- GitLab From 94cf702f6976527eef8a3923bd8f0359dec13606 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Mon, 18 Sep 2017 10:48:39 +0100 Subject: [PATCH 008/126] BUG: kOmegaSSTLM - corrected writing of coefficients. Fixes #592 --- .../turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C index 5d14d97bf9c..371b0a51f1e 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C @@ -373,7 +373,8 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM alphaRhoPhi, phi, transport, - propertiesName + propertiesName, + typeName ), ca1_ @@ -477,7 +478,12 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM this->mesh_, dimensionedScalar("0", dimless, 0) ) -{} +{ + if (type == typeName) + { + this->printCoeffs(type); + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -- GitLab From 68e7533847dde7514df4cd8dcb444ec32dc380d6 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 20 Sep 2017 17:01:56 +0200 Subject: [PATCH 009/126] STYLE: include <utility> in stdFoam, formatting of list loop macros --- .../containers/Lists/FixedList/FixedList.C | 6 +- src/OpenFOAM/containers/Lists/List/List.C | 18 ++++-- .../containers/Lists/List/ListLoopM.H | 12 +--- src/OpenFOAM/containers/Lists/UList/UList.C | 12 ++-- src/OpenFOAM/fields/Fields/Field/FieldM.H | 58 ++++++++++++------- src/OpenFOAM/include/stdFoam.H | 24 ++++---- 6 files changed, 78 insertions(+), 52 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C index 03c3d167681..19163402da0 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C @@ -35,10 +35,11 @@ void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& a) List_ACCESS(T, a, ap); T tmp; List_FOR_ALL((*this), i) + { tmp = List_CELEM((*this), vp, i); List_ELEM((*this), vp, i) = List_CELEM(a, ap, i); List_ELEM(a, ap, i) = tmp; - List_END_FOR_ALL + } } @@ -53,9 +54,10 @@ bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& a) const List_CONST_ACCESS(T, (a), ap); List_FOR_ALL((*this), i) + { equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i)); if (!equal) break; - List_END_FOR_ALL + } return equal; } diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index ab8aea673f8..04f731f2119 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -69,8 +69,9 @@ Foam::List<T>::List(const label s, const T& a) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = a; - List_END_FOR_ALL + } } } @@ -93,8 +94,9 @@ Foam::List<T>::List(const label s, const zero) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = Zero; - List_END_FOR_ALL + } } } @@ -119,8 +121,9 @@ Foam::List<T>::List(const List<T>& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } @@ -139,8 +142,9 @@ Foam::List<T>::List(const List<T2>& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T2, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = T(List_ELEM(a, ap, i)); - List_END_FOR_ALL + } } } @@ -178,8 +182,9 @@ Foam::List<T>::List(List<T>& a, bool reuse) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } @@ -390,8 +395,9 @@ void Foam::List<T>::operator=(const UList<T>& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } diff --git a/src/OpenFOAM/containers/Lists/List/ListLoopM.H b/src/OpenFOAM/containers/Lists/List/ListLoopM.H index 032edb3052e..5f74321bc66 100644 --- a/src/OpenFOAM/containers/Lists/List/ListLoopM.H +++ b/src/OpenFOAM/containers/Lists/List/ListLoopM.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,10 +37,7 @@ Description #define List_FOR_ALL(f, i) \ const label _n##i = (f).size(); \ - for (label i=0; i<_n##i; ++i) \ - { - -#define List_END_FOR_ALL } + for (label i=0; i<_n##i; ++i) // Provide current element #define List_CELEM(f, fp, i) (fp[i]) @@ -60,10 +57,7 @@ Description #define List_FOR_ALL(f, i) \ label i = (f).size(); \ - while (i--) \ - { \ - -#define List_END_FOR_ALL } + while (i--) // Provide current element without incrementing pointer #define List_CELEM(f, fp, i) (*fp) diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index f4796987442..599dd0f9980 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -95,8 +95,9 @@ void Foam::UList<T>::deepCopy(const UList<T>& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } @@ -152,8 +153,9 @@ void Foam::UList<T>::operator=(const T& t) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = t; - List_END_FOR_ALL + } } @@ -162,8 +164,9 @@ void Foam::UList<T>::operator=(const zero) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = Zero; - List_END_FOR_ALL + } } @@ -244,9 +247,10 @@ bool Foam::UList<T>::operator==(const UList<T>& a) const List_CONST_ACCESS(T, (a), ap); List_FOR_ALL((*this), i) + { equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i)); if (!equal) break; - List_END_FOR_ALL + } return equal; } diff --git a/src/OpenFOAM/fields/Fields/Field/FieldM.H b/src/OpenFOAM/fields/Fields/Field/FieldM.H index 28d4788c176..46be4b350da 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldM.H +++ b/src/OpenFOAM/fields/Fields/Field/FieldM.H @@ -120,8 +120,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i)); \ - List_END_FOR_ALL \ + } #define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC) \ @@ -135,13 +136,14 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i).FUNC(); \ - List_END_FOR_ALL \ + } // member function : this field f1 OP fUNC f2, f3 -#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)\ +#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3) \ \ /* check the three fields have same Field<Type> mesh */ \ checkFields(f1, f2, f3, "f1 " #OP " " #FUNC "(f2, f3)"); \ @@ -153,9 +155,10 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) \ OP FUNC(List_ELEM(f2, f2P, i), List_ELEM(f3, f3P, i)); \ - List_END_FOR_ALL \ + } // member function : this field f1 OP fUNC f2, f3 @@ -171,8 +174,9 @@ void checkFields \ /* loop through fields performing s OP FUNC(f1, f2) */ \ List_FOR_ALL(f1, i) \ + { \ (s) OP FUNC(List_ELEM(f1, f1P, i), List_ELEM(f2, f2P, i)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP fUNC f2, s @@ -188,8 +192,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i), (s)); \ - List_END_FOR_ALL + } // member function : s1 OP fUNC f, s2 @@ -201,8 +206,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f, i) \ + { \ (s1) OP FUNC(List_ELEM(f, fP, i), (s2)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP fUNC s, f2 @@ -218,21 +224,23 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC((s), List_ELEM(f2, f2P, i)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP fUNC s, f2 -#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2)\ +#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2) \ \ /* set access to f1 at end of field */ \ List_ACCESS(typeF1, f1, f1P); \ \ /* loop through fields performing f1 OP1 FUNC(s1, s2) */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC((s1), (s2)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP1 f2 OP2 FUNC s @@ -248,8 +256,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i) FUNC((s)); \ - List_END_FOR_ALL \ + } // define high performance macro functions for Field<Type> operations @@ -268,9 +277,10 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) \ OP2 List_ELEM(f3, f3P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP1 s OP2 f2 @@ -286,8 +296,9 @@ void checkFields \ /* loop through fields performing f1 OP1 s OP2 f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 (s) OP2 List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP1 f2 OP2 s @@ -303,8 +314,9 @@ void checkFields \ /* loop through fields performing f1 OP1 s OP2 f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) OP2 (s); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP f2 @@ -321,8 +333,9 @@ void checkFields \ /* loop through fields performing f1 OP f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP1 OP2 f2 @@ -338,8 +351,9 @@ void checkFields \ /* loop through fields performing f1 OP1 OP2 f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 OP2 List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f OP s @@ -351,8 +365,9 @@ void checkFields \ /* loop through field performing f OP s */ \ List_FOR_ALL(f, i) \ + { \ List_ELEM(f, fP, i) OP (s); \ - List_END_FOR_ALL \ + } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -367,8 +382,9 @@ void checkFields \ /* loop through field performing s OP f */ \ List_FOR_ALL(f, i) \ + { \ (s) OP List_ELEM(f, fP, i); \ - List_END_FOR_ALL + } // friend operator function : s OP1 f1 OP2 f2, allocates storage for s @@ -381,8 +397,9 @@ void checkFields \ /* loop through field performing s OP f */ \ List_FOR_ALL(f1, i) \ + { \ (s) OP1 List_ELEM(f1, f1P, i) OP2 List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL + } // friend operator function : s OP FUNC(f), allocates storage for s @@ -394,8 +411,9 @@ void checkFields \ /* loop through field performing s OP f */ \ List_FOR_ALL(f, i) \ + { \ (s) OP FUNC(List_ELEM(f, fP, i)); \ - List_END_FOR_ALL + } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/include/stdFoam.H b/src/OpenFOAM/include/stdFoam.H index 59b0d9f704a..3141c383512 100644 --- a/src/OpenFOAM/include/stdFoam.H +++ b/src/OpenFOAM/include/stdFoam.H @@ -25,12 +25,13 @@ Namespace stdFoam Description - Includes some global templates and macros used by OpenFOAM. + Some global templates and macros used by OpenFOAM and some standard + C++ headers. - Some of the templates are defined here correspond to useful + Some of the templates defined here correspond to useful std templates that are part of future C++ standards, or that are in a state of change. Defining them here provides some additional - control over which definition are used within the OpenFOAM code-base. + control over which definitions are used within the OpenFOAM code-base. SeeAlso - http://en.cppreference.com/w/cpp/iterator/end @@ -42,6 +43,7 @@ SeeAlso #define StdFoam_H #include <initializer_list> +#include <utility> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -114,12 +116,12 @@ constexpr auto cend(const C& c) -> decltype(c.end()) // } // \endcode // \sa forAllConstIters, forAllIter, forAllConstIters -#define forAllIters(container,it) \ +#define forAllIters(container,iter) \ for \ ( \ - auto it = stdFoam::begin(container); \ - it != stdFoam::end(container); \ - ++it \ + auto iter = stdFoam::begin(container); \ + iter != stdFoam::end(container); \ + ++iter \ ) @@ -132,12 +134,12 @@ constexpr auto cend(const C& c) -> decltype(c.end()) // } // \endcode // \sa forAllIters, forAllIter, forAllConstIter -#define forAllConstIters(container,cit) \ +#define forAllConstIters(container,iter) \ for \ ( \ - auto cit = stdFoam::cbegin(container); \ - cit != stdFoam::cend(container); \ - ++cit \ + auto iter = stdFoam::cbegin(container); \ + iter != stdFoam::cend(container); \ + ++iter \ ) -- GitLab From 049617d037d963533d554a1efc9e110f70e05589 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 20 Sep 2017 17:20:54 +0200 Subject: [PATCH 010/126] ENH: update List and DynamicList methods (issue #595) - improve functional compatibility with DynList (remove methods) * eg, remove an element from any position in a DynamicList * reduce the number of template parameters * remove/subset regions of DynamicList - propagate Swap template specializations for lists, hashtables - move construct/assignment to various containers. - add find/found methods for FixedList and UList for a more succinct (and clearer?) usage than the equivalent global findIndex() function. - simplify List_FOR_ALL loops --- .../test/DynamicList/Test-DynamicList.C | 109 ++- applications/test/Field/Make/files | 3 - applications/test/Field/Make/options | 2 - applications/test/Field/Test-Field.C | 11 - applications/test/Field/Test-Field.H | 58 -- applications/test/FixedList/Test-FixedList.C | 59 +- applications/test/FixedList/fixedListFile | Bin 30 -> 0 bytes applications/test/FixedList2/Make/files | 3 + applications/test/FixedList2/Make/options | 0 .../test/FixedList2/Test-FixedList2.C | 190 ++++++ applications/test/Function1/Test-Function1.C | 7 +- applications/test/HashSet/Test-hashSet.C | 25 + applications/test/HashTable/Test-hashTable.C | 28 + .../test/IndirectList/Test-IndirectList.C | 56 +- applications/test/List/Test-List.C | 24 +- applications/test/List2/Make/files | 3 + applications/test/List2/Make/options | 0 applications/test/List2/Test-List2.C | 269 ++++++++ applications/test/ListOps2/Make/files | 2 + applications/test/ListOps2/Make/options | 3 + applications/test/ListOps2/Test-ListOps2.C | 144 ++++ applications/test/Map/Test-Map.C | 58 +- .../test/UIndirectList/Test-UIndirectList.C | 87 ++- applications/test/sort/Test-sortList.C | 167 +++-- .../ideasUnvToFoam/ideasUnvToFoam.C | 3 +- .../containers/HashTables/HashSet/HashSet.C | 11 +- .../containers/HashTables/HashSet/HashSet.H | 35 +- .../HashTables/HashTable/HashTable.C | 39 ++ .../HashTables/HashTable/HashTable.H | 20 + .../HashTables/HashTable/HashTableI.H | 13 + src/OpenFOAM/containers/HashTables/Map/Map.H | 31 +- .../Lists/BiIndirectList/BiIndirectList.H | 20 +- .../Lists/BiIndirectList/BiIndirectListI.H | 38 +- .../Lists/DynamicList/DynamicList.C | 76 ++- .../Lists/DynamicList/DynamicList.H | 231 +++++-- .../Lists/DynamicList/DynamicListI.H | 639 +++++++++++++----- .../containers/Lists/FixedList/FixedList.C | 94 ++- .../containers/Lists/FixedList/FixedList.H | 91 ++- .../containers/Lists/FixedList/FixedListI.H | 115 +++- .../Lists/IndirectList/IndirectList.H | 58 +- .../Lists/IndirectList/IndirectListI.H | 1 - src/OpenFOAM/containers/Lists/List/List.C | 168 +++-- src/OpenFOAM/containers/Lists/List/List.H | 59 +- src/OpenFOAM/containers/Lists/List/ListI.H | 14 +- .../containers/Lists/List/ListLoopM.H | 49 +- .../Lists/ListOps/ListOpsTemplates.C | 2 +- .../Lists/SortableList/SortableList.C | 105 ++- .../Lists/SortableList/SortableList.H | 48 +- .../Lists/UIndirectList/UIndirectList.C | 87 +++ .../Lists/UIndirectList/UIndirectList.H | 81 ++- .../Lists/UIndirectList/UIndirectListI.H | 11 + .../Lists/UIndirectList/UIndirectListIO.C | 4 +- src/OpenFOAM/containers/Lists/UList/UList.C | 135 +++- src/OpenFOAM/containers/Lists/UList/UList.H | 75 +- src/OpenFOAM/containers/Lists/UList/UListI.H | 59 +- .../fields/Fields/DynamicField/DynamicField.C | 24 +- .../fields/Fields/DynamicField/DynamicField.H | 56 +- .../Fields/DynamicField/DynamicFieldI.H | 282 ++++---- src/OpenFOAM/fields/Fields/Field/FieldM.H | 179 +++-- src/OpenFOAM/meshes/meshShapes/face/face.H | 7 +- src/OpenFOAM/meshes/meshShapes/face/faceI.H | 4 +- .../meshes/meshShapes/face/faceTemplates.C | 4 +- .../meshes/polyMesh/polyMeshFromShapeMesh.C | 6 +- .../primitiveMesh/primitiveMeshCellEdges.C | 6 +- src/OpenFOAM/primitives/Swap/Swap.H | 44 +- .../enrichedPatch/enrichedPatchPointPoints.C | 6 +- .../searchableBox/searchableBox.C | 2 +- .../searchableRotatedBox.C | 2 +- .../triSurfaceMesh/triSurfaceMesh.H | 2 +- .../triSurfaceSearch/triSurfaceSearch.C | 4 +- .../triSurfaceSearch/triSurfaceSearch.H | 2 +- wmake/rules/linux64GccKNL/c | 2 +- wmake/rules/linux64GccKNL/c++ | 2 +- wmake/rules/linux64IccKNL/c++ | 2 +- 74 files changed, 3196 insertions(+), 1160 deletions(-) delete mode 100644 applications/test/Field/Make/files delete mode 100644 applications/test/Field/Make/options delete mode 100644 applications/test/Field/Test-Field.C delete mode 100644 applications/test/Field/Test-Field.H delete mode 100644 applications/test/FixedList/fixedListFile create mode 100644 applications/test/FixedList2/Make/files create mode 100644 applications/test/FixedList2/Make/options create mode 100644 applications/test/FixedList2/Test-FixedList2.C create mode 100644 applications/test/List2/Make/files create mode 100644 applications/test/List2/Make/options create mode 100644 applications/test/List2/Test-List2.C create mode 100644 applications/test/ListOps2/Make/files create mode 100644 applications/test/ListOps2/Make/options create mode 100644 applications/test/ListOps2/Test-ListOps2.C create mode 100644 src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C diff --git a/applications/test/DynamicList/Test-DynamicList.C b/applications/test/DynamicList/Test-DynamicList.C index c8e2ed4a93b..ca3f4fc7872 100644 --- a/applications/test/DynamicList/Test-DynamicList.C +++ b/applications/test/DynamicList/Test-DynamicList.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +27,10 @@ Description #include "DynamicList.H" #include "IOstreams.H" +#include "FlatOutput.H" #include "ListOps.H" +#include "labelRange.H" +#include "labelIndList.H" using namespace Foam; @@ -44,15 +47,15 @@ void printInfo { Info<< " size=\"" << lst.size() << "\""; } - Info<< ">" << lst << "</" << tag << ">" << endl; + Info<< ">" << nl << flatOutput(lst) << nl << "</" << tag << ">" << endl; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> void printInfo ( const word& tag, - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst, + const DynamicList<T, SizeMin>& lst, const bool showSize = false ) { @@ -62,7 +65,7 @@ void printInfo Info<< " size=\"" << lst.size() << "\" capacity=\"" << lst.capacity() << "\""; } - Info<< ">" << lst << "</" << tag << ">" << endl; + Info<< ">" << nl << flatOutput(lst) << nl << "</" << tag << ">" << endl; } @@ -71,7 +74,7 @@ void printInfo int main(int argc, char *argv[]) { - List<DynamicList<label, 1, 0>> ldl(2); + List<DynamicList<label>> ldl(2); ldl[0](0) = 0; ldl[0](2) = 2; @@ -89,7 +92,7 @@ int main(int argc, char *argv[]) ldl[1] = 3; - Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: "; + Info<< "<ldl>" << flatOutput(ldl) << "</ldl>" << nl << "sizes: "; forAll(ldl, i) { Info<< " " << ldl[i].size() << "/" << ldl[i].capacity(); @@ -100,7 +103,7 @@ int main(int argc, char *argv[]) ll[0].transfer(ldl[0]); ll[1].transfer(ldl[1].shrink()); - Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: "; + Info<< "<ldl>" << flatOutput(ldl) << "</ldl>" << nl << "sizes: "; forAll(ldl, i) { Info<< " " << ldl[i].size() << "/" << ldl[i].capacity(); @@ -111,18 +114,18 @@ int main(int argc, char *argv[]) // test the transfer between DynamicLists - DynamicList<label, 1, 0> dlA + DynamicList<label> dlA { 0, 1, 2, 3, 4 }; dlA.append({ 5, 6 }); dlA = { 1, 2, 4 }; - DynamicList<label, 1, 0> dlB; + DynamicList<label> dlB; dlA.setCapacity(10); - Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: " + Info<< "<dlA>" << flatOutput(dlA) << "</dlA>" << nl << "sizes: " << " " << dlA.size() << "/" << dlA.capacity() << endl; dlB.transfer(dlA); @@ -132,9 +135,9 @@ int main(int argc, char *argv[]) dlB[6] = 6; Info<< "Transferred to dlB" << endl; - Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: " + Info<< "<dlA>" << flatOutput(dlA) << "</dlA>" << nl << "sizes: " << " " << dlA.size() << "/" << dlA.capacity() << endl; - Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: " + Info<< "<dlB>" << flatOutput(dlB) << "</dlB>" << nl << "sizes: " << " " << dlB.size() << "/" << dlB.capacity() << endl; // try with a normal list: @@ -166,7 +169,7 @@ int main(int argc, char *argv[]) // check allocation granularity - DynamicList<label, 6, 0> dlC; + DynamicList<label> dlC; printInfo("dlC", dlC, true); @@ -227,15 +230,89 @@ int main(int argc, char *argv[]) dlE2[i] *= 10; } - UIndirectList<label> uil + labelUIndList uil ( dlE2, addr ); Info<< "use UIndirectList " << uil << " remapped from " << dlE2 << endl; dlE4 = uil; printInfo("dlE4", dlE4, true); - } + } + + { + Info<< nl << "Test moving:" << nl; + + labelList input1 = identity(15); + labelList input2 = identity(15); + inplaceReverseList(input2); + + DynamicList<label> list1(std::move(input1)); + DynamicList<label> list2; + + Info<< "move construct:" << nl + << "input: " << flatOutput(input1) << nl + << "list: " << flatOutput(list1) << endl; + + list1 = std::move(input2); + + Info<< "move assignment:" << nl + << "input: " << flatOutput(input2) << nl + << "list: " << flatOutput(list1) << endl; + + list2 = std::move(list1); + Info<< "list in: " << flatOutput(list1) << nl + << "list out: " << flatOutput(list2) << endl; + + input2 = std::move(identity(15)); + list2 = std::move(input2); + Info<< "list in: " << flatOutput(input2) << nl + << "list out: " << flatOutput(list2) << endl; + + input1 = identity(15); + input2 = identity(15); + inplaceReverseList(input2); + + Info<< "test move-append with " + << flatOutput(input1) << " and " << flatOutput(input2) << endl; + list2.append(std::move(list1)); + list2.append(std::move(input1)); + list2.append(std::move(input2)); + + Info<< "result: " << flatOutput(list2) << nl + << "inputs: " << flatOutput(list1) << " / " + << flatOutput(input1) << " / " + << flatOutput(input2) << nl; + + + input1 = list2; + + Info<< nl << "test subset/remove with " + << flatOutput(input1) << endl; + + for + ( + const labelRange range : + { + labelRange(-10, 8), // invalid range + labelRange(40, 18), // trailing portion + labelRange(-5, 10), // leading portion + labelRange(10, 8), // mid-portion + labelRange(0, input1.size()), // everything + } + ) + { + list1 = input1; + list2 = input1; + + list1.remove(range); + list2.subset(range); + + Info<< "input = " << flatOutput(input1) << nl + << "remove " << range << " = " << flatOutput(list1) << nl + << "subset " << range << " = " << flatOutput(list2) << nl; + } + } Info<< "\nEnd\n"; diff --git a/applications/test/Field/Make/files b/applications/test/Field/Make/files deleted file mode 100644 index f8f0bb64df8..00000000000 --- a/applications/test/Field/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -Test-Field.C - -EXE = $(FOAM_USER_APPBIN)/Test-Field diff --git a/applications/test/Field/Make/options b/applications/test/Field/Make/options deleted file mode 100644 index 6a9e9810b3d..00000000000 --- a/applications/test/Field/Make/options +++ /dev/null @@ -1,2 +0,0 @@ -/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ -/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/Field/Test-Field.C b/applications/test/Field/Test-Field.C deleted file mode 100644 index 2e037f6a34b..00000000000 --- a/applications/test/Field/Test-Field.C +++ /dev/null @@ -1,11 +0,0 @@ -#include "Test-Field.H" - -int main() -{ - Vector<double> v1(1, 2); - Vector<double> v2(2, 3); - - std::cout << v1 + v2; - - return 0; -} diff --git a/applications/test/Field/Test-Field.H b/applications/test/Field/Test-Field.H deleted file mode 100644 index bd6929f838e..00000000000 --- a/applications/test/Field/Test-Field.H +++ /dev/null @@ -1,58 +0,0 @@ -#include <iostream> - -template<class C> -class Vector; - -template<class C> -Vector<C> operator+(const Vector<C>& v1, const Vector<C>& v2); - -template<class C> -std::ostream& operator<<(std::ostream& os, const Vector<C>& v); - - -/*---------------------------------------------------------------------------*\ - Class Vector Declaration -\*---------------------------------------------------------------------------*/ - -template<class C> -class Vector -{ - - double X, Y; - -public: - - inline Vector(const double x, const double y); - - C x() const - { - return X; - } - - C y() const - { - return Y; - } - - friend Vector<C> operator+ <C>(const Vector<C>& v1, const Vector<C>& v2); - - friend std::ostream& operator<<(std::ostream& os, const Vector<C>& v) - { - os << v.X << '\t' << v.Y << '\n'; - return os; - } -}; - -template<class C> -inline Vector<C>::Vector(const double x, const double y) -{ - X = x; - Y = y; -} - - -template<class C> -inline Vector<C> operator+(const Vector<C>& v1, const Vector<C>& v2) -{ - return Vector<C>(v1.X+v2.X, v1.Y+v2.Y); -} diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C index b057b43f276..a06abee82f6 100644 --- a/applications/test/FixedList/Test-FixedList.C +++ b/applications/test/FixedList/Test-FixedList.C @@ -35,6 +35,7 @@ See also #include "argList.H" #include "FixedList.H" #include "Fstream.H" +#include "List.H" #include "IPstream.H" #include "OPstream.H" @@ -47,36 +48,44 @@ int main(int argc, char *argv[]) { argList args(argc, argv); - FixedList<label, 4> list; - list[0] = 1; - list[1] = 2; - list[2] = 3; - list[3] = 4; + { + FixedList<label, 4> list1{1, 2, 3, 4}; - Info<< "list:" << list - << " hash:" << FixedList<label, 4>::Hash<>()(list) << endl; + Info<< "list1:" << list1 + << " hash:" << FixedList<label, 4>::Hash<>()(list1) << endl; - label a[4] = {0, 1, 2, 3}; - FixedList<label, 4> list2(a); + label a[4] = {0, 1, 2, 3}; + FixedList<label, 4> list2(a); - Info<< "list2:" << list2 - << " hash:" << FixedList<label, 4>::Hash<>()(list2) << endl; + Info<< "list2:" << list2 + << " hash:" << FixedList<label, 4>::Hash<>()(list2) << endl; - // Using FixedList for content too - { - List<FixedList<label, 4>> twolists{list, list2}; - Info<<"List of FixedList: " << flatOutput(twolists) << endl; - sort(twolists); - // outer-sort only - Info<<"sorted FixedList : " << flatOutput(twolists) << endl; - } + // Using FixedList for content too + { + List<FixedList<label, 4>> twolists{list1, list2}; + Info<<"List of FixedList: " << flatOutput(twolists) << endl; + sort(twolists); + // outer-sort only + Info<<"sorted FixedList : " << flatOutput(twolists) << endl; + } - Info<< "list: " << list << nl - << "list2: " << list2 << endl; - list.swap(list2); - Info<< "Swapped via the swap() method" << endl; - Info<< "list: " << list << nl - << "list2: " << list2 << endl; + Info<< "====" << nl + << "Test swap" << nl; + + Info<< "list1: " << list1 << nl + << "list2: " << list2 << endl; + list1.swap(list2); + Info<< "The swap() method" << endl; + Info<< "list1: " << list1 << nl + << "list2: " << list2 << endl; + + Swap(list1, list2); + Info<< "The Swap() function" << endl; + Info<< "list1: " << list1 << nl + << "list2: " << list2 << endl; + + Info<< "====" << nl; + } List<label> list3{0, 1, 2, 3}; FixedList<label, 4> list4(list3.begin(), list3.end()); diff --git a/applications/test/FixedList/fixedListFile b/applications/test/FixedList/fixedListFile deleted file mode 100644 index 4faae2f6aab9b12b7503643eb87c1756e9139d44..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 30 fcmd-w;?m&KU}RumU;<)IE)5U`;%ahfa&Z9w7<U13 diff --git a/applications/test/FixedList2/Make/files b/applications/test/FixedList2/Make/files new file mode 100644 index 00000000000..548fa36bc5e --- /dev/null +++ b/applications/test/FixedList2/Make/files @@ -0,0 +1,3 @@ +Test-FixedList2.C + +EXE = $(FOAM_USER_APPBIN)/Test-FixedList2 diff --git a/applications/test/FixedList2/Make/options b/applications/test/FixedList2/Make/options new file mode 100644 index 00000000000..e69de29bb2d diff --git a/applications/test/FixedList2/Test-FixedList2.C b/applications/test/FixedList2/Test-FixedList2.C new file mode 100644 index 00000000000..efd3cfabdcb --- /dev/null +++ b/applications/test/FixedList2/Test-FixedList2.C @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + Test-FixedList2 + +Description + Test speeds, usability of some List/FixedList operations + +See also + Foam::FixedList + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "FixedList.H" +#include "labelList.H" +#include "vectorList.H" +#include "ListOps.H" +#include "IFstream.H" +#include "OFstream.H" +#include "cpuTime.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +using namespace Foam; + +template<class ListType> +void runSwapTest +( + const label nLoops, + ListType& list1, + ListType& list2 +) +{ + cpuTime timer; + + Info<<"Swapping fixed lists with " << list1.size() << " elements\n"; + + Info<< "input 1: " << list1.first() << nl; + Info<< "input 2: " << list2.first() << nl; + + // Should be zero, since this is a compile-time value + + Info<< "Perform " << nLoops << " swaps..." << nl; + + for (label iLoop = 0; iLoop < nLoops; ++iLoop) + { + Swap(list1, list2); + } + + Info<< "output 1: " << list1.first() << nl; + Info<< "output 2: " << list2.first() << nl; + + Info<< "Operation took" + << " " << timer.cpuTimeIncrement() << " s\n\n"; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addBoolOption("label"); + argList::addBoolOption("float"); + argList::addBoolOption("vector"); + argList::addBoolOption("labelList"); + argList::addBoolOption("vectorList"); + argList::addBoolOption("fixedLabel"); + argList::addBoolOption("fixedLabelList"); + + argList args(argc, argv); + + if (args.options().empty()) + { + Info<< nl << "Specify an option! " << nl << endl; + } + + if (args.optionFound("label")) + { + FixedList<label, 100000> list1(1); + FixedList<label, 100000> list2(0); + + runSwapTest(1000001, list1, list2); + } + + if (args.optionFound("float")) + { + FixedList<double, 100000> list1(1.0); + FixedList<double, 100000> list2(0.0); + + runSwapTest(1000001, list1, list2); + } + + if (args.optionFound("vector")) + { + FixedList<vector, 100000> list1(vector::one); + FixedList<vector, 100000> list2(vector::zero); + + runSwapTest(100001, list1, list2); + } + + if (args.optionFound("labelList")) + { + typedef labelList testType; + testType initVal(500); + + initVal = 0; + FixedList<testType, 1000> list1(initVal); + + initVal = 1; + FixedList<testType, 1000> list2(initVal); + + runSwapTest(100001, list1, list2); + } + + if (args.optionFound("vectorList")) + { + typedef vectorList testType; + testType initVal(500); + + initVal = vector::zero; + FixedList<testType, 1000> list1(initVal); + + initVal = vector::one; + FixedList<testType, 1000> list2(initVal); + + runSwapTest(100001, list1, list2); + } + + if (args.optionFound("fixedLabel")) + { + typedef FixedList<label,1000> testType; + + testType initVal; + + initVal = 0; + FixedList<testType, 1000> list1(initVal); + + initVal = 1; + FixedList<testType, 1000> list2(initVal); + + runSwapTest(100001, list1, list2); + } + + if (args.optionFound("fixedLabelList")) + { + typedef labelList testType; + typedef FixedList<testType,10> containerType; + + testType tinitVal(500); + containerType initVal; + + tinitVal = 0; + initVal = tinitVal; + FixedList<containerType, 1000> list1(initVal); + + tinitVal = 1; + initVal = tinitVal; + FixedList<containerType, 1000> list2(initVal); + + runSwapTest(10001, list1, list2); + } + + Info<< nl << "Done" << nl << endl; + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/Function1/Test-Function1.C b/applications/test/Function1/Test-Function1.C index ab4baee1509..d1d3b1f073c 100644 --- a/applications/test/Function1/Test-Function1.C +++ b/applications/test/Function1/Test-Function1.C @@ -31,6 +31,7 @@ Description #include "fvCFD.H" #include "Function1.H" +#include "scalarIndList.H" #include "IOdictionary.H" #include "linearInterpolationWeights.H" #include "splineInterpolationWeights.H" @@ -69,7 +70,7 @@ int main(int argc, char *argv[]) scalar baseSum = interpolator.weightedSum ( weights, - UIndirectList<scalar>(values, indices) + scalarUIndList(values, indices) ); Pout<< "baseSum=" << baseSum << nl << nl << endl; @@ -78,7 +79,7 @@ int main(int argc, char *argv[]) // scalar partialSum = interpolator.weightedSum // ( // weights, -// UIndirectList<scalar>(values, indices) +// scalarUIndList(values, indices) // ); // Pout<< "partialSum=" << partialSum << nl << nl << endl; // @@ -90,7 +91,7 @@ int main(int argc, char *argv[]) // scalar sum = interpolator.weightedSum // ( // weights, -// UIndirectList<scalar>(values, indices) +// scalarUIndList(values, indices) // ); // Pout<< "integrand=" << sum << nl << nl << endl; diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C index 55640829fb2..781c6ceabdf 100644 --- a/applications/test/HashSet/Test-hashSet.C +++ b/applications/test/HashSet/Test-hashSet.C @@ -223,6 +223,31 @@ int main(int argc, char *argv[]) Info << i << endl; } + Info<< nl << "Test swapping, moving etc." << nl; + setA.insert({ "some", "more", "entries" }); + + Info<< "input" << nl; + Info<< "setA: " << setA << nl; + + wordHashSet setA1(std::move(setA)); + + Info<< "move construct" << nl; + Info<< "setA: " << setA << nl + << "setA1: " << setA1 << nl; + + + wordHashSet setB1; + Info<< "move assign" << nl; + setB1 = std::move(setA1); + + Info<< "setA1: " << setA1 << nl + << "setB1: " << setB1 << nl; + + setB1.swap(setA1); + + Info<< "setA1: " << setA1 << nl + << "setB1: " << setB1 << nl; + return 0; } diff --git a/applications/test/HashTable/Test-hashTable.C b/applications/test/HashTable/Test-hashTable.C index 1071b0a473a..f0017d4e5af 100644 --- a/applications/test/HashTable/Test-hashTable.C +++ b/applications/test/HashTable/Test-hashTable.C @@ -324,6 +324,34 @@ int main() << nl; + // Start again with new value + table2.set("ada", 14.0); + table2.set("aeq", 15.0); + table2.set("aaw", 16.0); + + Info<< nl << "input values" << nl; + Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl; + + Info<<"global Swap function" << nl; + Swap(table1, table2); + Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl; + + Info<<"swap method" << nl; + table1.swap(table2); + Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl; + + Info<<"transfer" << nl; + table1.transfer(table2); + Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl; + + Info<<"move assign" << nl; + table2 = std::move(table1); + Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl; + + Info<<"move construct" << nl; + HashTable<scalar> table1b(std::move(table2)); + Info<<"table1 = " << table1b << nl <<"table2 = " << table2 << nl; + Info<< "\nDone\n"; return 0; diff --git a/applications/test/IndirectList/Test-IndirectList.C b/applications/test/IndirectList/Test-IndirectList.C index 1af5a1682cf..4727ed52484 100644 --- a/applications/test/IndirectList/Test-IndirectList.C +++ b/applications/test/IndirectList/Test-IndirectList.C @@ -27,58 +27,70 @@ Description #include "IndirectList.H" #include "IOstreams.H" +#include "ListOps.H" +#include "labelIndList.H" using namespace Foam; template<class ListType> void printInfo(const ListType& lst) { - Info<< "addr: " << lst.addressing() << nl - << "list: " << lst << nl + Info<< "addr: " << flatOutput(lst.addressing()) << nl + << "list: " << flatOutput(lst) << nl << endl; } +template<class T, class ListType> +void testFind(const T& val, const ListType& lst) +{ + Info<< nl + << "Search for "<< val << " in " << flatOutput(lst) << nl + <<" found() = " << lst.found(val) + <<" find() = " << lst.find(val) + <<" rfind() = " << lst.rfind(val) + <<" find(2) = " << lst.find(val, 2) + <<" rfind(2) = " << lst.rfind(val, 2) + <<" findIndex = " << findIndex(lst, val) << nl + << nl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { - List<double> completeList(10); + List<label> completeList(20); forAll(completeList, i) { - completeList[i] = 0.1*i; + completeList[i] = 10*i; } - Info<< "raw : " << completeList << nl << endl; + Info<< "raw : " << flatOutput(completeList) << nl << endl; + List<label> addresses{1, 0, 3, 7, 4, 8, 5, 1, 0, 3, 7, 4, 8, 5, }; - List<label> addresses(5); - addresses[0] = 1; - addresses[1] = 0; - addresses[2] = 7; - addresses[3] = 8; - addresses[4] = 5; - - IndirectList<double> idl1(completeList, addresses); + labelIndList idl1(completeList, addresses); printInfo(idl1); - addresses[4] = 1; - addresses[3] = 0; - addresses[2] = 7; - addresses[1] = 8; - addresses[0] = 5; + for (const label val : { 10, 30, 40, 50, 90, 80, 120 } ) + { + testFind(val, idl1); + } + + inplaceReverseList(addresses); idl1.resetAddressing(addresses.xfer()); printInfo(idl1); - // test copying - UIndirectList<double> uidl1(idl1); - IndirectList<double> idl2(uidl1); - IndirectList<double> idl3(idl2); + // Test copying + labelUIndList uidl1(idl1); + labelIndList idl2(uidl1); + labelIndList idl3(idl2); printInfo(uidl1); diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 5d3f3ba4b49..990da8729f5 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -50,6 +50,20 @@ See also using namespace Foam; +template<class T, class ListType> +void testFind(const T& val, const ListType& lst) +{ + Info<< nl + << "Search for "<< val << " in " << flatOutput(lst) << nl + <<" found() = " << lst.found(val) + <<" find() = " << lst.find(val) + <<" rfind() = " << lst.rfind(val) + <<" find(2) = " << lst.find(val, 2) + <<" rfind(2) = " << lst.rfind(val, 2) + <<" findIndex = " << findIndex(lst, val) << nl + << nl; +} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -84,14 +98,20 @@ int main(int argc, char *argv[]) { vector(0, 1, 2), vector(3, 4, 5), - vector(6, 7, 8) + vector(6, 7, 8), + vector(0, 1, 2), + vector(3, 4, 5), + vector(6, 7, 8), }; Info<< "list2: " << list2 << endl; list1.append(list2); Info<< "list1.append(list2): " << list1 << endl; - Info<< findIndex(list2, vector(3, 4, 5)) << endl; + for (const vector& val : { vector(3, 4, 5), vector(10,11, 12)} ) + { + testFind(val, list2); + } list2.setSize(10, vector(1, 2, 3)); Info<< "list2: " << list2 << endl; diff --git a/applications/test/List2/Make/files b/applications/test/List2/Make/files new file mode 100644 index 00000000000..49c6d304c83 --- /dev/null +++ b/applications/test/List2/Make/files @@ -0,0 +1,3 @@ +Test-List2.C + +EXE = $(FOAM_USER_APPBIN)/Test-List2 diff --git a/applications/test/List2/Make/options b/applications/test/List2/Make/options new file mode 100644 index 00000000000..e69de29bb2d diff --git a/applications/test/List2/Test-List2.C b/applications/test/List2/Test-List2.C new file mode 100644 index 00000000000..0be3acda63e --- /dev/null +++ b/applications/test/List2/Test-List2.C @@ -0,0 +1,269 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + Test-List2 + +Description + Test speeds, usability of some List/FixedList operations + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "FixedList.H" +#include "labelList.H" +#include "vectorList.H" +#include "ListOps.H" +#include "IFstream.H" +#include "OFstream.H" +#include "cpuTime.H" + +#include <initializer_list> + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +using namespace Foam; + +template<class ListType> +void runResizeTest +( + const label nLoops, + ListType& list, + std::initializer_list<label> sizes +) +{ + cpuTime timer; + + const label size0 = list.size(); + const auto val = list.first(); + + Info<<"Resize list(" << list.size() << ") to"; + + for (auto len : sizes) + { + Info<< " " << len; + } + Info<< nl; + + Info<< "Perform " << nLoops << " times..." << nl; + for (label iLoop = 0; iLoop < nLoops; ++iLoop) + { + list.setSize(size0, val); + + for (auto len : sizes) + { + list.setSize(len, val); + } + } + + Info<< "Operation took" + << " " << timer.cpuTimeIncrement() << " s\n\n"; +} + + +template<class ListType> +void runOrderingTest(const label nLoops, const ListType& list) +{ + if (true) + { + cpuTime timer; + + float total = 0; + + Info<<"forAll - perform " << nLoops << " times..." << nl; + for (label iLoop = 0; iLoop < nLoops; ++iLoop) + { + float sum = 0; + forAll(list, i) + { + sum += list[i]; + } + + total += sum; + } + + Info<< "Operation (sum " << total << ") took" + << " " << timer.cpuTimeIncrement() << " s\n\n"; + } + + if (true) + { + cpuTime timer; + + float total = 0; + + Info<<"reverse pointer loop - perform " << nLoops << " times..." << nl; + for (label iLoop = 0; iLoop < nLoops; ++iLoop) + { + float sum = 0; + + const typename ListType::value_type* __restrict__ fp + = (list).end(); + + label i = (list).size(); + while (i--) + { + sum += (*--fp); + } + + total += sum; + } + + Info<< "Operation (sum " << total << ") took" + << " " << timer.cpuTimeIncrement() << " s\n\n"; + } + + if (true) + { + cpuTime timer; + + float total = 0; + + Info<<"forward pointer loop - perform " << nLoops << " times..." << nl; + for (label iLoop = 0; iLoop < nLoops; ++iLoop) + { + float sum = 0; + + const typename ListType::value_type* __restrict__ fp + = (list).begin(); + + label i = (list).size(); + while (i--) + { + sum += (*fp++); + } + + total += sum; + } + + Info<< "Operation (sum " << total << ") took" + << " " << timer.cpuTimeIncrement() << " s\n\n"; + } + + + if (true) + { + cpuTime timer; + + float total = 0; + + Info<<"for loop - perform " << nLoops << " times..." << nl; + for (label iLoop = 0; iLoop < nLoops; ++iLoop) + { + float sum = 0; + + const typename ListType::value_type* __restrict__ fp + = (list).begin(); + + const label sz = (list).size(); + for (label i=0; i<sz; ++i) + { + sum += fp[i]; + } + + total += sum; + } + + Info<< "Operation (sum " << total << ") took" + << " " << timer.cpuTimeIncrement() << " s\n\n"; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addBoolOption("label"); + argList::addBoolOption("float"); + argList::addBoolOption("vector"); + argList::addBoolOption("order"); + argList::addBoolOption("labelList"); + argList::addBoolOption("vectorList"); + + argList args(argc, argv); + + if (args.options().empty()) + { + Info<< nl << "Specify an option! " << nl << endl; + } + + + std::initializer_list<label> increments + = {10000, 20000, 40000, 80000, 160000}; + + if (args.optionFound("label")) + { + List<label> list(10, 1); + + runResizeTest(100000, list, increments); + } + + if (args.optionFound("float")) + { + List<double> list(10, 1.0); + + runResizeTest(10000, list, increments); + } + + if (args.optionFound("vector")) + { + List<vector> list(10, vector::one); + + runResizeTest(10000, list, increments); + } + + if (args.optionFound("labelList")) + { + typedef labelList testType; + testType initVal(500, label(1)); + + List<testType> list(10, initVal); + + runResizeTest(200, list, increments); + } + + if (args.optionFound("vectorList")) + { + typedef vectorList testType; + testType initVal(500, vector::one); + + List<testType> list(10, initVal); + + runResizeTest(100, list, increments); + } + + if (args.optionFound("order")) + { + List<label> list(100000000, 1); + + runOrderingTest(100, list); + } + + + Info<< nl << "Done" << nl << endl; + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/ListOps2/Make/files b/applications/test/ListOps2/Make/files new file mode 100644 index 00000000000..4149f5146d3 --- /dev/null +++ b/applications/test/ListOps2/Make/files @@ -0,0 +1,2 @@ +Test-ListOps2.C +EXE = $(FOAM_USER_APPBIN)/Test-ListOps2 diff --git a/applications/test/ListOps2/Make/options b/applications/test/ListOps2/Make/options new file mode 100644 index 00000000000..51903c0ce4f --- /dev/null +++ b/applications/test/ListOps2/Make/options @@ -0,0 +1,3 @@ +EXE_INC = /*-DFULLDEBUG -O0 -g*/ \ + +EXE_LIBS = diff --git a/applications/test/ListOps2/Test-ListOps2.C b/applications/test/ListOps2/Test-ListOps2.C new file mode 100644 index 00000000000..e41ae9f893b --- /dev/null +++ b/applications/test/ListOps2/Test-ListOps2.C @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + Test-ListOps2 + +Description + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "List.H" +#include "FixedList.H" +#include "DynamicList.H" +#include "SubList.H" +#include "ListOps.H" +#include "FlatOutput.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class ListType> +void testFind(const ListType& list) +{ + Info<< nl << "list: " << flatOutput(list) << nl << endl; + + for (auto val : { 20, 35, 6, 13, 12, -12}) + { + Info<< "lookup " << val + << " found " << list.found(val) + << " index " << list.find(val) << nl; + } +} + + +template<class ListType> +void testMoving(ListType& list) +{ + Info<< nl << "list: " << flatOutput(list) << nl << endl; + + { + const label i = 3; + list.swapFirst(i); + Info<<"swapFirst: " << i << " = " << flatOutput(list) << nl; + } + + { + const label i = 6; + list.moveFirst(i); + Info<<"moveFirst: " << i << " = " << flatOutput(list) << nl; + } + + { + const label i = 6; + list.moveLast(i); + Info<<"moveLast: " << i << " = " << flatOutput(list) << nl; + } + + { + const label i = 8; + list.swapLast(i); + Info<<"swapLast: " << i << " = " << flatOutput(list) << nl; + } +} + + +// Main program: + +int main(int argc, char *argv[]) +{ + List<label> list1(identity(15)); + shuffle(list1); + + FixedList<label, 15> list2(list1); + inplaceReverseList(list2); + + DynamicList<label> list3(list1); + inplaceReverseList(list3); + + testFind(list1); + testFind(list2); + testFind(list3); + + testMoving(list1); + testMoving(list2); + testMoving(list3); + + // Test remove + { + auto& list = list3; + + Info<< nl << "list: " << flatOutput(list) << nl << endl; + + list.remove(); + Info<<"remove = " << flatOutput(list) << nl; + + { + const label i = 6; + list.remove(i); + Info<<"rmSwap: " << i << " = " << flatOutput(list) << nl; + } + + { + const label i = 3; + list.remove(i); + Info<<"rmSwap: " << i << " = " << flatOutput(list) << nl; + } + + { + const label i = 8; + list.remove(i); + Info<<"rmMove: " << i << " = " << flatOutput(list) << nl; + } + } + + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/Map/Test-Map.C b/applications/test/Map/Test-Map.C index 5ced3b569d0..5ba38e9f60b 100644 --- a/applications/test/Map/Test-Map.C +++ b/applications/test/Map/Test-Map.C @@ -38,41 +38,75 @@ using namespace Foam; int main(int argc, char *argv[]) { - Map<bool> banana{{5, true}}; + Map<bool> map1 + { + {1, true}, {2, false}, {3, true}, {4, false}, {5, true} + }; // Taking a const iterator from find does not work! // Also, fails later on op== - Map<bool>::const_iterator bananaIter = banana.find(5); + Map<bool>::const_iterator map1Iter = map1.cfind(5); - // This works but now I can change the value. - //Map<bool>::iterator bananaIter = banana.find(5); + // Same, but with non-const access + // Map<bool>::iterator map1Iter = map1.find(5); - if (!bananaIter.found()) // same as (bananaIter == banana.end()) + if (!map1Iter.found()) // same as (map1Iter == map1.end()) { Info<< "not found" << endl; } else { - Info<< "5 is " << bananaIter() << endl; + Info<< "5 is " << *map1Iter << endl; } - // Same with STL + // Repeat with std::map Info<< "Same with STL" << endl; - std::map<label, bool> STLbanana{{5, true}}; - std::map<label, bool>::const_iterator STLbananaIter = STLbanana.find(5); + std::map<label, bool> stdmap1 + { + {1, true}, {2, false}, {3, true}, {4, false}, {5, true} + }; + + std::map<label, bool>::const_iterator stdmap1Iter = stdmap1.find(5); - if (STLbananaIter == STLbanana.end()) + if (stdmap1Iter == stdmap1.cend()) { Info<< "not found" << endl; } else { - Info<< "5 is " << STLbananaIter->second << endl; + Info<< "5 is " << stdmap1Iter->second << endl; } - Info<< "End\n" << endl; + Info<<"test move construct" << nl; + Map<bool> map2(std::move(map1)); + Map<bool> map3; + + std::map<label, bool> stdmap2(std::move(stdmap1)); + std::map<label, bool> stdmap3; + + Info<<"map1: " << map1 << nl + <<"map2: " << map2 << nl; + + Info + <<"stdmap1: " << stdmap1.size() << nl + <<"stdmap2: " << stdmap2.size() << nl; + + + Info<<"test move assign" << nl; + map3 = std::move(map2); + stdmap3 = std::move(stdmap2); + + Info<<"map2: " << map2 << nl + <<"map3: " << map3 << nl; + + Info + <<"stdmap2: " << stdmap2.size() << nl + <<"stdmap3: " << stdmap3.size() << nl; + + + Info<< nl << "End\n" << endl; return 0; } diff --git a/applications/test/UIndirectList/Test-UIndirectList.C b/applications/test/UIndirectList/Test-UIndirectList.C index be78bbd16b3..7749a2b18fc 100644 --- a/applications/test/UIndirectList/Test-UIndirectList.C +++ b/applications/test/UIndirectList/Test-UIndirectList.C @@ -29,75 +29,102 @@ Description #include "DynamicList.H" #include "IOstreams.H" #include "ListOps.H" -#include "OFstream.H" +#include "labelIndList.H" using namespace Foam; +template<class ListType> +void printInfo(const ListType& lst) +{ + Info<< "addr: " << flatOutput(lst.addressing()) << nl + << "list: " << flatOutput(lst) << nl + << endl; +} + +template<class T, class ListType> +void testFind(const T& val, const ListType& lst) +{ + Info<< nl + << "Search for "<< val << " in " << flatOutput(lst) << nl + <<" found() = " << lst.found(val) + <<" find() = " << lst.find(val) + <<" rfind() = " << lst.rfind(val) + <<" find(2) = " << lst.find(val, 2) + <<" rfind(2) = " << lst.rfind(val, 2) + <<" findIndex = " << findIndex(lst, val) << nl + << nl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { - List<double> completeList(10); + List<label> completeList(20); forAll(completeList, i) { - completeList[i] = 0.1*i; + completeList[i] = 10*i; } - List<label> addresses(5); - addresses[0] = 1; - addresses[1] = 0; - addresses[2] = 7; - addresses[3] = 8; - addresses[4] = 5; + Info<< "raw : " << flatOutput(completeList) << nl << endl; + + List<label> addresses{1, 0, 3, 7, 4, 8, 5, 1, 0, 3, 7, 4, 8, 5, }; + + labelUIndList idl1(completeList, addresses); - UIndirectList<double> idl(completeList, addresses); + printInfo(idl1); - Info<< idl << "\n"; + for (const label val : { 10, 30, 40, 50, 90, 80, 120 } ) + { + testFind(val, idl1); + } - idl[1] = -666; + Info<< flatOutput(idl1) << nl; - Info<< "idl[1] changed: " << idl << endl; + idl1[1] = -666; - idl = -999; + Info<< "idl1[1] changed: " << flatOutput(idl1) << endl; - Info<< "idl changed: " << idl << endl; + idl1 = -999; - UIndirectList<double> idl2(idl); + Info<< "idl1 changed: " << flatOutput(idl1) << endl; - Info<< "idl2: " << idl2 << endl; + labelUIndList idl2(idl1); + Info<< "idl2: " << flatOutput(idl2) << endl; { - List<double> ident(idl.size()); + List<label> ident(idl1.size()); forAll(ident, i) { ident[i] = ident.size() - i; } - idl = ident; + idl1 = ident; } - Info<< "idl assigned from UList: " << idl << endl; + Info<< "idl1 assigned from UList: " << flatOutput(idl1) << endl; // test List operations - List<double> flatList(UIndirectList<double>(completeList, addresses)); - Info<< "List constructed from UIndirectList: " << flatList << endl; + List<label> flatList(labelUIndList(completeList, addresses)); + Info<< "List construct from UIndirectList: " << flatOutput(flatList) << nl; - flatList = UIndirectList<double>(completeList, addresses); - Info<< "List assigned from UIndirectList: " << flatList << endl; + flatList = labelUIndList(completeList, addresses); + Info<< "List assign from UIndirectList: " << flatOutput(flatList) << nl; - flatList.append(UIndirectList<double>(completeList, addresses)); - Info<< "List::append(UIndirectList): " << flatList << endl; + flatList.append(labelUIndList(completeList, addresses)); + Info<< "List::append(UIndirectList): " << flatOutput(flatList) << nl; - DynamicList<double> dynList(UIndirectList<double>(completeList, addresses)); - Info<< "DynamicList constructed from UIndirectList: " << dynList << endl; + DynamicList<label> dynList(labelUIndList(completeList, addresses)); + Info<< "DynamicList construct from UIndirectList: " << flatOutput(dynList) + << nl; - dynList.append(UIndirectList<double>(completeList, addresses)); - Info<< "DynamicList::append(UIndirectList): " << dynList << endl; + dynList.append(labelUIndList(completeList, addresses)); + Info<< "DynamicList::append(UIndirectList): " << flatOutput(dynList) << nl; Info<< "\nEnd\n" << endl; diff --git a/applications/test/sort/Test-sortList.C b/applications/test/sort/Test-sortList.C index d92a4a7ad42..1fbfcfcf39c 100644 --- a/applications/test/sort/Test-sortList.C +++ b/applications/test/sort/Test-sortList.C @@ -33,108 +33,147 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: + +template<class T> +void printInfo(const SortableList<T>& list) +{ + Info<< "sorted: " << list << nl + << "indices: " << list.indices() << endl; +} + + int main(int argc, char *argv[]) { - labelList orig(8); - orig[0] = 7; - orig[1] = 9; - orig[2] = 1; - orig[3] = 2; - orig[4] = 4; - orig[5] = 7; - orig[6] = 4; - orig[7] = 0; + const labelList orig{7, 9, 1, 2, 4, 7, 4, 0}; labelList order; - labelList a(orig); - sortedOrder(a, order); + labelList list1(orig); + sortedOrder(list1, order); - SortableList<label> aReverse(a.size()); - aReverse = a; + SortableList<label> list1r(list1.size()); + list1r = list1; - Info<< "unsorted: " << a << endl; - sort(a); - Info<< "sorted: " << a << endl; - Info<< "indices: " << order << endl; + Info<< "unsorted: " << orig << endl; + sort(list1); + Info<< "sorted: " << list1 << nl + << "indices: " << order << endl; - aReverse.reverseSort(); - Info<< "reverse sorted: " << aReverse << endl; - Info<< "reverse indices: " << aReverse.indices() << endl; + list1r.reverseSort(); + Info<< "reverse ..." << nl; + printInfo(list1r); - SortableList<label> b(orig); - Info<< "unsorted: " << orig << endl; - Info<< "sorted: " << b << endl; - Info<< "indices: " << b.indices() << endl; + SortableList<label> list2(orig); + Info<< "unsorted: " << orig << nl; + printInfo(list2); - Info<< "shrunk: " << b.shrink() << endl; - Info<< "indices: " << b.indices() << endl; + Info<< "shrunk: " << list2.shrink() << endl; + Info<< "indices: " << list2.indices() << endl; // repeat by assignment - b = orig; - Info<< "unsorted: " << b << endl; - b.sort(); + list2 = orig; + Info<< "unsorted: " << list2 << endl; + list2.sort(); - Info<< "sorted: " << b << endl; - Info<< "indices: " << b.indices() << endl; + printInfo(list2); // find unique/duplicate values - b = orig; + list2 = orig; - Info<< "unsorted: " << b << endl; - uniqueOrder(b, order); + Info<< "unsorted: " << list2 << endl; + uniqueOrder(list2, order); Info<< "unique: " << order << endl; - duplicateOrder(b, order); + duplicateOrder(list2, order); Info<< "duplicate:" << order << endl; // sort reverse - Info<< "unsorted: " << b << endl; - b.reverseSort(); - Info<< "rsort: " << b << endl; - Info<< "indices: " << b.indices() << endl; + Info<< "unsorted: " << list2 << endl; + list2.reverseSort(); + Info<< "rsort: " << list2 << endl; + Info<< "indices: " << list2.indices() << endl; // transfer assignment - a = orig; - b.transfer(a); - Info<< "unsorted: " << b << endl; - b.sort(); + { + list1 = orig; + list2.transfer(list1); + Info<< "unsorted: " << list2 << endl; + list2.sort(); - Info<< "sorted: " << b << endl; - Info<< "indices: " << b.indices() << endl; + printInfo(list2); - a.transfer(b); + list1.transfer(list2); - Info<< "plain: " << a << endl; - Info<< "sorted: " << b << endl; - Info<< "indices: " << b.indices() << endl; + Info<< "plain: " << list1 << endl; + printInfo(list2); + } // sort/duplicate/unique with identical values - b.setSize(8); - b = 5; + list2.setSize(8); + list2 = 5; - Info<< "unsorted: " << b << endl; + Info<< "unsorted: " << list2 << endl; - uniqueOrder(b, order); + uniqueOrder(list2, order); Info<< "unique: " << order << endl; - duplicateOrder(b, order); + duplicateOrder(list2, order); Info<< "duplicate:" << order << endl; - b.sort(); + list2.sort(); - Info<< "sorted: " << b << endl; - Info<< "indices: " << b.indices() << endl; + printInfo(list2); // with a single value - b.setSize(1); + list2.setSize(1); - Info<< "unsorted: " << b << endl; - uniqueOrder(b, order); + Info<< "unsorted: " << list2 << endl; + uniqueOrder(list2, order); Info<< "unique: " << order << endl; - duplicateOrder(b, order); + duplicateOrder(list2, order); Info<< "duplicate:" << order << endl; - b.sort(); + list2.sort(); + + printInfo(list2); + + { + labelList tmp(orig); + + Info<< nl << "move construct from List: " << tmp << endl; + SortableList<label> list3(std::move(tmp)); + + Info<< "input: " << tmp << endl; + printInfo(list3); + + list3.reverseSort(); + + Info<< nl << "move construct from SortableList: " << list3 << endl; + + SortableList<label> list4(std::move(list3)); + Info<< "input: " << list3 << endl; + printInfo(list3); + printInfo(list4); + + tmp = orig; + + Info<< nl << "move assign from List: " << tmp << endl; + list3 = std::move(tmp); + + Info<< "input: " << tmp << endl; + printInfo(list3); + + Info<< nl << "move assign from SortableList: " << list3 << endl; + list4 = std::move(list3); + + Info<< "input: " << list3 << endl; + printInfo(list3); + printInfo(list4); + + labelList values; + Info<< "move to flat-list: " << list4 << endl; - Info<< "sorted: " << b << endl; - Info<< "indices: " << b.indices() << endl; + values = std::move(list4); + Info<< "input: " << list4 << endl; + printInfo(list4); + Info<< "flat = " << values << endl; + } Info<< "\nEnd\n" << endl; diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 6ad6dfcd433..0309bd6c747 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -589,7 +589,8 @@ void readDOFS is.getLine(line); { IStringStream lineStr(line); - patchNames.append(lineStr); + word pName(lineStr); + patchNames.append(pName); } Info<< "For DOF set " << group diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C index 5b1f45b8395..809adb795b3 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C @@ -275,7 +275,16 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const HashSet<Key, Hash>& tbl) } -/* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */ +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template<class Key, class Hash> +void Foam::Swap(const HashSet<Key, Hash>& a, const HashSet<Key, Hash>& b) +{ + a.swap(b); +} + + +/* * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * */ template<class Key, class Hash> Foam::HashSet<Key, Hash> diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H index fe82253bc0f..12aea8bea33 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H @@ -127,12 +127,18 @@ public: //- Construct from an initializer list of Key HashSet(std::initializer_list<Key> lst); - //- Construct as copy - HashSet(const HashSet<Key, Hash>& hs) + //- Copy construct + HashSet(const this_type& hs) : parent_type(hs) {} + //- Move construct + HashSet(this_type&& hs) + : + parent_type(std::move(hs)) + {} + //- Construct by transferring the parameter contents HashSet(const Xfer<HashSet<Key, Hash>>& hs) : @@ -284,6 +290,20 @@ public: //- Return true if the entry exists, same as found(). inline bool operator[](const Key& key) const; + using parent_type::operator=; + + //- Copy assignment + void operator=(const this_type& rhs) + { + parent_type::operator=(rhs); + } + + //- Move assignment + void operator=(this_type&& rhs) + { + parent_type::operator=(std::move(rhs)); + } + // Comparison @@ -340,6 +360,17 @@ public: }; +// Global Functions + +// Exchange contents of hash tables - see HashTable::swap(). +template<class T, class Key, class Hash> +inline void Swap +( + HashSet<Key, Hash>& a, + HashSet<Key, Hash>& b +); + + // Global Operators //- Combine entries from HashSets diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index bc887b7d3b9..1f209ef350e 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -93,6 +93,18 @@ Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht) } +template<class T, class Key, class Hash> +Foam::HashTable<T, Key, Hash>::HashTable(HashTable<T, Key, Hash>&& ht) +: + HashTableCore(), + nElmts_(0), + tableSize_(0), + table_(nullptr) +{ + transfer(ht); +} + + template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable ( @@ -750,6 +762,15 @@ void Foam::HashTable<T, Key, Hash>::clearStorage() } +template<class T, class Key, class Hash> +void Foam::HashTable<T, Key, Hash>::swap(HashTable<T, Key, Hash>& ht) +{ + Foam::Swap(table_, ht.table_); + Foam::Swap(tableSize_, ht.tableSize_); + Foam::Swap(nElmts_, ht.nElmts_); +} + + template<class T, class Key, class Hash> void Foam::HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) { @@ -908,6 +929,24 @@ void Foam::HashTable<T, Key, Hash>::operator= } +template<class T, class Key, class Hash> +void Foam::HashTable<T, Key, Hash>::operator= +( + HashTable<T, Key, Hash>&& rhs +) +{ + // Check for assignment to self + if (this == &rhs) + { + FatalErrorInFunction + << "attempted assignment to self" + << abort(FatalError); + } + + transfer(rhs); +} + + template<class T, class Key, class Hash> bool Foam::HashTable<T, Key, Hash>::operator== ( diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index cd50551d5d5..aa848e475c4 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -293,6 +293,9 @@ public: //- Construct as copy HashTable(const HashTable<T, Key, Hash>& ht); + //- Move construct + HashTable(HashTable<T, Key, Hash>&& ht); + //- Construct by transferring the parameter contents HashTable(const Xfer<HashTable<T, Key, Hash>>& ht); @@ -528,6 +531,9 @@ public: // Equivalent to clear() followed by resize(0) void clearStorage(); + //- Swap contents of the argument table into this table + void swap(HashTable<T, Key, Hash>& ht); + //- Transfer the contents of the argument table into this table // and annul the argument table. void transfer(HashTable<T, Key, Hash>& ht); @@ -561,6 +567,9 @@ public: //- Assignment from an initializer list void operator=(std::initializer_list<std::pair<Key, T>> lst); + //- Move assign + void operator=(HashTable<T, Key, Hash>&& rhs); + //- Equality. Hash tables are equal if the keys and values are equal. // Independent of table storage size and table order. bool operator==(const HashTable<T, Key, Hash>& rhs) const; @@ -841,6 +850,17 @@ public: }; +// Global Functions + +// Exchange contents of hash tables - see HashTable::swap(). +template<class T, class Key, class Hash> +inline void Swap +( + HashTable<T, Key, Hash>& a, + HashTable<T, Key, Hash>& b +); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index 4d8028ca139..50f0c42d1e7 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -604,4 +604,17 @@ Foam::HashTable<T, Key, Hash>::cend() const } +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template<class T, class Key, class Hash> +inline void Foam::Swap +( + HashTable<T, Key, Hash>& a, + HashTable<T, Key, Hash>& b +) +{ + a.swap(b); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H index 56f59128dd1..e862ff97e39 100644 --- a/src/OpenFOAM/containers/HashTables/Map/Map.H +++ b/src/OpenFOAM/containers/HashTables/Map/Map.H @@ -77,14 +77,20 @@ public: parent_type(is) {} - //- Construct as copy - Map(const Map<T>& map) + //- Copy construct + Map(const this_type& map) : parent_type(map) {} + //- Move construct + Map(this_type&& map) + : + parent_type(std::move(map)) + {} + //- Construct by transferring the parameter contents - Map(const Xfer<Map<T>>& map) + Map(const Xfer<this_type>& map) : parent_type(map) {} @@ -100,6 +106,25 @@ public: : parent_type(map) {} + + + // Member Operators + + using parent_type::operator=; + + //- Copy assignment + void operator=(const this_type& rhs) + { + parent_type::operator=(rhs); + } + + //- Move assignment + void operator=(this_type&& rhs) + { + parent_type::operator=(std::move(rhs)); + } + + }; diff --git a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H index 66bd1cb397a..371a64b5bac 100644 --- a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H +++ b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H @@ -65,7 +65,7 @@ public: ( const UList<T>& posList, const UList<T>& negList, - const labelUList& + const labelUList& addr ); //- Construct given the complete list and by transferring addressing @@ -73,7 +73,7 @@ public: ( const UList<T>& posList, const UList<T>& negList, - const Xfer<List<label>>& + const Xfer<List<label>>& addr ); @@ -94,14 +94,14 @@ public: inline const List<label>& addressing() const; //- Calculate index given whether index is into posList or negList - inline static label posIndex(const label); - inline static label negIndex(const label); + inline static label posIndex(const label i); + inline static label negIndex(const label i); // Edit //- Reset addressing - inline void resetAddressing(const labelUList&); - inline void resetAddressing(const Xfer<List<label>>&); + inline void resetAddressing(const labelUList& addr); + inline void resetAddressing(const Xfer<List<label>>& addr); // Member Operators @@ -110,16 +110,16 @@ public: inline List<T> operator()() const; //- Return non-const access to an element - inline T& operator[](const label); + inline T& operator[](const label i); //- Return const access to an element - inline const T& operator[](const label) const; + inline const T& operator[](const label i) const; //- Assignment to UList of addressed elements - inline void operator=(const UList<T>&); + inline void operator=(const UList<T>& ae); //- Assignment of all entries to the given value - inline void operator=(const T&); + inline void operator=(const T& val); }; diff --git a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H index 1f1dd4de5b3..6b8a6c0b92e 100644 --- a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H +++ b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H @@ -23,6 +23,22 @@ License \*---------------------------------------------------------------------------*/ +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +template<class T> +inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i) +{ + return i; +} + + +template<class T> +inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i) +{ + return -i-1; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class T> @@ -111,20 +127,6 @@ inline void Foam::BiIndirectList<T>::resetAddressing } -template<class T> -inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i) -{ - return i; -} - - -template<class T> -inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i) -{ - return -i-1; -} - - // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T> @@ -144,7 +146,7 @@ inline Foam::List<T> Foam::BiIndirectList<T>::operator()() const template<class T> inline T& Foam::BiIndirectList<T>::operator[](const label i) { - label index = addressing_[i]; + const label index = addressing_[i]; if (index >= 0) { @@ -160,7 +162,7 @@ inline T& Foam::BiIndirectList<T>::operator[](const label i) template<class T> inline const T& Foam::BiIndirectList<T>::operator[](const label i) const { - label index = addressing_[i]; + const label index = addressing_[i]; if (index >= 0) { @@ -193,11 +195,11 @@ inline void Foam::BiIndirectList<T>::operator=(const UList<T>& ae) template<class T> -inline void Foam::BiIndirectList<T>::operator=(const T& t) +inline void Foam::BiIndirectList<T>::operator=(const T& val) { forAll(addressing_, i) { - operator[](i) = t; + operator[](i) = val; } } diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C index 363d6d98e49..deb5b1e7f02 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,23 +24,83 @@ License \*---------------------------------------------------------------------------*/ #include "DynamicList.H" +#include "labelRange.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class T, int SizeMin> +Foam::label Foam::DynamicList<T, SizeMin>::removeElements +( + const labelRange& slice +) +{ + if (!slice.size()) + { + // Noop + return 0; + } + else if (slice.after() >= this->size()) + { + // Remove tail + this->resize(slice.first()); + } + else + { + // Copy (swap) down + label j = slice.first(); + const label len = this->size(); + + for (label i = slice.after(); i < len; ++i, ++j) + { + Foam::Swap(this->operator[](i), this->operator[](j)); + } + + resize(this->size() - slice.size()); + } + + return slice.size(); +} -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // +template<class T, int SizeMin> +Foam::label Foam::DynamicList<T, SizeMin>::subsetElements +( + const labelRange& slice +) +{ + if (slice.first() > 0) + { + // Copy (swap) down + label j = slice.first(); + const label len = slice.size(); + + for (label i = 0; i < len; ++i, ++j) + { + Foam::Swap(this->operator[](i), this->operator[](j)); + } + } + + // Don't need min size, since slice size was already checked before + resize(slice.size()); + return this->size(); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList(Istream& is) +template<class T, int SizeMin> +Foam::DynamicList<T, SizeMin>::DynamicList(Istream& is) : List<T>(is), capacity_(List<T>::size()) {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> Foam::Ostream& Foam::operator<< ( Ostream& os, - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + const DynamicList<T, SizeMin>& lst ) { os << static_cast<const List<T>&>(lst); @@ -48,11 +108,11 @@ Foam::Ostream& Foam::operator<< } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> Foam::Istream& Foam::operator>> ( Istream& is, - DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + DynamicList<T, SizeMin>& lst ) { is >> static_cast<List<T>&>(lst); diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 6c03173401e..4dae845ed31 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -52,21 +52,20 @@ namespace Foam { // Forward declaration of friend functions and operators +template<class T, int SizeMin> class DynamicList; -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -class DynamicList; - -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> Ostream& operator<< ( Ostream& os, - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + const DynamicList<T, SizeMin>& lst ); -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> + +template<class T, int SizeMin> Istream& operator>> ( Istream& is, - DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + DynamicList<T, SizeMin>& lst ); @@ -74,22 +73,36 @@ Istream& operator>> Class DynamicList Declaration \*---------------------------------------------------------------------------*/ -template<class T, unsigned SizeInc=0, unsigned SizeMult=2, unsigned SizeDiv=1> +template<class T, int SizeMin = 16> class DynamicList : public List<T> { - static_assert - ( - (SizeInc || SizeMult) && SizeDiv, - "Invalid sizing parameters" - ); + static_assert(SizeMin > 0, "Invalid min size parameter"); // Private data //- The capacity (allocated size) of the underlying list. label capacity_; +private: + + // Private Member Functions + + //- Remove elements in range + label removeElements(const labelRange& slice); + + //- Subset elements in range + label subsetElements(const labelRange& slice); + + +protected: + + // Protected Member Functions + + //- Copy assignment from another list + template<class ListType> + inline void assignDynList(const ListType& lst); public: @@ -108,18 +121,26 @@ public: explicit inline DynamicList(const label nElem); //- Construct with given size and value for all elements. - inline DynamicList(const label nElem, const T& a); + inline DynamicList(const label nElem, const T& val); + + //- Construct with given size initializing all elements to zero + inline DynamicList(const label s, const zero); + + //- Copy construct. + inline DynamicList(const DynamicList<T, SizeMin>& lst); - //- Construct copy. - inline DynamicList - ( - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst - ); + //- Copy construct from DynamicList with different sizing parameters + template<int AnySizeMin> + inline DynamicList(const DynamicList<T, AnySizeMin>& lst); //- Construct from UList. Size set to UList size. // Also constructs from DynamicList with different sizing parameters. explicit inline DynamicList(const UList<T>& lst); + //- Construct from a FixedList + template<unsigned FixedSize> + inline DynamicList(const FixedList<T, FixedSize>& lst); + //- Construct given begin/end iterators. // Uses std::distance to determine the size. template<class InputIterator> @@ -131,9 +152,18 @@ public: //- Construct from UIndirectList. Size set to UIndirectList size. explicit inline DynamicList(const UIndirectList<T>& lst); - //- Construct by transferring the parameter contents + //- Transfer (move) construct explicit inline DynamicList(const Xfer<List<T>>& lst); + //- Move construct. + inline DynamicList(DynamicList<T, SizeMin>&& lst); + + //- Move construct from List + inline DynamicList(List<T>&& lst); + + //- Move construct from SortableList + DynamicList(SortableList<T>&& lst); + //- Construct from Istream. Size set to size of list read. explicit DynamicList(Istream& is); @@ -153,25 +183,23 @@ public: // Use this or reserve() in combination with append(). inline void setCapacity(const label nElem); - //- Alter the addressed list size. + //- Alter addressable list size. // New space will be allocated if required. // Use this to resize the list prior to using the operator[] for // setting values (as per List usage). inline void setSize(const label nElem); - //- Alter the addressed list size and fill new space with a - // constant. - inline void setSize(const label nElem, const T& t); + //- Alter addressable list size and fill new space with constant. + inline void setSize(const label nElem, const T& val); - //- Alter the addressed list size. + //- Alter addressable list size. // New space will be allocated if required. // Use this to resize the list prior to using the operator[] for // setting values (as per List usage). inline void resize(const label nElem); - //- Alter the addressed list size and fill new space with a - // constant. - inline void resize(const label nElem, const T& t); + //- Alter addressable list size and fill new space with constant. + inline void resize(const label nElem, const T& val); //- Reserve allocation space for at least this size. // Never shrinks the allocated size, use setCapacity() for that. @@ -186,101 +214,162 @@ public: //- Shrink the allocated space to the number of elements used. // Returns a reference to the DynamicList. - inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& shrink(); + inline DynamicList<T, SizeMin>& shrink(); + + //- Swap content with any sized DynamicList + template<int AnySizeMin> + inline void swap(DynamicList<T, AnySizeMin>& lst); //- Transfer contents of the argument List into this. inline void transfer(List<T>& lst); - //- Transfer contents of the argument DynamicList into this. - inline void transfer - ( - DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst - ); + //- Transfer contents of any sized DynamicList into this. + template<int AnySizeMin> + inline void transfer(DynamicList<T, AnySizeMin>& lst); + + //- Transfer contents of the argument SortableList into this. + inline void transfer(SortableList<T>& lst); //- Transfer contents to the Xfer container as a plain List inline Xfer<List<T>> xfer(); - // Member Operators + //- Append an element to the end of this list. + inline DynamicList<T, SizeMin>& append(const T& val); - //- Append an element at the end of the list - inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append - ( - const T& t - ); + //- Append another list to the end of this list. + inline DynamicList<T, SizeMin>& append(const UList<T>& lst); - //- Append a List at the end of this list - inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append - ( - const UList<T>& lst - ); + //- Append a FixedList to the end of this list. + template<unsigned FixedSize> + inline DynamicList<T, SizeMin>& + append(const FixedList<T, FixedSize>& lst); //- Append an initializer list at the end of this list. - inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append - ( - std::initializer_list<T> lst - ); + inline DynamicList<T, SizeMin>& + append(std::initializer_list<T> lst); //- Append a UIndirectList at the end of this list - inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append - ( - const UIndirectList<T>& lst - ); + inline DynamicList<T, SizeMin>& + append(const UIndirectList<T>& lst); + + //- Move append list + inline DynamicList<T, SizeMin>& append(List<T>&& lst); + + //- Move append list + inline DynamicList<T, SizeMin>& + append(DynamicList<T, SizeMin>&& lst); + + //- Move append list + template<int AnySizeMin> + inline DynamicList<T, SizeMin>& + append(DynamicList<T, AnySizeMin>&& lst); - //- Remove and return the top element + //- Move append list + inline DynamicList<T, SizeMin>& + append(SortableList<T>&& lst); + + //- Remove and return the last element. Fatal on an empty list. inline T remove(); + //- Remove and return the specified element. Fatal on an empty list. + // With fast=true (operates in constant time), the place of the + // removed element is swapped with the last one in the list, which + // changes the ordering. + // With fast=false (operates in linear time), the elements + // are swapped down in the list to preserve ordering. + inline T remove(const label idx, const bool fast=false); + + //- Remove a (start,size) subset from the list. + // The range is subsetted with the list size itself to ensure + // result always addresses a valid section of the list. + // Remaining elements are moved down. + inline label remove(const labelRange& range); + + //- Remove a (start,size) subset from the list. + inline label remove(std::initializer_list<label> start_size); + + //- Retain a (start,size) subset from the list. + // The range is subsetted with the list size itself to ensure + // result always addresses a valid section of the list. + // Remaining elements are moved down. + inline label subset(const labelRange& range); + + //- Retain a (start,size) subset from List. + inline label subset(std::initializer_list<label> start_size); + + + // Member Operators + //- Return non-const access to an element, resizing list if // necessary inline T& operator()(const label elemI); //- Assignment of all addressed entries to the given value - inline void operator=(const T& t); + inline void operator=(const T& val); - //- Assignment to DynamicList - inline void operator= - ( - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst - ); + //- Assignment of all entries to zero + inline void operator=(const zero); //- Assignment to UList inline void operator=(const UList<T>& lst); + //- Assignment to FixedList + template<unsigned FixedSize> + inline void operator=(const FixedList<T, FixedSize>& lst); + + //- Assignment to DynamicList + inline void operator=(const DynamicList<T, SizeMin>& lst); + + //- Assignment from DynamicList with different sizing parameters + template<int AnySizeMin> + inline void operator=(const DynamicList<T, AnySizeMin>& lst); + //- Assignment from initializer list inline void operator=(std::initializer_list<T> lst); //- Assignment to UIndirectList inline void operator=(const UIndirectList<T>& lst); + //- Move assignment + inline void operator=(List<T>&& lst); - // STL member functions + //- Move assignment + inline void operator=(DynamicList<T, SizeMin>&& lst); - //- Erase an element, move the remaining elements to fill the gap - // and resize the List - typename UList<T>::iterator erase - ( - typename UList<T>::iterator curIter - ); + //- Move assignment + template<int AnySizeMin> + inline void operator=(DynamicList<T, AnySizeMin>&& lst); + + //- Move assignment + inline void operator=(SortableList<T>&& lst); // IOstream operators // Write DynamicList to Ostream. - friend Ostream& operator<< <T, SizeInc, SizeMult, SizeDiv> + friend Ostream& operator<< <T, SizeMin> ( Ostream& os, - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + const DynamicList<T, SizeMin>& lst ); //- Read from Istream, discarding contents of existing DynamicList. - friend Istream& operator>> <T, SizeInc, SizeMult, SizeDiv> + friend Istream& operator>> <T, SizeMin> ( Istream& is, - DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + DynamicList<T, SizeMin>& lst ); }; +// Global Functions + +// Exchange contents of lists - see DynamicList::swap(). +template<class T, int SizeMin1, int SizeMin2> +inline void Swap(DynamicList<T, SizeMin1>& a, DynamicList<T, SizeMin2>& b); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index e6ba973b48a..a41f284f639 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,17 +23,47 @@ License \*---------------------------------------------------------------------------*/ +#include "FixedList.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template<class T, int SizeMin> +template<class ListType> +inline void Foam::DynamicList<T, SizeMin>::assignDynList +( + const ListType& lst +) +{ + const label newSize = lst.size(); + + if (capacity_ >= newSize) + { + // Can copy w/o reallocating - adjust addressable size accordingly. + List<T>::size(newSize); + List<T>::operator=(lst); + } + else + { + // Ensure list size consistency prior to copying. + List<T>::size(capacity_); + + List<T>::operator=(lst); + capacity_ = List<T>::size(); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList() +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList() : capacity_(0) {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList ( const label nElem ) @@ -41,27 +71,52 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList List<T>(nElem), capacity_(nElem) { - // We could also enforce SizeInc granularity when (!SizeMult || !SizeDiv) + // We could also enforce sizing granularity + List<T>::size(0); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList +( + const label nElem, + const T& val +) +: + List<T>(nElem, val), + capacity_(nElem) +{} + + +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList ( const label nElem, - const T& a + const zero ) : - List<T>(nElem, a), + List<T>(nElem, Zero), capacity_(nElem) {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList +( + const DynamicList<T, SizeMin>& lst +) +: + List<T>(lst), + capacity_(lst.size()) +{} + + +template<class T, int SizeMin> +template<int AnySizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList ( - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + const DynamicList<T, AnySizeMin>& lst ) : List<T>(lst), @@ -69,8 +124,8 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList ( const UList<T>& lst ) @@ -80,9 +135,22 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> +template<unsigned FixedSize> +inline Foam::DynamicList<T, SizeMin>::DynamicList +( + const FixedList<T, FixedSize>& lst +) +: + capacity_(0) +{ + this->operator=(lst); +} + + +template<class T, int SizeMin> template<class InputIterator> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +inline Foam::DynamicList<T, SizeMin>::DynamicList ( InputIterator begIter, InputIterator endIter @@ -93,8 +161,8 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList ( std::initializer_list<T> lst ) @@ -104,8 +172,8 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList ( const UIndirectList<T>& lst ) @@ -115,8 +183,8 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList ( const Xfer<List<T>>& lst ) @@ -126,19 +194,42 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList {} +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList +( + DynamicList<T, SizeMin>&& lst +) +: + capacity_(0) +{ + transfer(lst); +} + + +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList +( + List<T>&& lst +) +: + capacity_(0) +{ + transfer(lst); +} + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::label Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::capacity() +template<class T, int SizeMin> +inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const { return capacity_; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::setCapacity ( const label nElem ) @@ -152,15 +243,15 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity nextFree = capacity_; } - // We could also enforce SizeInc granularity when (!SizeMult || !SizeDiv) + // We could also enforce sizing granularity List<T>::setSize(capacity_); List<T>::size(nextFree); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::reserve ( const label nElem ) @@ -170,20 +261,25 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve { capacity_ = max ( - nElem, - label(SizeInc + capacity_ * SizeMult / SizeDiv) + SizeMin, + max + ( + nElem, + // label(SizeInc + capacity_ * SizeMult / SizeDiv) + label(2 * capacity_) + ) ); // Adjust allocated size, leave addressed size untouched - label nextFree = List<T>::size(); + const label nextFree = List<T>::size(); List<T>::setSize(capacity_); List<T>::size(nextFree); } } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::setSize ( const label nElem ) @@ -193,8 +289,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize { capacity_ = max ( - nElem, - label(SizeInc + capacity_ * SizeMult / SizeDiv) + SizeMin, + max + ( + nElem, + // label(SizeInc + capacity_ * SizeMult / SizeDiv) + label(2 * capacity_) + ) ); List<T>::setSize(capacity_); @@ -205,11 +306,11 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::setSize ( const label nElem, - const T& t + const T& val ) { label nextFree = List<T>::size(); @@ -218,13 +319,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize // Set new elements to constant value while (nextFree < nElem) { - this->operator[](nextFree++) = t; + this->operator[](nextFree++) = val; } } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::resize ( const label nElem ) @@ -233,37 +334,37 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::resize ( const label nElem, - const T& t + const T& val ) { - this->setSize(nElem, t); + this->setSize(nElem, val); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clear() +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::clear() { List<T>::size(0); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clearStorage() +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::clearStorage() { List<T>::clear(); capacity_ = 0; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink() +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::shrink() { - label nextFree = List<T>::size(); + const label nextFree = List<T>::size(); if (capacity_ > nextFree) { // Use the full list when resizing @@ -278,9 +379,21 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink() } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> +template<int AnySizeMin> +inline void Foam::DynamicList<T, SizeMin>::swap +( + DynamicList<T, AnySizeMin>& lst +) +{ + Foam::Swap(static_cast<UList<T>&>(*this), static_cast<UList<T>&>(lst)); + Foam::Swap(capacity_, lst.capacity_); +} + + +template<class T, int SizeMin> inline void -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& lst) +Foam::DynamicList<T, SizeMin>::transfer(List<T>& lst) { // Take over storage, clear addressing for lst. capacity_ = lst.size(); @@ -288,11 +401,12 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& lst) } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> +template<int AnySizeMin> inline void -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer +Foam::DynamicList<T, SizeMin>::transfer ( - DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + DynamicList<T, AnySizeMin>& lst ) { // Take over storage as-is (without shrink), clear addressing for lst. @@ -302,32 +416,45 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> +inline void +Foam::DynamicList<T, SizeMin>::transfer +( + SortableList<T>& lst +) +{ + lst.shrink(); // Shrink away sort indices + capacity_ = lst.size(); // Capacity after transfer == list size + List<T>::transfer(lst); +} + + +template<class T, int SizeMin> inline Foam::Xfer<Foam::List<T>> -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer() +Foam::DynamicList<T, SizeMin>::xfer() { return xferMoveTo<List<T>>(*this); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append ( - const T& t + const T& val ) { - const label elemI = List<T>::size(); - setSize(elemI + 1); + const label idx = List<T>::size(); + setSize(idx + 1); - this->operator[](elemI) = t; + this->operator[](idx) = val; return *this; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append ( const UList<T>& lst ) @@ -341,17 +468,36 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append label nextFree = List<T>::size(); setSize(nextFree + lst.size()); - forAll(lst, elemI) + for (const T& val : lst) { - this->operator[](nextFree++) = lst[elemI]; + this->operator[](nextFree++) = val; + } + return *this; +} + + +template<class T, int SizeMin> +template<unsigned FixedSize> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append +( + const FixedList<T, FixedSize>& lst +) +{ + label nextFree = List<T>::size(); + setSize(nextFree + lst.size()); + + for (const T& val : lst) + { + this->operator[](nextFree++) = val; } return *this; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append ( std::initializer_list<T> lst ) @@ -367,9 +513,9 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append ( const UIndirectList<T>& lst ) @@ -385,29 +531,159 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove() +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append +( + List<T>&& lst +) +{ + if (this == &lst) + { + FatalErrorInFunction + << "Attempted appending to self" << abort(FatalError); + } + + label nextFree = List<T>::size(); + setSize(nextFree + lst.size()); + + for (T& val : lst) + { + Foam::Swap(this->operator[](nextFree++), val); + } + + lst.clear(); + return *this; +} + + +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append +( + DynamicList<T, SizeMin>&& lst +) +{ + append(std::move(static_cast<List<T>&>(lst))); + lst.clearStorage(); // Ensure capacity=0 too + return *this; +} + + +template<class T, int SizeMin> +template<int AnySizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append +( + DynamicList<T, AnySizeMin>&& lst +) +{ + append(std::move(static_cast<List<T>&>(lst))); + lst.clearStorage(); // Ensure capacity=0 too + return *this; +} + + +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append +( + SortableList<T>&& lst +) +{ + lst.shrink(); // Shrink away sort indices + append(std::move(static_cast<List<T>&>(lst))); + return *this; +} + + +template<class T, int SizeMin> +inline T Foam::DynamicList<T, SizeMin>::remove() { - const label elemI = List<T>::size() - 1; + // Location of last element and simultaneously the new size + const label idx = List<T>::size() - 1; - if (elemI < 0) + if (idx < 0) { FatalErrorInFunction << "List is empty" << abort(FatalError); } - const T& val = List<T>::operator[](elemI); + const T& val = List<T>::operator[](idx); - List<T>::size(elemI); + List<T>::size(idx); return val; } +template<class T, int SizeMin> +inline T Foam::DynamicList<T, SizeMin>::remove +( + const label idx, + const bool fast +) +{ + if (fast) + { + // Simply swap idx <=> last + this->swapLast(idx); + } + else + { + // Move element to the end and move everything down + this->moveLast(idx); + } + + // Element to remove is now at the end + return this->remove(); +} + + +template<class T, int SizeMin> +inline Foam::label Foam::DynamicList<T, SizeMin>::remove +( + const labelRange& range +) +{ + return this->removeElements(this->validateRange(range)); +} + + +template<class T, int SizeMin> +inline Foam::label Foam::DynamicList<T, SizeMin>::remove +( + std::initializer_list<label> start_size +) +{ + return this->removeElements(this->validateRange(start_size)); +} + + +template<class T, int SizeMin> +inline Foam::label Foam::DynamicList<T, SizeMin>::subset +( + const labelRange& range +) +{ + return this->subsetElements(this->validateRange(range)); +} + + +template<class T, int SizeMin> +inline Foam::label Foam::DynamicList<T, SizeMin>::subset +( + std::initializer_list<label> start_size +) +{ + return this->subsetElements(this->validateRange(start_size)); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator() +template<class T, int SizeMin> +inline T& Foam::DynamicList<T, SizeMin>::operator() ( const label elemI ) @@ -421,139 +697,156 @@ inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator() } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= ( - const T& t + const T& val ) { - UList<T>::operator=(t); + UList<T>::operator=(val); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= ( - const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst + const zero ) { - if (this == &lst) - { - FatalErrorInFunction - << "Attempted assignment to self" << abort(FatalError); - } + UList<T>::operator=(Zero); +} - if (capacity_ >= lst.size()) - { - // Can copy w/o reallocating, match initial size to avoid reallocation - List<T>::size(lst.size()); - List<T>::operator=(lst); - } - else - { - // Make everything available for the copy operation - List<T>::size(capacity_); - List<T>::operator=(lst); - capacity_ = List<T>::size(); - } +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= +( + const UList<T>& lst +) +{ + assignDynList(lst); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +template<unsigned FixedSize> +inline void Foam::DynamicList<T, SizeMin>::operator= ( - const UList<T>& lst + const FixedList<T, FixedSize>& lst ) { - if (capacity_ >= lst.size()) - { - // Can copy w/o reallocating, match initial size to avoid reallocation - List<T>::size(lst.size()); - List<T>::operator=(lst); - } - else - { - // Make everything available for the copy operation - List<T>::size(capacity_); + setSize(lst.size()); - List<T>::operator=(lst); - capacity_ = List<T>::size(); + forAll(lst, i) + { + this->operator[](i) = lst[i]; } } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= ( - std::initializer_list<T> lst + const DynamicList<T, SizeMin>& lst ) { - if (capacity_ >= lst.size()) + if (this == &lst) { - // Can copy w/o reallocating, match initial size to avoid reallocation - List<T>::size(lst.size()); - List<T>::operator=(lst); + FatalErrorInFunction + << "Attempted assignment to self" << abort(FatalError); } - else - { - // Make everything available for the copy operation - List<T>::size(capacity_); - List<T>::operator=(lst); - capacity_ = List<T>::size(); - } + assignDynList(lst); +} + + +template<class T, int SizeMin> +template<int SizeMin2> +inline void Foam::DynamicList<T, SizeMin>::operator= +( + const DynamicList<T, SizeMin2>& lst +) +{ + assignDynList(lst); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= +( + std::initializer_list<T> lst +) +{ + assignDynList(lst); +} + + +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= ( const UIndirectList<T>& lst ) { - if (capacity_ >= lst.size()) + assignDynList(lst); +} + + +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= +( + List<T>&& lst +) +{ + clear(); + transfer(lst); +} + + +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= +( + DynamicList<T, SizeMin>&& lst +) +{ + if (this == &lst) { - // Can copy w/o reallocating, match initial size to avoid reallocation - List<T>::size(lst.size()); - List<T>::operator=(lst); + FatalErrorInFunction + << "Attempted assignment to self" << abort(FatalError); } - else - { - // Make everything available for the copy operation - List<T>::size(capacity_); - List<T>::operator=(lst); - capacity_ = List<T>::size(); - } + clear(); + transfer(lst); } -// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * // - -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -typename Foam::UList<T>::iterator -Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::erase +template<class T, int SizeMin> +template<int SizeMin2> +inline void Foam::DynamicList<T, SizeMin>::operator= ( - typename UList<T>::iterator curIter + DynamicList<T, SizeMin2>&& lst ) { - typename Foam::UList<T>::iterator iter = curIter; - typename Foam::UList<T>::iterator nextIter = curIter; + clear(); + transfer(lst); +} - if (iter != this->end()) - { - ++iter; - while (iter != this->end()) - { - *nextIter++ = *iter++; - } +template<class T, int SizeMin> +inline void Foam::DynamicList<T, SizeMin>::operator= +( + SortableList<T>&& lst +) +{ + clear(); + transfer(lst); +} - this->setSize(this->size() - 1); - } - return curIter; +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template<class T, int SizeMin1, int SizeMin2> +inline void Foam::Swap(DynamicList<T, SizeMin1>& a, DynamicList<T, SizeMin2>& b) +{ + a.swap(b); } diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C index 19163402da0..2a10efe4116 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,19 +26,85 @@ License #include "FixedList.H" #include "ListLoopM.H" -// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class T, unsigned Size> -void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& a) +Foam::label Foam::FixedList<T, Size>::find +( + const T& val, + const label start +) const { - List_ACCESS(T, (*this), vp); - List_ACCESS(T, a, ap); - T tmp; - List_FOR_ALL((*this), i) + if (start >= 0) { - tmp = List_CELEM((*this), vp, i); - List_ELEM((*this), vp, i) = List_CELEM(a, ap, i); - List_ELEM(a, ap, i) = tmp; + List_CONST_ACCESS(T, *this, lst); + + for (label i = start; i < label(Size); ++i) + { + if (lst[i] == val) + { + return i; + } + } + } + + return -1; +} + + +template<class T, unsigned Size> +void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& lst) +{ + Foam::Swap(v_, lst.v_); +} + + +template<class T, unsigned Size> +void Foam::FixedList<T, Size>::moveFirst(const label i) +{ + checkIndex(i); + + for (label lower = 0; lower < i; ++lower) + { + Foam::Swap(v_[lower], v_[i]); + } +} + + +template<class T, unsigned Size> +void Foam::FixedList<T, Size>::moveLast(const label i) +{ + checkIndex(i); + + for (label upper = label(Size - 1); upper > i; --upper) + { + Foam::Swap(v_[i], v_[upper]); + } +} + + +template<class T, unsigned Size> +void Foam::FixedList<T, Size>::swapFirst(const label i) +{ + checkIndex(i); + + if (i > 0) + { + Foam::Swap(v_[0], v_[i]); + } +} + + +template<class T, unsigned Size> +void Foam::FixedList<T, Size>::swapLast(const label i) +{ + checkIndex(i); + + const label upper = label(Size - 1); + + if (i < upper) + { + Foam::Swap(v_[i], v_[upper]); } } @@ -53,9 +119,9 @@ bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& a) const List_CONST_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, (a), ap); - List_FOR_ALL((*this), i) + for (unsigned i = 0; i < Size; ++i) { - equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i)); + equal = (vp[i] == ap[i]); if (!equal) break; } @@ -73,8 +139,8 @@ bool Foam::FixedList<T, Size>::operator!=(const FixedList<T, Size>& a) const template<class T, unsigned Size> bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& a) const { - const T* const __restrict__ ptr1 = this->begin(); - const T* const __restrict__ ptr2 = a.begin(); + List_CONST_ACCESS(T, *this, ptr1); + List_CONST_ACCESS(T, a, ptr2); for (unsigned i=0; i<Size; ++i) { diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index dce2cad0c63..8db0275bd4d 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -42,6 +42,8 @@ SourceFiles #include "uLabel.H" #include "Hash.H" #include "autoPtr.H" +#include "Swap.H" + #include <type_traits> #include <initializer_list> @@ -125,11 +127,17 @@ public: inline FixedList(); //- Construct from value - explicit inline FixedList(const T& t); + explicit inline FixedList(const T& val); //- Construct from C-array explicit inline FixedList(const T lst[Size]); + //- Copy constructor + inline FixedList(const FixedList<T, Size>& lst); + + //- Move constructor + inline FixedList(FixedList<T, Size>&& lst); + //- Construct given begin/end iterators // Uses std::distance when verifying the size. template<class InputIterator> @@ -144,9 +152,6 @@ public: //- Construct from SLList explicit inline FixedList(const SLList<T>& lst); - //- Copy constructor - inline FixedList(const FixedList<T, Size>& lst); - //- Construct from Istream FixedList(Istream& is); @@ -158,14 +163,26 @@ public: // Access - //- Return the forward circular index, i.e. the next index + //- Return the forward circular index, i.e. next index // which returns to the first at the end of the list inline label fcIndex(const label i) const; - //- Return the reverse circular index, i.e. the previous index + //- Return forward circular value (ie, next value in the list) + inline const T& fcValue(const label i) const; + + //- Return forward circular value (ie, next value in the list) + inline T& fcValue(const label i); + + //- Return the reverse circular index, i.e. previous index // which returns to the last at the beginning of the list inline label rcIndex(const label i) const; + //- Return reverse circular value (ie, previous value in the list) + inline const T& rcValue(const label i) const; + + //- Return reverse circular value (ie, previous value in the list) + inline T& rcValue(const label i); + //- Return a const pointer to the first data element, // similar to the STL front() method and the string::data() method @@ -202,19 +219,42 @@ public: inline void checkIndex(const label i) const; + // Search + + //- Find index of the first occurence of the value. + // Linear search. + // \return -1 if not found. + label find(const T& val, const label start=0) const; + + //- True if the value if found in the list. Linear search. + inline bool found(const T& val, const label start=0) const; + + // Edit - //- Dummy resize function - // needed to make FixedList consistent with List - inline void resize(const label s); + //- Dummy resize function + // needed to make FixedList consistent with List + inline void resize(const label s); + + //- Dummy setSize function + // needed to make FixedList consistent with List + inline void setSize(const label s); + + //- Move element to the first position. + void moveFirst(const label i); + + //- Move element to the last position. + void moveLast(const label i); + + //- Swap element with the first element. Fatal on an empty list. + void swapFirst(const label i); - //- Dummy setSize function - // needed to make FixedList consistent with List - inline void setSize(const label s); + //- Swap element with the last element. Fatal on an empty list. + void swapLast(const label i); - //- Copy (not transfer) the argument contents - // needed to make FixedList consistent with List - void transfer(const FixedList<T, Size>& lst); + //- Copy (not transfer) the argument contents + // needed to make FixedList consistent with List + void transfer(const FixedList<T, Size>& lst); // Member operators @@ -238,7 +278,13 @@ public: inline void operator=(std::initializer_list<T> lst); //- Assignment of all entries to the given value - inline void operator=(const T& t); + inline void operator=(const T& val); + + //- Copy assignment + inline void operator=(const FixedList<T, Size>& lst); + + //- Move assignment + inline void operator=(FixedList<T, Size>&& lst); // STL type definitions @@ -333,14 +379,14 @@ public: //- Always false since zero-sized FixedList is compile-time disabled. inline bool empty() const; - //- Swap two FixedLists of the same type in constant time - void swap(FixedList<T, Size>& a); + //- Swap content with another FixedList of the same type. + void swap(FixedList<T, Size>& lst); // STL member operators //- Equality operation on FixedLists of the same type. - // Returns true when the FixedLists are elementwise equal + // Returns true when the FixedLists are element-wise equal // (using FixedList::value_type::operator==). Takes linear time bool operator==(const FixedList<T, Size>& a) const; @@ -388,6 +434,13 @@ public: }; +// Global Functions + +// Exchange contents of lists - see FixedList::swap(). +template<class T, unsigned Size> +inline void Swap(FixedList<T,Size>& a, FixedList<T,Size>& b); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index 1df4fb958a0..c9554231f45 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,9 @@ License #include "SLList.H" #include "contiguous.H" +#include <type_traits> +#include <utility> + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class T, unsigned Size> @@ -35,11 +38,11 @@ inline Foam::FixedList<T, Size>::FixedList() template<class T, unsigned Size> -inline Foam::FixedList<T, Size>::FixedList(const T& t) +inline Foam::FixedList<T, Size>::FixedList(const T& val) { for (unsigned i=0; i<Size; ++i) { - v_[i] = t; + v_[i] = val; } } @@ -54,6 +57,29 @@ inline Foam::FixedList<T, Size>::FixedList(const T lst[Size]) } +template<class T, unsigned Size> +inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& lst) +{ + for (unsigned i=0; i<Size; ++i) + { + v_[i] = lst[i]; + } +} + + +template<class T, unsigned Size> +inline Foam::FixedList<T, Size>::FixedList(FixedList<T, Size>&& lst) +{ + // No significant speedup observed for copy assignment on simple types, + // use move assignment for generality with more complex types + + for (unsigned i=0; i<Size; ++i) + { + v_[i] = std::move(lst.v_[i]); + } +} + + template<class T, unsigned Size> template<class InputIterator> Foam::FixedList<T, Size>::FixedList @@ -113,16 +139,6 @@ inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& lst) } -template<class T, unsigned Size> -inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& lst) -{ - for (unsigned i=0; i<Size; ++i) - { - v_[i] = lst[i]; - } -} - - template<class T, unsigned Size> inline Foam::autoPtr<Foam::FixedList<T, Size>> Foam::FixedList<T, Size>::clone() const @@ -147,6 +163,20 @@ inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const } +template<class T, unsigned Size> +inline const T& Foam::FixedList<T, Size>::fcValue(const label i) const +{ + return this->operator[](this->fcIndex(i)); +} + + +template<class T, unsigned Size> +inline T& Foam::FixedList<T, Size>::fcValue(const label i) +{ + return this->operator[](this->fcIndex(i)); +} + + template<class T, unsigned Size> inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const { @@ -154,6 +184,20 @@ inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const } +template<class T, unsigned Size> +inline const T& Foam::FixedList<T, Size>::rcValue(const label i) const +{ + return this->operator[](this->rcIndex(i)); +} + + +template<class T, unsigned Size> +inline T& Foam::FixedList<T, Size>::rcValue(const label i) +{ + return this->operator[](this->rcIndex(i)); +} + + template<class T, unsigned Size> inline void Foam::FixedList<T, Size>::checkStart(const label start) const { @@ -190,6 +234,17 @@ inline void Foam::FixedList<T, Size>::checkIndex(const label i) const } +template<class T, unsigned Size> +inline bool Foam::FixedList<T, Size>::found +( + const T& val, + const label start +) const +{ + return (this->find(val, start) >= 0); +} + + template<class T, unsigned Size> inline void Foam::FixedList<T, Size>::resize(const label s) { @@ -206,6 +261,7 @@ inline void Foam::FixedList<T, Size>::setSize(const label s) #endif } + template<class T, unsigned Size> inline void Foam::FixedList<T, Size>::transfer(const FixedList<T, Size>& lst) { @@ -329,11 +385,31 @@ inline void Foam::FixedList<T, Size>::operator=(std::initializer_list<T> lst) } template<class T, unsigned Size> -inline void Foam::FixedList<T, Size>::operator=(const T& t) +inline void Foam::FixedList<T, Size>::operator=(const T& val) { for (unsigned i=0; i<Size; ++i) { - v_[i] = t; + v_[i] = val; + } +} + +template<class T, unsigned Size> +inline void Foam::FixedList<T, Size>::operator=(const FixedList<T, Size>& lst) +{ + for (unsigned i=0; i<Size; ++i) + { + v_[i] = lst.v_[i]; + } +} + +template<class T, unsigned Size> +inline void Foam::FixedList<T, Size>::operator=(FixedList<T, Size>&& lst) +{ + // No significant speedup observed for copy assignment on simple types, + // use move assignment for generality with more complex types + for (unsigned i=0; i<Size; ++i) + { + v_[i] = std::move(lst.v_[i]); } } @@ -485,4 +561,13 @@ inline unsigned Foam::FixedList<T, Size>::Hash<HashT>::operator() } +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template<class T, unsigned Size> +void Foam::Swap(FixedList<T, Size>& a, FixedList<T, Size>& b) +{ + a.swap(b); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H index a320682a60e..aa6c222ec26 100644 --- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H +++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,10 +62,10 @@ class IndirectListAddressing // Private Member Functions //- Disallow default bitwise copy construct - IndirectListAddressing(const IndirectListAddressing&); + IndirectListAddressing(const IndirectListAddressing&) = delete; //- Disallow default bitwise assignment - void operator=(const IndirectListAddressing&); + void operator=(const IndirectListAddressing&) = delete; protected: @@ -81,16 +81,16 @@ protected: // Member Functions - // Access + // Access - //- Return the list addressing - inline const List<label>& addressing() const; + //- Return the list addressing + inline const List<label>& addressing() const; - // Edit + // Edit - //- Reset addressing - inline void resetAddressing(const labelUList&); - inline void resetAddressing(const Xfer<List<label>>&); + //- Reset addressing + inline void resetAddressing(const labelUList& addr); + inline void resetAddressing(const Xfer<List<label>>& addr); }; @@ -108,10 +108,10 @@ class IndirectList // Private Member Functions //- Disallow default assignment operator - void operator=(const IndirectList<T>&); + void operator=(const IndirectList<T>&) = delete; //- Disallow assignment from UIndirectList - void operator=(const UIndirectList<T>&); + void operator=(const UIndirectList<T>&) = delete; public: @@ -119,37 +119,45 @@ public: // Constructors //- Construct given the complete list and the addressing array - inline IndirectList(const UList<T>&, const labelUList&); + inline IndirectList + ( + const UList<T>& completeList, + const labelUList& addr + ); //- Construct given the complete list and by transferring addressing - inline IndirectList(const UList<T>&, const Xfer<List<label>>&); + inline IndirectList + ( + const UList<T>& completeList, + const Xfer<List<label>>& addr + ); //- Copy constructor - inline IndirectList(const IndirectList<T>&); + inline IndirectList(const IndirectList<T>& lst); //- Construct from UIndirectList - explicit inline IndirectList(const UIndirectList<T>&); + explicit inline IndirectList(const UIndirectList<T>& lst); // Member Functions + // Access - // Access + //- Return the list addressing + using UIndirectList<T>::addressing; - //- Return the list addressing - using UIndirectList<T>::addressing; + // Edit - // Edit + //- Reset addressing + using IndirectListAddressing::resetAddressing; - //- Reset addressing - using IndirectListAddressing::resetAddressing; + // Member Operators - // Member Operators + //- Assignment operator + using UIndirectList<T>::operator=; - //- Assignment operator - using UIndirectList<T>::operator=; }; diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H index 068b38ed9d2..1558c3a6611 100644 --- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H +++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H @@ -25,7 +25,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - inline Foam::IndirectListAddressing::IndirectListAddressing ( const labelUList& addr diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 04f731f2119..556de7b6f35 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -33,6 +33,8 @@ License #include "BiIndirectList.H" #include "contiguous.H" +#include <utility> + // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // template<class T> @@ -52,7 +54,7 @@ Foam::List<T>::List(const label s) template<class T> -Foam::List<T>::List(const label s, const T& a) +Foam::List<T>::List(const label s, const T& val) : UList<T>(nullptr, s) { @@ -70,7 +72,7 @@ Foam::List<T>::List(const label s, const T& a) List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = a; + vp[i] = val; } } } @@ -95,7 +97,7 @@ Foam::List<T>::List(const label s, const zero) List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = Zero; + vp[i] = Zero; } } } @@ -122,7 +124,7 @@ Foam::List<T>::List(const List<T>& a) List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); + vp[i] = ap[i]; } } } @@ -143,19 +145,12 @@ Foam::List<T>::List(const List<T2>& a) List_CONST_ACCESS(T2, a, ap); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = T(List_ELEM(a, ap, i)); + vp[i] = T(ap[i]); } } } -template<class T> -Foam::List<T>::List(const Xfer<List<T>>& lst) -{ - transfer(lst()); -} - - template<class T> Foam::List<T>::List(List<T>& a, bool reuse) : @@ -163,6 +158,7 @@ Foam::List<T>::List(List<T>& a, bool reuse) { if (reuse) { + // swap content this->v_ = a.v_; a.v_ = nullptr; a.size_ = 0; @@ -183,7 +179,7 @@ Foam::List<T>::List(List<T>& a, bool reuse) List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); + vp[i] = ap[i]; } } } @@ -191,19 +187,20 @@ Foam::List<T>::List(List<T>& a, bool reuse) template<class T> -Foam::List<T>::List(const UList<T>& a, const labelUList& mapAddressing) +Foam::List<T>::List(const UList<T>& lst, const labelUList& mapAddressing) : UList<T>(nullptr, mapAddressing.size()) { if (this->size_) { - // Note: cannot use List_ELEM since third argument has to be index. - alloc(); - forAll(*this, i) + List_ACCESS(T, (*this), vp); + + const label len = (*this).size(); + for (label i=0; i < len; ++i) { - this->operator[](i) = a[mapAddressing[i]]; + vp[i] = lst[mapAddressing[i]]; } } } @@ -268,6 +265,42 @@ Foam::List<T>::List(std::initializer_list<T> lst) {} +template<class T> +Foam::List<T>::List(const Xfer<List<T>>& lst) +{ + transfer(lst()); +} + + +template<class T> +Foam::List<T>::List(List<T>&& lst) +: + UList<T>(nullptr, 0) +{ + // Can use transfer or swap to manage content + transfer(lst); +} + + +template<class T> +template<int SizeMin> +Foam::List<T>::List(DynamicList<T, SizeMin>&& lst) +: + UList<T>(nullptr, 0) +{ + transfer(lst); +} + + +template<class T> +Foam::List<T>::List(SortableList<T>&& lst) +: + UList<T>(nullptr, 0) +{ + transfer(lst); +} + + // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // template<class T> @@ -298,21 +331,24 @@ void Foam::List<T>::setSize(const label newSize) { T* nv = new T[label(newSize)]; - if (this->size_) - { - label i = min(this->size_, newSize); + const label overlap = min(this->size_, newSize); + if (overlap) + { #ifdef USEMEMCPY if (contiguous<T>()) { - memcpy(nv, this->v_, i*sizeof(T)); + memcpy(nv, this->v_, overlap*sizeof(T)); } else #endif { - T* vv = &this->v_[i]; - T* av = &nv[i]; - while (i--) *--av = *--vv; + // No speedup observed for copy assignment on simple types + List_ACCESS(T, *this, vp); + for (label i = 0; i < overlap; ++i) + { + nv[i] = std::move(vp[i]); + } } } @@ -329,49 +365,51 @@ void Foam::List<T>::setSize(const label newSize) template<class T> -void Foam::List<T>::setSize(const label newSize, const T& a) +void Foam::List<T>::setSize(const label newSize, const T& val) { const label oldSize = label(this->size_); this->setSize(newSize); - if (newSize > oldSize) + List_ACCESS(T, *this, vp); + for (label i = oldSize; i < newSize; ++i) { - label i = newSize - oldSize; - T* vv = &this->v_[newSize]; - while (i--) *--vv = a; + vp[i] = val; } } template<class T> -void Foam::List<T>::transfer(List<T>& a) +void Foam::List<T>::transfer(List<T>& lst) { + // Clear and swap - could also check for self assignment clear(); - this->size_ = a.size_; - this->v_ = a.v_; + this->size_ = lst.size_; + this->v_ = lst.v_; - a.size_ = 0; - a.v_ = nullptr; + lst.size_ = 0; + lst.v_ = nullptr; } template<class T> -template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a) +template<int SizeMin> +void Foam::List<T>::transfer(DynamicList<T, SizeMin>& lst) { // Shrink the allocated space to the number of elements used - a.shrink(); - transfer(static_cast<List<T>&>(a)); - a.clearStorage(); + lst.shrink(); + transfer(static_cast<List<T>&>(lst)); + + // Ensure DynamicList has proper capacity=0 too + lst.clearStorage(); } template<class T> -void Foam::List<T>::transfer(SortableList<T>& a) +void Foam::List<T>::transfer(SortableList<T>& lst) { // Shrink away the sort indices - a.shrink(); - transfer(static_cast<List<T>&>(a)); + lst.shrink(); + transfer(static_cast<List<T>&>(lst)); } @@ -396,7 +434,7 @@ void Foam::List<T>::operator=(const UList<T>& a) List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); + vp[i] = ap[i]; } } } @@ -404,16 +442,16 @@ void Foam::List<T>::operator=(const UList<T>& a) template<class T> -void Foam::List<T>::operator=(const List<T>& a) +void Foam::List<T>::operator=(const List<T>& lst) { - if (this == &a) + if (this == &lst) { FatalErrorInFunction << "attempted assignment to self" << abort(FatalError); } - operator=(static_cast<const UList<T>&>(a)); + operator=(static_cast<const UList<T>&>(lst)); } @@ -454,12 +492,40 @@ void Foam::List<T>::operator=(std::initializer_list<T> lst) { reAlloc(lst.size()); - auto iter = lst.begin(); - forAll(*this, i) + label i = 0; + for (const auto& val : lst) + { + this->operator[](i++) = val; + } +} + + +template<class T> +void Foam::List<T>::operator=(List<T>&& lst) +{ + if (this == &lst) { - this->operator[](i) = *iter; - ++iter; + FatalErrorInFunction + << "attempted assignment to self" + << abort(FatalError); } + + transfer(lst); +} + + +template<class T> +template<int SizeMin> +void Foam::List<T>::operator=(DynamicList<T, SizeMin>&& lst) +{ + transfer(lst); +} + + +template<class T> +void Foam::List<T>::operator=(SortableList<T>&& lst) +{ + transfer(lst); } diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index c8e3219d992..d4ff38d488b 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,8 +68,7 @@ template<class LListBase, class T> class LList; template<class T> using SLList = LList<SLListBase, T>; -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -class DynamicList; +template<class T, int SizeMin> class DynamicList; template<class T> class SortableList; template<class T> class IndirectList; @@ -136,26 +135,25 @@ public: explicit List(const label s); //- Construct with given size and value for all elements - List(const label s, const T& a); + List(const label s, const T& val); //- Construct with given size initializing all elements to zero List(const label s, const zero); - //- Copy constructor + //- Copy constructor from list List(const List<T>& a); - //- Copy constructor from list containing another type + //- Copy constructor from list containing another type. + // This is primarily useful to convert a list of ints into floats, + // for example. template<class T2> explicit List(const List<T2>& a); - //- Construct by transferring the parameter contents - List(const Xfer<List<T>>& lst); - //- Construct as copy or re-use as specified List(List<T>& a, bool reuse); //- Construct as subset - List(const UList<T>& a, const labelUList& mapAddressing); + List(const UList<T>& lst, const labelUList& mapAddressing); //- Construct given begin/end iterators. // Uses std::distance to determine the size. @@ -181,6 +179,19 @@ public: //- Construct from an initializer list List(std::initializer_list<T> lst); + //- Transfer (move) construct + List(const Xfer<List<T>>& lst); + + //- Move construct from List + List(List<T>&& lst); + + //- Move construct from DynamicList + template<int SizeMin> + List(DynamicList<T, SizeMin>&& lst); + + //- Move construct from SortableList + List(SortableList<T>&& lst); + //- Construct from Istream List(Istream& is); @@ -210,19 +221,19 @@ public: inline void resize(const label newSize); //- Alias for setSize(const label, const T&) - inline void resize(const label newSize, const T& a); + inline void resize(const label newSize, const T& val); //- Reset size of List void setSize(const label newSize); //- Reset size of List and value for new elements - void setSize(const label newSize, const T& a); + void setSize(const label newSize, const T& val); //- Clear the list, i.e. set size to zero inline void clear(); //- Append an element at the end of the list - inline void append(const T& t); + inline void append(const T& val); //- Append a List at the end of this list inline void append(const UList<T>& lst); @@ -232,16 +243,16 @@ public: //- Transfer the contents of the argument List into this list // and annul the argument list - void transfer(List<T>& a); + void transfer(List<T>& lst); //- Transfer the contents of the argument List into this list // and annul the argument list - template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> - void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a); + template<int SizeMin> + void transfer(DynamicList<T, SizeMin>& lst); //- Transfer the contents of the argument List into this list // and annul the argument list - void transfer(SortableList<T>& a); + void transfer(SortableList<T>& lst); //- Transfer contents to the Xfer container inline Xfer<List<T>> xfer(); @@ -261,7 +272,7 @@ public: void operator=(const UList<T>& a); //- Assignment operator. Takes linear time - void operator=(const List<T>& a); + void operator=(const List<T>& lst); //- Assignment to SLList operator. Takes linear time void operator=(const SLList<T>& lst); @@ -276,11 +287,21 @@ public: void operator=(std::initializer_list<T> lst); //- Assignment of all entries to the given value - inline void operator=(const T& t); + inline void operator=(const T& val); //- Assignment of all entries to zero inline void operator=(const zero); + //- Move assignment. Takes constant time + void operator=(List<T>&& lst); + + //- Move assignment. Takes constant time. + template<int SizeMin> + void operator=(DynamicList<T, SizeMin>&& lst); + + //- Move assignment. Takes constant time. + void operator=(SortableList<T>&& lst); + // Istream operator diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H index 8aa5bc016aa..d3549e131b1 100644 --- a/src/OpenFOAM/containers/Lists/List/ListI.H +++ b/src/OpenFOAM/containers/Lists/List/ListI.H @@ -89,7 +89,7 @@ inline Foam::List<T>::List alloc(); InputIterator iter = begIter; - forAll(*this, i) + for (label i = 0; i < s; ++i) { this->operator[](i) = *iter; ++iter; @@ -142,9 +142,9 @@ inline void Foam::List<T>::resize(const label newSize) template<class T> -inline void Foam::List<T>::resize(const label newSize, const T& a) +inline void Foam::List<T>::resize(const label newSize, const T& val) { - this->setSize(newSize, a); + this->setSize(newSize, val); } @@ -182,9 +182,9 @@ inline Foam::Xfer<Foam::List<T>> Foam::List<T>::xfer() template<class T> -inline void Foam::List<T>::append(const T& t) +inline void Foam::List<T>::append(const T& val) { - setSize(size()+1, t); + setSize(size()+1, val); } @@ -223,9 +223,9 @@ inline void Foam::List<T>::append(const UIndirectList<T>& lst) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T> -inline void Foam::List<T>::operator=(const T& t) +inline void Foam::List<T>::operator=(const T& val) { - UList<T>::operator=(t); + UList<T>::operator=(val); } diff --git a/src/OpenFOAM/containers/Lists/List/ListLoopM.H b/src/OpenFOAM/containers/Lists/List/ListLoopM.H index 5f74321bc66..3a9b341837c 100644 --- a/src/OpenFOAM/containers/Lists/List/ListLoopM.H +++ b/src/OpenFOAM/containers/Lists/List/ListLoopM.H @@ -26,53 +26,26 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef ListLoop_H -#define ListLoop_H +#ifndef ListLoopM_H +#define ListLoopM_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Element access looping -#ifdef vectorMachine - -// Element access looping using [] for vector machines - -#define List_FOR_ALL(f, i) \ - const label _n##i = (f).size(); \ - for (label i=0; i<_n##i; ++i) - -// Provide current element -#define List_CELEM(f, fp, i) (fp[i]) - -// Provide current element -#define List_ELEM(f, fp, i) (fp[i]) - -#define List_ACCESS(type, f, fp) \ +// Initial non-const access to list +#define List_ACCESS(type, f, fp) \ type* const __restrict__ fp = (f).begin() -#define List_CONST_ACCESS(type, f, fp) \ +// Initial const access to list +#define List_CONST_ACCESS(type, f, fp) \ const type* const __restrict__ fp = (f).begin() -#else - -// Pointer looping for scalar machines - #define List_FOR_ALL(f, i) \ - label i = (f).size(); \ - while (i--) - -// Provide current element without incrementing pointer -#define List_CELEM(f, fp, i) (*fp) - -// Provide current element and increment pointer -#define List_ELEM(f, fp, i) (*fp++) - -#define List_ACCESS(type, f, fp) \ - type* __restrict__ fp = (f).begin() - -#define List_CONST_ACCESS(type, f, fp) \ - const type* __restrict__ fp = (f).begin() - -#endif + const label _n##i = (f).size(); \ + for (label i=0; i<_n##i; ++i) +// Current element (non-const access) +#define List_ELEM(fp, i) (fp[i]) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index bf5af3080db..641aa4ade0e 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -890,7 +890,7 @@ void Foam::inplaceReverseList(ListType& list) label elemI = 0; while (elemI < nIterations) { - Swap(list[elemI], list[lastIndex - elemI]); + Foam::Swap(list[elemI], list[lastIndex - elemI]); elemI++; } diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C index a35334507aa..fac433d7d75 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,43 +33,60 @@ inline Foam::SortableList<T>::SortableList() template<class T> -Foam::SortableList<T>::SortableList(const UList<T>& values) +inline Foam::SortableList<T>::SortableList(const label size) : - List<T>(values) -{ - sort(); -} + List<T>(size) +{} template<class T> -Foam::SortableList<T>::SortableList(const Xfer<List<T>>& values) +inline Foam::SortableList<T>::SortableList(const label size, const T& val) : - List<T>(values) -{ - sort(); -} + List<T>(size, val) +{} template<class T> -inline Foam::SortableList<T>::SortableList(const label size) +inline Foam::SortableList<T>::SortableList(const SortableList<T>& lst) : - List<T>(size) + List<T>(lst), + indices_(lst.indices()) {} template<class T> -inline Foam::SortableList<T>::SortableList(const label size, const T& val) +inline Foam::SortableList<T>::SortableList(SortableList<T>&& lst) : - List<T>(size, val) + List<T>(std::move(lst)), + indices_(std::move(lst.indices_)) {} template<class T> -Foam::SortableList<T>::SortableList(const SortableList<T>& lst) +Foam::SortableList<T>::SortableList(const UList<T>& values) : - List<T>(lst), - indices_(lst.indices()) -{} + List<T>(values) +{ + sort(); +} + + +template<class T> +Foam::SortableList<T>::SortableList(List<T>&& values) +: + List<T>(std::move(values)) +{ + sort(); +} + + +template<class T> +Foam::SortableList<T>::SortableList(const Xfer<List<T>>& values) +: + List<T>(values) +{ + sort(); +} template<class T> @@ -97,7 +114,6 @@ Foam::SortableList<T>::SortableList(std::initializer_list<T> values) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - template<class T> void Foam::SortableList<T>::clear() { @@ -119,12 +135,7 @@ void Foam::SortableList<T>::sort() { sortedOrder(*this, indices_); - List<T> lst(this->size()); - forAll(indices_, i) - { - lst[i] = this->operator[](indices_[i]); - } - + List<T> lst(*this, indices_); // Copy with indices for mapping List<T>::transfer(lst); } @@ -134,16 +145,18 @@ void Foam::SortableList<T>::reverseSort() { sortedOrder(*this, indices_, typename UList<T>::greater(*this)); - List<T> lst(this->size()); - forAll(indices_, i) - { - lst[i] = this->operator[](indices_[i]); - } - + List<T> lst(*this, indices_); // Copy with indices for mapping List<T>::transfer(lst); } +template<class T> +void Foam::SortableList<T>::swap(SortableList<T>& lst) +{ + List<T>::swap(lst); + indices_.swap(lst.indices_); +} + template<class T> Foam::Xfer<Foam::List<T>> Foam::SortableList<T>::xfer() { @@ -156,6 +169,7 @@ Foam::Xfer<Foam::List<T>> Foam::SortableList<T>::xfer() template<class T> inline void Foam::SortableList<T>::operator=(const T& val) { + indices_.clear(); UList<T>::operator=(val); } @@ -163,8 +177,8 @@ inline void Foam::SortableList<T>::operator=(const T& val) template<class T> inline void Foam::SortableList<T>::operator=(const UList<T>& lst) { - List<T>::operator=(lst); indices_.clear(); + List<T>::operator=(lst); } @@ -176,6 +190,22 @@ inline void Foam::SortableList<T>::operator=(const SortableList<T>& lst) } +template<class T> +inline void Foam::SortableList<T>::operator=(List<T>&& lst) +{ + indices_.clear(); + List<T>::operator=(std::move(lst)); +} + + +template<class T> +inline void Foam::SortableList<T>::operator=(SortableList<T>&& lst) +{ + clear(); + this->swap(lst); +} + + template<class T> inline void Foam::SortableList<T>::operator=(std::initializer_list<T> lst) { @@ -184,4 +214,13 @@ inline void Foam::SortableList<T>::operator=(std::initializer_list<T> lst) } +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template<class T> +inline void Foam::Swap(SortableList<T>& a, SortableList<T>& b) +{ + a.swap(b); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H index cd005a09c2f..8ef6aefa197 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,13 +67,7 @@ public: //- Null constructor, sort later (eg, after assignment or transfer) inline SortableList(); - //- Construct from UList, sorting immediately - explicit SortableList(const UList<T>& values); - - //- Construct from transferred List, sorting immediately - explicit SortableList(const Xfer<List<T>>& values); - - //- Construct given size. Sort later on + //- Construct given size, sort later. // The indices remain empty until the list is sorted explicit inline SortableList(const label size); @@ -81,17 +75,29 @@ public: // The indices remain empty until the list is sorted inline SortableList(const label size, const T& val); + //- Copy construct + inline SortableList(const SortableList<T>& lst); + + //- Move construct + inline SortableList(SortableList<T>&& lst); + + //- Copy construct from UList, sorting immediately + explicit SortableList(const UList<T>& values); + + //- Move construct from List, sorting immediately + SortableList(List<T>&& values); + //- Construct given begin/end iterators. // Uses std::distance to determine the size. template<class InputIterator> inline SortableList(InputIterator begIter, InputIterator endIter); - //- Construct as copy - inline SortableList(const SortableList<T>& lst); - //- Construct from an initializer list, sorting immediately SortableList(std::initializer_list<T> values); + //- Construct from transferred List, sorting immediately + explicit SortableList(const Xfer<List<T>>& values); + // Member Functions @@ -120,26 +126,42 @@ public: //- Reverse (stable) sort the list void reverseSort(); + //- Swap content with another SortableList in constant time + inline void swap(SortableList<T>& lst); + //- Transfer contents to the Xfer container as a plain List inline Xfer<List<T>> xfer(); // Member Operators - //- Assignment of all entries to the given value + //- Assignment of all entries to the given value, removing indices. inline void operator=(const T& val); - //- Assignment to UList operator. Takes linear time + //- Assignment to UList operator, removing indices. Takes linear time inline void operator=(const UList<T>& lst); //- Assignment operator. Takes linear time inline void operator=(const SortableList<T>& lst); + //- Move assignment, removing indices. Takes linear time + inline void operator=(List<T>&& lst); + + //- Move operator. Takes linear time + inline void operator=(SortableList<T>&& lst); + //- Assignment to an initializer list void operator=(std::initializer_list<T> lst); }; +// Global Functions + +// Exchange contents of lists - see SortableList::swap(). +template<class T> +inline void Swap(SortableList<T>& a, SortableList<T>& b); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C new file mode 100644 index 00000000000..931e93efb11 --- /dev/null +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class T> +inline Foam::label Foam::UIndirectList<T>::find +( + const T& val, + const label start +) const +{ + if (start >= 0) + { + List_CONST_ACCESS(T, completeList_, lst); + List_CONST_ACCESS(label, addressing_, addr); + + const label len = addressing_.size(); + + for (label i = start; i < len; ++i) + { + if (lst[addr[i]] == val) + { + return i; + } + } + } + + return -1; +} + + +template<class T> +inline Foam::label Foam::UIndirectList<T>::rfind +( + const T& val, + const label pos +) const +{ + List_CONST_ACCESS(T, completeList_, lst); + List_CONST_ACCESS(label, addressing_, addr); + + for + ( + label i = + ( + pos < 0 + ? (addressing_.size()-1) + : min(pos, (addressing_.size()-1)) + ); + i >= 0; + --i + ) + { + if (lst[addr[i]] == val) + { + return i; + } + } + + return -1; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H index e39d899f899..61ddf3bed97 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H @@ -79,52 +79,70 @@ public: // Member Functions - // Access + // Access - //- Return the number of elements in the list - inline label size() const; + //- Return the number of elements in the list + inline label size() const; - //- Return true if the list is empty (ie, size() is zero). - inline bool empty() const; + //- Return true if the list is empty (ie, size() is zero). + inline bool empty() const; - //- Return the first element of the list. - inline T& first(); + //- Return the first element of the list. + inline T& first(); - //- Return first element of the list. - inline const T& first() const; + //- Return first element of the list. + inline const T& first() const; - //- Return the last element of the list. - inline T& last(); + //- Return the last element of the list. + inline T& last(); - //- Return the last element of the list. - inline const T& last() const; + //- Return the last element of the list. + inline const T& last() const; - //- Return the complete list - inline const UList<T>& completeList() const; + //- Return the complete list + inline const UList<T>& completeList() const; - //- Return the list addressing - inline const List<label>& addressing() const; + //- Return the list addressing + inline const List<label>& addressing() const; - // Member Operators + // Search - //- Return the addressed elements as a List - inline List<T> operator()() const; + //- Find index of the first occurence of the value. + // When start is specified, any occurences before start are ignored. + // Linear search. + // \return -1 if not found. + label find(const T& val, const label start=0) const; - //- Return non-const access to an element - inline T& operator[](const label i); + //- Find index of the last occurence of the value. + // When pos is specified, any occurences after pos are ignored. + // Linear search. + // \return -1 if not found. + label rfind(const T& val, const label pos=-1) const; - //- Return const access to an element - inline const T& operator[](const label i) const; + //- True if the value if found in the list. Linear search. + inline bool found(const T& val, const label start=0) const; - //- Assignment to UList of addressed elements - inline void operator=(const UList<T>& ae); - //- Assignment to UIndirectList of addressed elements - inline void operator=(const UIndirectList<T>& ae); + // Member Operators - //- Assignment of all entries to the given value - inline void operator=(const T& t); + //- Return the addressed elements as a List + inline List<T> operator()() const; + + //- Return non-const access to an element + inline T& operator[](const label i); + + //- Return const access to an element + inline const T& operator[](const label i) const; + + //- Assignment to UList of addressed elements + inline void operator=(const UList<T>& ae); + + //- Assignment to UIndirectList of addressed elements + inline void operator=(const UIndirectList<T>& ae); + + //- Assignment of all entries to the given value + inline void operator=(const T& t); // STL type definitions @@ -162,7 +180,7 @@ public: friend Ostream& operator<< <T> ( Ostream& os, - const UIndirectList<T>& L + const UIndirectList<T>& lst ); }; @@ -176,6 +194,7 @@ public: #include "UIndirectListI.H" #ifdef NoRepository + #include "UIndirectList.C" #include "UIndirectListIO.C" #endif diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H index c26efd9ac74..15daa10969f 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H @@ -95,6 +95,17 @@ inline const Foam::List<Foam::label>& Foam::UIndirectList<T>::addressing() const } +template<class T> +inline bool Foam::UIndirectList<T>::found +( + const T& val, + const label pos +) const +{ + return this->find(val, pos) != -1; +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T> diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C index 5e711c07241..de49fc74a0c 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C @@ -131,10 +131,10 @@ template<class T> Foam::Ostream& Foam::operator<< ( Foam::Ostream& os, - const Foam::UIndirectList<T>& L + const Foam::UIndirectList<T>& lst ) { - return L.writeList(os, 10); + return lst.writeList(os, 10); } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index 599dd0f9980..b87e524b593 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -49,18 +49,18 @@ Foam::labelRange Foam::UList<T>::validateRange(const labelRange& range) const template<class T> Foam::labelRange Foam::UList<T>::validateRange ( - std::initializer_list<label> start_size_pair + std::initializer_list<label> start_size ) const { - if (start_size_pair.size() != 2) + if (start_size.size() != 2) { FatalErrorInFunction - << "range specified with " << start_size_pair.size() + << "range specified with " << start_size.size() << " elements instead of 2" << abort(FatalError); } - auto iter = start_size_pair.begin(); + auto iter = start_size.begin(); const label beg = *(iter++); const label sz = *iter; @@ -71,6 +71,56 @@ Foam::labelRange Foam::UList<T>::validateRange // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template<class T> +void Foam::UList<T>::moveFirst(const label i) +{ + checkIndex(i); + + for (label lower = 0; lower < i; ++lower) + { + Foam::Swap(this->operator[](lower), this->operator[](i)); + } +} + + +template<class T> +void Foam::UList<T>::moveLast(const label i) +{ + checkIndex(i); + + for (label upper = size()-1; upper > i; --upper) + { + Foam::Swap(this->operator[](i), this->operator[](upper)); + } +} + + +template<class T> +void Foam::UList<T>::swapFirst(const label i) +{ + checkIndex(i); + + if (i > 0) + { + Foam::Swap(this->operator[](0), this->operator[](i)); + } +} + + +template<class T> +void Foam::UList<T>::swapLast(const label i) +{ + checkIndex(i); + + const label upper = size()-1; + + if (i < upper) + { + Foam::Swap(this->operator[](i), this->operator[](upper)); + } +} + + template<class T> void Foam::UList<T>::deepCopy(const UList<T>& a) { @@ -96,7 +146,7 @@ void Foam::UList<T>::deepCopy(const UList<T>& a) List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); + vp[i] = ap[i]; } } } @@ -126,10 +176,10 @@ const Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range) const template<class T> Foam::UList<T> Foam::UList<T>::operator[] ( - std::initializer_list<label> start_size_pair + std::initializer_list<label> start_size ) { - const labelRange slice = validateRange(start_size_pair); + const labelRange slice = validateRange(start_size); return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList } @@ -138,23 +188,23 @@ Foam::UList<T> Foam::UList<T>::operator[] template<class T> const Foam::UList<T> Foam::UList<T>::operator[] ( - std::initializer_list<label> start_size_range + std::initializer_list<label> start_size ) const { // Restricted range - const labelRange slice = validateRange(start_size_range); + const labelRange slice = validateRange(start_size); return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList } template<class T> -void Foam::UList<T>::operator=(const T& t) +void Foam::UList<T>::operator=(const T& val) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = t; + vp[i] = val; } } @@ -165,21 +215,11 @@ void Foam::UList<T>::operator=(const zero) List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) { - List_ELEM((*this), vp, i) = Zero; + vp[i] = Zero; } } -// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * // - -template<class T> -void Foam::UList<T>::swap(UList<T>& a) -{ - Swap(size_, a.size_); - Swap(v_, a.v_); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class T> @@ -197,6 +237,55 @@ std::streamsize Foam::UList<T>::byteSize() const } +template<class T> +Foam::label Foam::UList<T>::find(const T& val, const label start) const +{ + if (start >= 0) + { + List_CONST_ACCESS(T, (*this), vp); + + const label len = this->size(); + + for (label i = start; i < len; ++i) + { + if (vp[i] == val) + { + return i; + } + } + } + + return -1; +} + + +template<class T> +Foam::label Foam::UList<T>::rfind(const T& val, const label pos) const +{ + List_CONST_ACCESS(T, (*this), vp); + + for + ( + label i = + ( + pos < 0 + ? (this->size()-1) + : min(pos, this->size()-1) + ); + i >= 0; + --i + ) + { + if (vp[i] == val) + { + return i; + } + } + + return -1; +} + + template<class T> void Foam::sort(UList<T>& a) { @@ -248,7 +337,7 @@ bool Foam::UList<T>::operator==(const UList<T>& a) const List_FOR_ALL((*this), i) { - equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i)); + equal = (vp[i] == ap[i]); if (!equal) break; } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 6b58437b36f..23fee6ab040 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -48,6 +48,8 @@ SourceFiles #include "nullObject.H" #include "zero.H" #include "stdFoam.H" +#include "Swap.H" + #include <initializer_list> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -181,17 +183,28 @@ public: // Member Functions - // Access - //- Return the forward circular index, i.e. the next index + //- Return the forward circular index, i.e. next index // which returns to the first at the end of the list inline label fcIndex(const label i) const; - //- Return the reverse circular index, i.e. the previous index + //- Return forward circular value (ie, next value in the list) + inline const T& fcValue(const label i) const; + + //- Return forward circular value (ie, next value in the list) + inline T& fcValue(const label i); + + //- Return the reverse circular index, i.e. previous index // which returns to the last at the beginning of the list inline label rcIndex(const label i) const; + //- Return reverse circular value (ie, previous value in the list) + inline const T& rcValue(const label i) const; + + //- Return reverse circular value (ie, previous value in the list) + inline T& rcValue(const label i); + //- Return the binary size in number of characters of the UList // if the element is a primitive type // i.e. contiguous<T>() == true. @@ -234,6 +247,41 @@ public: inline void checkIndex(const label i) const; + // Search + + //- Find index of the first occurence of the value. + // When start is specified, any occurences before start are ignored. + // Linear search. + // \return -1 if not found. + label find(const T& val, const label start=0) const; + + //- Find index of the last occurence of the value. + // When pos is specified, any occurences after pos are ignored. + // Linear search. + // \return -1 if not found. + label rfind(const T& val, const label pos=-1) const; + + //- True if the value if found in the list. Linear search. + inline bool found(const T& val, const label start=0) const; + + + // Edit + + //- Move element to the first position. + void moveFirst(const label i); + + //- Move element to the last position. + void moveLast(const label i); + + //- Swap element with the first element. Fatal on an empty list. + void swapFirst(const label i); + + //- Swap element with the last element. Fatal on an empty list. + void swapLast(const label i); + + + // Copy + //- Copy the pointer held by the given UList inline void shallowCopy(const UList<T>& a); @@ -264,21 +312,21 @@ public: //- Return (start,size) subset from UList with non-const access. // The range is subsetted with the list size itself to ensure that the // result always addresses a valid section of the list. - UList<T> operator[](std::initializer_list<label> start_size_range); + UList<T> operator[](std::initializer_list<label> start_size); //- Return (start,size) subset from UList with const access. // The range is subsetted with the list size itself to ensure that the // result always addresses a valid section of the list. const UList<T> operator[] ( - std::initializer_list<label> start_size_range + std::initializer_list<label> start_size ) const; //- Allow cast to a const List<T>& inline operator const Foam::List<T>&() const; //- Assignment of all entries to the given value - void operator=(const T& t); + void operator=(const T& val); //- Assignment of all entries to zero void operator=(const zero); @@ -374,8 +422,8 @@ public: //- Return true if the UList is empty (ie, size() is zero) inline bool empty() const; - //- Swap two ULists of the same type in constant time - void swap(UList<T>& a); + //- Swap content with another UList of the same type in constant time + inline void swap(UList<T>& lst); // STL member operators @@ -429,6 +477,9 @@ public: ); }; + +// Global Functions + template<class T> void sort(UList<T>& a); @@ -446,11 +497,15 @@ void shuffle(UList<T>& a); // Reverse the first n elements of the list template<class T> -inline void reverse(UList<T>& ul, const label n); +inline void reverse(UList<T>& lst, const label n); // Reverse all the elements of the list template<class T> -inline void reverse(UList<T>& ul); +inline void reverse(UList<T>& lst); + +// Exchange contents of lists - see UList::swap(). +template<class T> +inline void Swap(UList<T>& a, UList<T>& b); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index 971fa7faa05..36c74ee28b5 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -61,6 +61,20 @@ inline Foam::label Foam::UList<T>::fcIndex(const label i) const } +template<class T> +inline const T& Foam::UList<T>::fcValue(const label i) const +{ + return this->operator[](this->fcIndex(i)); +} + + +template<class T> +inline T& Foam::UList<T>::fcValue(const label i) +{ + return this->operator[](this->fcIndex(i)); +} + + template<class T> inline Foam::label Foam::UList<T>::rcIndex(const label i) const { @@ -68,6 +82,20 @@ inline Foam::label Foam::UList<T>::rcIndex(const label i) const } +template<class T> +inline const T& Foam::UList<T>::rcValue(const label i) const +{ + return this->operator[](this->rcIndex(i)); +} + + +template<class T> +inline T& Foam::UList<T>::rcValue(const label i) +{ + return this->operator[](this->rcIndex(i)); +} + + template<class T> inline void Foam::UList<T>::checkStart(const label start) const { @@ -152,6 +180,13 @@ inline T* Foam::UList<T>::data() } +template<class T> +inline bool Foam::UList<T>::found(const T& val, const label start) const +{ + return (this->find(val, start) >= 0); +} + + template<class T> inline void Foam::UList<T>::shallowCopy(const UList<T>& a) { @@ -313,21 +348,37 @@ inline bool Foam::UList<T>::empty() const } +template<class T> +inline void Foam::UList<T>::swap(UList<T>& lst) +{ + Foam::Swap(size_, lst.size_); + Foam::Swap(v_, lst.v_); +} + + // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // template<class T> -inline void Foam::reverse(UList<T>& ul, const label n) +inline void Foam::reverse(UList<T>& lst, const label n) { for (int i=0; i<n/2; ++i) { - Swap(ul[i], ul[n-1-i]); + Foam::Swap(lst[i], lst[n-1-i]); } } + +template<class T> +inline void Foam::reverse(UList<T>& lst) +{ + reverse(lst, lst.size()); +} + + template<class T> -inline void Foam::reverse(UList<T>& ul) +inline void Foam::Swap(UList<T>& a, UList<T>& b) { - reverse(ul, ul.size()); + a.swap(b); } diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.C b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.C index 1626319fc0f..a18d76fc9eb 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.C +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,32 +27,32 @@ License // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField(Istream& is) +template<class T, int SizeMin> +Foam::DynamicField<T, SizeMin>::DynamicField(Istream& is) : Field<T>(is), capacity_(Field<T>::size()) {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -Foam::tmp<Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>> -Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clone() const +template<class T, int SizeMin> +Foam::tmp<Foam::DynamicField<T, SizeMin>> +Foam::DynamicField<T, SizeMin>::clone() const { - return tmp<DynamicField<T, SizeInc, SizeMult, SizeDiv>> + return tmp<DynamicField<T, SizeMin>> ( - new DynamicField<T, SizeInc, SizeMult, SizeDiv>(*this) + new DynamicField<T, SizeMin>(*this) ); } // * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> Foam::Ostream& Foam::operator<< ( Ostream& os, - const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst + const DynamicField<T, SizeMin>& lst ) { os << static_cast<const Field<T>&>(lst); @@ -60,11 +60,11 @@ Foam::Ostream& Foam::operator<< } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> Foam::Istream& Foam::operator>> ( Istream& is, - DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst + DynamicField<T, SizeMin>& lst ) { is >> static_cast<Field<T>&>(lst); diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H index 178dff7c256..fd5b3a5486f 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H @@ -46,21 +46,20 @@ namespace Foam // Forward declaration of friend functions and operators -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -class DynamicField; +template<class T, int SizeMin> class DynamicField; -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> Ostream& operator<< ( Ostream&, - const DynamicField<T, SizeInc, SizeMult, SizeDiv>& + const DynamicField<T, SizeMin>& ); -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> Istream& operator>> ( Istream&, - DynamicField<T, SizeInc, SizeMult, SizeDiv>& + DynamicField<T, SizeMin>& ); @@ -68,16 +67,12 @@ Istream& operator>> Class DynamicField Declaration \*---------------------------------------------------------------------------*/ -template<class T, unsigned SizeInc=0, unsigned SizeMult=2, unsigned SizeDiv=1> +template<class T, int SizeMin=64> class DynamicField : public Field<T> { - static_assert - ( - (SizeInc || SizeMult) && SizeDiv, - "Avoid invalid sizing parameters" - ); + static_assert(SizeMin > 0, "Invalid min size parameter"); // Private data @@ -85,17 +80,20 @@ class DynamicField label capacity_; + // Private Member Functions + + //- Copy assignment from another list + template<class ListType> + inline void assignDynField(const ListType& lst); + public: // Static Member Functions //- Return a null field - inline static const DynamicField<T, SizeInc, SizeMult, SizeDiv>& null() + inline static const DynamicField<T, SizeMin>& null() { - return *reinterpret_cast - < - DynamicField<T, SizeInc, SizeMult, SizeDiv>* - >(0); + return *reinterpret_cast<DynamicField<T, SizeMin>*>(0); } @@ -140,19 +138,19 @@ public: ); //- Construct copy - inline DynamicField(const DynamicField<T, SizeInc, SizeMult, SizeDiv>&); + inline DynamicField(const DynamicField<T, SizeMin>&); //- Construct by transferring the Field contents inline DynamicField ( - const Xfer<DynamicField<T, SizeInc, SizeMult, SizeDiv>>& + const Xfer<DynamicField<T, SizeMin>>& ); //- Construct from Istream. Size set to size of list read. explicit DynamicField(Istream&); //- Clone - tmp<DynamicField<T, SizeInc, SizeMult, SizeDiv>> clone() const; + tmp<DynamicField<T, SizeMin>> clone() const; // Member Functions @@ -188,7 +186,7 @@ public: //- Alter the addressed list size and fill new space with a // constant. - inline void resize(const label, const T&); + inline void resize(const label, const T& val); //- Reserve allocation space for at least this size. // Never shrinks the allocated size, use setCapacity() for that. @@ -203,7 +201,7 @@ public: //- Shrink the allocated space to the number of elements used. // Returns a reference to the DynamicField. - inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& shrink(); + inline DynamicField<T, SizeMin>& shrink(); //- Transfer contents to the Xfer container as a plain List inline Xfer<List<T>> xfer(); @@ -212,16 +210,12 @@ public: // Member Operators //- Append an element at the end of the list - inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& append - ( - const T& - ); + inline DynamicField<T, SizeMin>& + append(const T& val); //- Append a List at the end of this list - inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& append - ( - const UList<T>& - ); + inline DynamicField<T, SizeMin>& + append(const UList<T>& lst); //- Remove and return the top element inline T remove(); @@ -236,7 +230,7 @@ public: //- Assignment to DynamicField inline void operator= ( - const DynamicField<T, SizeInc, SizeMult, SizeDiv>& + const DynamicField<T, SizeMin>& ); //- Assignment to UList diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H index b29af8958e3..658c0b9d1cb 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,18 +23,46 @@ License \*---------------------------------------------------------------------------*/ +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class T, int SizeMin> +template<class ListType> +inline void Foam::DynamicField<T, SizeMin>::assignDynField +( + const ListType& lst +) +{ + const label newSize = lst.size(); + + if (capacity_ >= newSize) + { + // Can copy w/o reallocating - adjust addressable size accordingly. + Field<T>::size(lst.size()); + Field<T>::operator=(lst); + } + else + { + // Ensure list size consistency prior to copying. + Field<T>::size(capacity_); + + Field<T>::operator=(lst); + capacity_ = Field<T>::size(); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField() +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField() : Field<T>(0), capacity_(Field<T>::size()) {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( const label nElem ) @@ -42,13 +70,13 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField Field<T>(nElem), capacity_(Field<T>::size()) { - // we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv) + // We could also enforce sizing granularity Field<T>::size(0); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( const UList<T>& lst ) @@ -58,8 +86,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( const Xfer<List<T>>& lst ) @@ -69,8 +97,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( const Xfer<Field<T>>& lst ) @@ -80,8 +108,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( const UList<T>& mapF, const labelList& mapAddressing @@ -92,8 +120,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( const UList<T>& mapF, const labelListList& mapAddressing, @@ -106,8 +134,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField //- Construct by mapping from the given field -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( const UList<T>& mapF, const FieldMapper& map @@ -118,10 +146,10 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( - const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst + const DynamicField<T, SizeMin>& lst ) : Field<T>(lst), @@ -129,10 +157,10 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField {} -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>::DynamicField ( - const Xfer<DynamicField<T, SizeInc, SizeMult, SizeDiv>>& lst + const Xfer<DynamicField<T, SizeMin>>& lst ) : Field<T>(lst), @@ -142,16 +170,16 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::label Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::capacity() +template<class T, int SizeMin> +inline Foam::label Foam::DynamicField<T, SizeMin>::capacity() const { return capacity_; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setCapacity +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::setCapacity ( const label nElem ) @@ -164,107 +192,90 @@ inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setCapacity // truncate addressed sizes too nextFree = capacity_; } - // we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv) + + // We could also enforce sizing granularity Field<T>::setSize(capacity_); Field<T>::size(nextFree); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::reserve +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::reserve ( const label nElem ) { - // allocate more capacity? + // Allocate more capacity if necessary if (nElem > capacity_) { -// TODO: convince the compiler that division by zero does not occur -// if (SizeInc && (!SizeMult || !SizeDiv)) -// { -// // resize with SizeInc as the granularity -// capacity_ = nElem; -// unsigned pad = SizeInc - (capacity_ % SizeInc); -// if (pad != SizeInc) -// { -// capacity_ += pad; -// } -// } -// else - { - capacity_ = max + capacity_ = max + ( + SizeMin, + max ( nElem, - label(SizeInc + capacity_ * SizeMult / SizeDiv) - ); - } + // label(SizeInc + capacity_ * SizeMult / SizeDiv) + label(2*capacity_) + ) + ); - // adjust allocated size, leave addressed size untouched - label nextFree = Field<T>::size(); + // Adjust allocated size, leave addressed size untouched + const label nextFree = Field<T>::size(); Field<T>::setSize(capacity_); Field<T>::size(nextFree); } } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setSize +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::setSize ( const label nElem ) { - // allocate more capacity? + // Allocate more capacity if necessary if (nElem > capacity_) { -// TODO: convince the compiler that division by zero does not occur -// if (SizeInc && (!SizeMult || !SizeDiv)) -// { -// // resize with SizeInc as the granularity -// capacity_ = nElem; -// unsigned pad = SizeInc - (capacity_ % SizeInc); -// if (pad != SizeInc) -// { -// capacity_ += pad; -// } -// } -// else - { - capacity_ = max + capacity_ = max + ( + SizeMin, + max ( nElem, - label(SizeInc + capacity_ * SizeMult / SizeDiv) - ); - } + // label(SizeInc + capacity_ * SizeMult / SizeDiv) + label(2*capacity_) + ) + ); Field<T>::setSize(capacity_); } - // adjust addressed size + // Adjust addressed size Field<T>::size(nElem); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setSize +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::setSize ( const label nElem, - const T& t + const T& val ) { label nextFree = Field<T>::size(); setSize(nElem); - // set new elements to constant value + // Set new elements to constant value while (nextFree < nElem) { - this->operator[](nextFree++) = t; + this->operator[](nextFree++) = val; } } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::resize ( const label nElem ) @@ -273,35 +284,35 @@ inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::resize ( const label nElem, - const T& t + const T& val ) { - this->setSize(nElem, t); + this->setSize(nElem, val); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clear() +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::clear() { Field<T>::size(0); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clearStorage() +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::clearStorage() { Field<T>::clear(); capacity_ = 0; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::shrink() +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>& +Foam::DynamicField<T, SizeMin>::shrink() { label nextFree = Field<T>::size(); if (capacity_ > nextFree) @@ -318,32 +329,32 @@ Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::shrink() } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<class T, int SizeMin> inline Foam::Xfer<Foam::List<T>> -Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::xfer() +Foam::DynamicField<T, SizeMin>::xfer() { return xferMoveTo<List<T>>(*this); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>& +Foam::DynamicField<T, SizeMin>::append ( - const T& t + const T& val ) { - const label elemI = List<T>::size(); - setSize(elemI + 1); + const label idx = List<T>::size(); + setSize(idx + 1); - this->operator[](elemI) = t; + this->operator[](idx) = val; return *this; } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>& -Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append +template<class T, int SizeMin> +inline Foam::DynamicField<T, SizeMin>& +Foam::DynamicField<T, SizeMin>::append ( const UList<T>& lst ) @@ -365,20 +376,21 @@ Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline T Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::remove() +template<class T, int SizeMin> +inline T Foam::DynamicField<T, SizeMin>::remove() { - const label elemI = List<T>::size() - 1; + // Location of last element and simultaneously the new size + const label idx = List<T>::size() - 1; - if (elemI < 0) + if (idx < 0) { FatalErrorInFunction << "List is empty" << abort(FatalError); } - const T& val = List<T>::operator[](elemI); + const T& val = List<T>::operator[](idx); - List<T>::size(elemI); + List<T>::size(idx); return val; } @@ -386,8 +398,8 @@ inline T Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::remove() // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline T& Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator() +template<class T, int SizeMin> +inline T& Foam::DynamicField<T, SizeMin>::operator() ( const label elemI ) @@ -401,65 +413,39 @@ inline T& Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator() } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::operator= ( - const T& t + const T& val ) { - UList<T>::operator=(t); + UList<T>::operator=(val); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::operator= ( - const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst + const DynamicField<T, SizeMin>& lst ) { if (this == &lst) { FatalErrorInFunction - << "attempted assignment to self" << abort(FatalError); - } - - if (capacity_ >= lst.size()) - { - // can copy w/o reallocating, match initial size to avoid reallocation - Field<T>::size(lst.size()); - Field<T>::operator=(lst); + << "Attempted assignment to self" << abort(FatalError); } - else - { - // make everything available for the copy operation - Field<T>::size(capacity_); - Field<T>::operator=(lst); - capacity_ = Field<T>::size(); - } + assignDynField(lst); } -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator= +template<class T, int SizeMin> +inline void Foam::DynamicField<T, SizeMin>::operator= ( const UList<T>& lst ) { - if (capacity_ >= lst.size()) - { - // can copy w/o reallocating, match initial size to avoid reallocation - Field<T>::size(lst.size()); - Field<T>::operator=(lst); - } - else - { - // make everything available for the copy operation - Field<T>::size(capacity_); - - Field<T>::operator=(lst); - capacity_ = Field<T>::size(); - } + assignDynField(lst); } diff --git a/src/OpenFOAM/fields/Fields/Field/FieldM.H b/src/OpenFOAM/fields/Fields/Field/FieldM.H index 46be4b350da..b1682bf6d7a 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldM.H +++ b/src/OpenFOAM/fields/Fields/Field/FieldM.H @@ -56,7 +56,8 @@ void checkFields FatalErrorInFunction << " Field<"<<pTraits<Type1>::typeName<<"> f1("<<f1.size()<<')' << " and Field<"<<pTraits<Type2>::typeName<<"> f2("<<f2.size()<<')' - << endl << " for operation " << op + << endl + << " for operation " << op << abort(FatalError); } } @@ -76,7 +77,8 @@ void checkFields << " Field<"<<pTraits<Type1>::typeName<<"> f1("<<f1.size()<<')' << ", Field<"<<pTraits<Type2>::typeName<<"> f2("<<f2.size()<<')' << " and Field<"<<pTraits<Type3>::typeName<<"> f3("<<f3.size()<<')' - << endl << " for operation " << op + << endl + << " for operation " << op << abort(FatalError); } } @@ -107,312 +109,305 @@ void checkFields // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// member function : this f1 OP fUNC f2 +// Member function : f1 OP Func f2 #define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP " " #FUNC "(f2)"); \ \ - /* set access to f1, f2 and f3 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: f1 OP FUNC(f2) */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i)); \ + (f1P[i]) OP FUNC(f2P[i]); \ } #define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP " f2" #FUNC); \ \ - /* set access to f1, f2 and f3 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: f1 OP f2.FUNC() */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i).FUNC(); \ + (f1P[i]) OP (f2P[i]).FUNC(); \ } -// member function : this field f1 OP fUNC f2, f3 +// Member function : this field f1 OP FUNC(f2, f3) #define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3) \ \ - /* check the three fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, f3, "f1 " #OP " " #FUNC "(f2, f3)"); \ \ - /* set access to f1, f2 and f3 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ List_CONST_ACCESS(typeF3, f3, f3P); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: f1 OP FUNC(f2, f3) */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) \ - OP FUNC(List_ELEM(f2, f2P, i), List_ELEM(f3, f3P, i)); \ + (f1P[i]) OP FUNC((f2P[i]), (f3P[i])); \ } -// member function : this field f1 OP fUNC f2, f3 +// Member function : s OP FUNC(f1, f2) #define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "s " #OP " " #FUNC "(f1, f2)"); \ \ - /* set access to f1 and f2 at end of each field */ \ + /* Field access */ \ List_CONST_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing s OP FUNC(f1, f2) */ \ + /* Loop: s OP FUNC(f1, f2) */ \ List_FOR_ALL(f1, i) \ { \ - (s) OP FUNC(List_ELEM(f1, f1P, i), List_ELEM(f2, f2P, i)); \ + (s) OP FUNC((f1P[i]), (f2P[i])); \ } -// member function : this f1 OP fUNC f2, s +// Member function : this f1 OP FUNC(f2, s) #define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP " " #FUNC "(f2, s)"); \ \ - /* set access to f1, f2 and f3 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: f1 OP FUNC(f2, s) */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i), (s)); \ + (f1P[i]) OP FUNC((f2P[i]), (s)); \ } -// member function : s1 OP fUNC f, s2 +// Member function : s1 OP FUNC(f, s2) #define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2) \ \ - /* set access to f at end of field */ \ + /* Field access */ \ List_CONST_ACCESS(typeF, f, fP); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: s1 OP FUNC(f, s2) */ \ List_FOR_ALL(f, i) \ { \ - (s1) OP FUNC(List_ELEM(f, fP, i), (s2)); \ + (s1) OP FUNC((fP[i]), (s2)); \ } -// member function : this f1 OP fUNC s, f2 +// Member function : this f1 OP FUNC(s, f2) #define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP " " #FUNC "(s, f2)"); \ \ - /* set access to f1, f2 and f3 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP FUNC((s), List_ELEM(f2, f2P, i)); \ + (f1P[i]) OP FUNC((s), (f2P[i])); \ } -// member function : this f1 OP fUNC s, f2 +// Member function : this f1 OP FUNC(s1, s2) #define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2) \ \ - /* set access to f1 at end of field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ \ - /* loop through fields performing f1 OP1 FUNC(s1, s2) */ \ + /* Loop: f1 OP FUNC(s1, s2) */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP FUNC((s1), (s2)); \ + (f1P[i]) OP FUNC((s1), (s2)); \ } -// member function : this f1 OP1 f2 OP2 FUNC s +// Member function : this f1 OP f2 FUNC(s) #define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP " f2 " #FUNC "(s)"); \ \ - /* set access to f1, f2 and f3 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: f1 OP f2 FUNC(s) */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i) FUNC((s)); \ + (f1P[i]) OP (f2P[i]) FUNC((s)); \ } -// define high performance macro functions for Field<Type> operations - -// member operator : this field f1 OP1 f2 OP2 f3 +// Member operator : this field f1 OP1 f2 OP2 f3 #define TFOR_ALL_F_OP_F_OP_F(typeF1, f1, OP1, typeF2, f2, OP2, typeF3, f3) \ \ - /* check the three fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, f3, "f1 " #OP1 " f2 " #OP2 " f3"); \ \ - /* set access to f1, f2 and f3 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ List_CONST_ACCESS(typeF3, f3, f3P); \ \ - /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ + /* Loop: f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) \ - OP2 List_ELEM(f3, f3P, i); \ + (f1P[i]) OP1 (f2P[i]) OP2 (f3P[i]); \ } -// member operator : this field f1 OP1 s OP2 f2 +// Member operator : this field f1 OP1 s OP2 f2 #define TFOR_ALL_F_OP_S_OP_F(typeF1, f1, OP1, typeS, s, OP2, typeF2, f2) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP1 " s " #OP2 " f2"); \ \ - /* set access to f1 and f2 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 s OP2 f2 */ \ + /* Loop: f1 OP1 s OP2 f2 */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP1 (s) OP2 List_ELEM(f2, f2P, i); \ + (f1P[i]) OP1 (s) OP2 (f2P[i]); \ } -// member operator : this field f1 OP1 f2 OP2 s +// Member operator : this field f1 OP1 f2 OP2 s #define TFOR_ALL_F_OP_F_OP_S(typeF1, f1, OP1, typeF2, f2, OP2, typeS, s) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP1 " f2 " #OP2 " s"); \ \ - /* set access to f1 and f2 at end of each field */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 s OP2 f2 */ \ + /* Loop f1 OP1 s OP2 f2 */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) OP2 (s); \ + (f1P[i]) OP1 (f2P[i]) OP2 (s); \ } -// member operator : this field f1 OP f2 +// Member operator : this field f1 OP f2 #define TFOR_ALL_F_OP_F(typeF1, f1, OP, typeF2, f2) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, "f1 " #OP " f2"); \ \ - /* set pointer to f1P at end of f1 and */ \ - /* f2.p at end of f2 */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP f2 */ \ + /* Loop: f1 OP f2 */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i); \ + (f1P[i]) OP (f2P[i]); \ } -// member operator : this field f1 OP1 OP2 f2 +// Member operator : this field f1 OP1 OP2 f2 #define TFOR_ALL_F_OP_OP_F(typeF1, f1, OP1, OP2, typeF2, f2) \ \ - /* check the two fields have same Field<Type> mesh */ \ + /* Check fields have same size */ \ checkFields(f1, f2, #OP1 " " #OP2 " f2"); \ \ - /* set pointer to f1P at end of f1 and */ \ - /* f2.p at end of f2 */ \ + /* Field access */ \ List_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through fields performing f1 OP1 OP2 f2 */ \ + /* Loop: f1 OP1 OP2 f2 */ \ List_FOR_ALL(f1, i) \ { \ - List_ELEM(f1, f1P, i) OP1 OP2 List_ELEM(f2, f2P, i); \ + (f1P[i]) OP1 OP2 (f2P[i]); \ } -// member operator : this field f OP s +// Member operator : this field f OP s #define TFOR_ALL_F_OP_S(typeF, f, OP, typeS, s) \ \ - /* set access to f at end of field */ \ + /* Field access */ \ List_ACCESS(typeF, f, fP); \ \ - /* loop through field performing f OP s */ \ + /* Loop: f OP s */ \ List_FOR_ALL(f, i) \ { \ - List_ELEM(f, fP, i) OP (s); \ + (fP[i]) OP (s); \ } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// define high performance macro functions for Field<Type> friend functions -// friend operator function : s OP f, allocates storage for s +// Friend operator function : s OP f, allocates storage for s #define TFOR_ALL_S_OP_F(typeS, s, OP, typeF, f) \ \ - /* set access to f at end of field */ \ + /* Field access */ \ List_CONST_ACCESS(typeF, f, fP); \ \ - /* loop through field performing s OP f */ \ + /* Loop: s OP f */ \ List_FOR_ALL(f, i) \ { \ - (s) OP List_ELEM(f, fP, i); \ + (s) OP (fP[i]); \ } -// friend operator function : s OP1 f1 OP2 f2, allocates storage for s +// Friend operator function : s OP1 f1 OP2 f2, allocates storage for s #define TFOR_ALL_S_OP_F_OP_F(typeS, s, OP1, typeF1, f1, OP2, typeF2, f2) \ \ - /* set access to f1 and f2 at end of each field */ \ + /* Field access */ \ List_CONST_ACCESS(typeF1, f1, f1P); \ List_CONST_ACCESS(typeF2, f2, f2P); \ \ - /* loop through field performing s OP f */ \ + /* Loop: s OP f */ \ List_FOR_ALL(f1, i) \ { \ - (s) OP1 List_ELEM(f1, f1P, i) OP2 List_ELEM(f2, f2P, i); \ + (s) OP1 (f1P[i]) OP2 (f2P[i]); \ } -// friend operator function : s OP FUNC(f), allocates storage for s +// Friend operator function : s OP FUNC(f), allocates storage for s #define TFOR_ALL_S_OP_FUNC_F(typeS, s, OP, FUNC, typeF, f) \ \ - /* set access to f at end of field */ \ + /* Field access */ \ List_CONST_ACCESS(typeF, f, fP); \ \ - /* loop through field performing s OP f */ \ + /* Loop: s OP FUNC(f) */ \ List_FOR_ALL(f, i) \ { \ - (s) OP FUNC(List_ELEM(f, fP, i)); \ + (s) OP FUNC(fP[i]); \ } diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 822e3c4f9a6..2c640ce5236 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -62,8 +62,7 @@ namespace Foam class face; class triFace; -template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> -class DynamicList; +template<class T, int SizeMin> class DynamicList; inline Istream& operator>>(Istream& is, face& f); @@ -344,11 +343,11 @@ public: //- Split into triangles using existing points. // Append to DynamicList. // Returns number of faces created. - template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> + template<int SizeMin> label triangles ( const UList<point>& points, - DynamicList<face, SizeInc, SizeMult, SizeDiv>& triFaces + DynamicList<face, SizeMin>& triFaces ) const; //- Number of triangles and quads after splitting diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H index d312560843c..17b58b83bd2 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H @@ -124,13 +124,13 @@ inline bool Foam::face::found(const label globalIndex) const inline Foam::label Foam::face::nextLabel(const label i) const { - return operator[](fcIndex(i)); + return this->fcValue(i); } inline Foam::label Foam::face::prevLabel(const label i) const { - return operator[](rcIndex(i)); + return this->rcValue(i); } diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C b/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C index 112a5703fbe..9f9bb58844e 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C +++ b/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C @@ -28,11 +28,11 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +template<int SizeMin> Foam::label Foam::face::triangles ( const UList<point>& points, - DynamicList<face, SizeInc, SizeMult, SizeDiv>& triFaces + DynamicList<face, SizeMin>& triFaces ) const { label triI = triFaces.size(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index ee160048be8..5603bda172b 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -38,8 +38,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells const cellShapeList& c ) const { - List<DynamicList<label, primitiveMesh::cellsPerPoint_>> - pc(points().size()); + List<DynamicList<label>> pc(points().size()); // For each cell forAll(c, i) @@ -51,8 +50,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells { // Set working point label label curPoint = labels[j]; - DynamicList<label, primitiveMesh::cellsPerPoint_>& curPointCells = - pc[curPoint]; + DynamicList<label>& curPointCells = pc[curPoint]; // Enter the cell label in the point's cell list curPointCells.append(i); diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C index 1b56bd5268c..f130c8975bb 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C @@ -60,7 +60,7 @@ void Foam::primitiveMesh::calcCellEdges() const else { // Set up temporary storage - List<DynamicList<label, edgesPerCell_>> ce(nCells()); + List<DynamicList<label>> ce(nCells()); // Get reference to faceCells and faceEdges @@ -71,7 +71,7 @@ void Foam::primitiveMesh::calcCellEdges() const // loop through the list again and add edges; checking for duplicates forAll(own, facei) { - DynamicList<label, edgesPerCell_>& curCellEdges = ce[own[facei]]; + DynamicList<label>& curCellEdges = ce[own[facei]]; const labelList& curEdges = fe[facei]; @@ -87,7 +87,7 @@ void Foam::primitiveMesh::calcCellEdges() const forAll(nei, facei) { - DynamicList<label, edgesPerCell_>& curCellEdges = ce[nei[facei]]; + DynamicList<label>& curCellEdges = ce[nei[facei]]; const labelList& curEdges = fe[facei]; diff --git a/src/OpenFOAM/primitives/Swap/Swap.H b/src/OpenFOAM/primitives/Swap/Swap.H index 85b0c7316da..0c2b20b1d4d 100644 --- a/src/OpenFOAM/primitives/Swap/Swap.H +++ b/src/OpenFOAM/primitives/Swap/Swap.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,28 +25,56 @@ InNamespace Foam Description - Swap its arguments + Swap arguments as per std::swap, but in Foam namespace. \*---------------------------------------------------------------------------*/ #ifndef Swap_H #define Swap_H +#include <type_traits> +#include <utility> + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - +//- Swap non-array types as per std::swap example, but in Foam namespace. +// \sa http://www.cplusplus.com/reference/utility/swap/ template<class T> -inline void Swap(T& a, T& b) +void Swap(T& a, T& b) +{ + // compile-time resolution with std::enable_if not yet working + if (std::is_fundamental<T>::value || std::is_pointer<T>::value) + { + // Use copy/assign for simple types + const T tmp = a; + a = b; + b = tmp; + } + else + { + // Use move/assignment + T tmp(std::move(a)); + a = std::move(b); + b = std::move(tmp); + } +} + + +//- Swap array types as per std::swap example, but in Foam namespace. +// \sa http://www.cplusplus.com/reference/utility/swap/ +template<class T, size_t N> +void Swap(T (&a)[N], T (&b)[N]) { - T tmp = a; - a = b; - b = tmp; + for (size_t i = 0; i < N; ++i) + { + Foam::Swap(a[i], b[i]); + } } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C index c0f8dd6fa7d..7a04712c027 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C @@ -46,8 +46,7 @@ void Foam::enrichedPatch::calcPointPoints() const // Go through all faces and add the previous and next point as the // neighbour for each point. While inserting points, reject the // duplicates (as every internal edge will be visited twice). - List<DynamicList<label, primitiveMesh::edgesPerPoint_>> - pp(meshPoints().size()); + List<DynamicList<label>> pp(meshPoints().size()); const faceList& lf = localFaces(); @@ -59,8 +58,7 @@ void Foam::enrichedPatch::calcPointPoints() const forAll(curFace, pointi) { - DynamicList<label, primitiveMesh::edgesPerPoint_>& - curPp = pp[curFace[pointi]]; + DynamicList<label>& curPp = pp[curFace[pointi]]; // Do next label label next = curFace.nextLabel(pointi); diff --git a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C index dfe684bb4da..9a5f3a49842 100644 --- a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C +++ b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C @@ -503,7 +503,7 @@ void Foam::searchableBox::findLineAll info.setSize(start.size()); // Work array - DynamicList<pointIndexHit, 1, 1> hits; + DynamicList<pointIndexHit> hits; // Tolerances: // To find all intersections we add a small vector to the last intersection diff --git a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C index ffb8dc9c5dc..ab2329e744a 100644 --- a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C +++ b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C @@ -301,7 +301,7 @@ void Foam::searchableRotatedBox::findLineAll info.setSize(start.size()); // Work array - DynamicList<pointIndexHit, 1, 1> hits; + DynamicList<pointIndexHit> hits; // Tolerances: // To find all intersections we add a small vector to the last intersection diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H index 110ee7944b2..54af373a33d 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H @@ -131,7 +131,7 @@ class triSurfaceMesh const point& start, const point& end, const vector& smallVec, - DynamicList<pointIndexHit, 1, 1>& hits + DynamicList<pointIndexHit>& hits ); //- Disallow default bitwise copy construct diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index 40edce3f2c3..fe699056547 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -33,7 +33,7 @@ License bool Foam::triSurfaceSearch::checkUniqueHit ( const pointIndexHit& currHit, - const DynamicList<pointIndexHit, 1, 1>& hits, + const UList<pointIndexHit>& hits, const vector& lineVec ) const { @@ -387,7 +387,7 @@ void Foam::triSurfaceSearch::findLineAll indexedOctree<treeDataTriSurface>::perturbTol() = tolerance(); // Work array - DynamicList<pointIndexHit, 1, 1> hits; + DynamicList<pointIndexHit> hits; DynamicList<label> shapeMask; diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H index b46e7589857..d42806a5639 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H @@ -80,7 +80,7 @@ class triSurfaceSearch bool checkUniqueHit ( const pointIndexHit& currHit, - const DynamicList<pointIndexHit, 1, 1>& hits, + const UList<pointIndexHit>& hits, const vector& lineVec ) const; diff --git a/wmake/rules/linux64GccKNL/c b/wmake/rules/linux64GccKNL/c index a1cd9d6613e..d0eb3eab570 100644 --- a/wmake/rules/linux64GccKNL/c +++ b/wmake/rules/linux64GccKNL/c @@ -2,7 +2,7 @@ SUFFIXES += .c cWARN = -Wall -cc = gcc -m64 -march=knl -DvectorMachine -DKNL +cc = gcc -m64 -march=knl include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linux64GccKNL/c++ b/wmake/rules/linux64GccKNL/c++ index cdc820c5568..199d72c0fdc 100644 --- a/wmake/rules/linux64GccKNL/c++ +++ b/wmake/rules/linux64GccKNL/c++ @@ -6,7 +6,7 @@ c++WARN = -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-para # Suppress some warnings for flex++ and CGAL c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds -CC = g++ -std=c++11 -m64 -march=knl -DvectorMachine +CC = g++ -std=c++11 -m64 -march=knl include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linux64IccKNL/c++ b/wmake/rules/linux64IccKNL/c++ index f0938a4da25..9b047d22caf 100644 --- a/wmake/rules/linux64IccKNL/c++ +++ b/wmake/rules/linux64IccKNL/c++ @@ -6,7 +6,7 @@ c++WARN = -Wall -Wextra -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invali # Suppress some warnings for flex++ and CGAL c++LESSWARN = -diag-disable 1224,2026,2305 -CC = icpc -std=c++11 -xmic-avx512 -DvectorMachine -fp-trap=common -fp-model precise -fp-speculation=safe +CC = icpc -std=c++11 -xmic-avx512 -fp-trap=common -fp-model precise -fp-speculation=safe include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION) -- GitLab From 16649b377248a76a2526c16b4b8b20b205db62e6 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Mon, 25 Sep 2017 13:25:34 +0100 Subject: [PATCH 011/126] BUG: thermoFoam - corrected to enable restart and post-processing using thermoFoam -postProcess. Fixes #598 --- .../solvers/heatTransfer/thermoFoam/EEqn.H | 6 ++- .../heatTransfer/thermoFoam/createFields.H | 26 +++++++++- .../heatTransfer/thermoFoam/setAlphaEff.H | 47 ------------------- .../heatTransfer/thermoFoam/thermoFoam.C | 2 - 4 files changed, 30 insertions(+), 51 deletions(-) delete mode 100644 applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H diff --git a/applications/solvers/heatTransfer/thermoFoam/EEqn.H b/applications/solvers/heatTransfer/thermoFoam/EEqn.H index 98a248ac35a..55088296638 100644 --- a/applications/solvers/heatTransfer/thermoFoam/EEqn.H +++ b/applications/solvers/heatTransfer/thermoFoam/EEqn.H @@ -15,12 +15,16 @@ ) : -dpdt ) - - fvm::laplacian(alphaEff, he) == radiation->Sh(thermo, he) + fvOptions(rho, he) ); + if (turbulence.valid()) + { + EEqn -= fvm::laplacian(turbulence->alphaEff(), he); + } + EEqn.relax(); fvOptions.constrain(EEqn); diff --git a/applications/solvers/heatTransfer/thermoFoam/createFields.H b/applications/solvers/heatTransfer/thermoFoam/createFields.H index 90f25a89a3a..2e09b43e595 100644 --- a/applications/solvers/heatTransfer/thermoFoam/createFields.H +++ b/applications/solvers/heatTransfer/thermoFoam/createFields.H @@ -35,7 +35,31 @@ volVectorField U #include "compressibleCreatePhi.H" -#include "setAlphaEff.H" +autoPtr<compressible::turbulenceModel> turbulence; + +IOobject turbulencePropertiesHeader +( + "turbulenceProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false +); + +if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(false)) +{ + Info<< "Creating turbulence model\n" << endl; + + turbulence = + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ); +} #include "createDpdt.H" diff --git a/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H b/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H deleted file mode 100644 index c760349a6eb..00000000000 --- a/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H +++ /dev/null @@ -1,47 +0,0 @@ -Info<< "Creating turbulence model\n" << endl; -tmp<volScalarField> talphaEff; - -IOobject turbulencePropertiesHeader -( - "turbulenceProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false -); - -if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(false)) -{ - autoPtr<compressible::turbulenceModel> turbulence - ( - compressible::turbulenceModel::New - ( - rho, - U, - phi, - thermo - ) - ); - - talphaEff = turbulence->alphaEff(); -} -else -{ - talphaEff = tmp<volScalarField> - ( - new volScalarField - ( - IOobject - ( - "alphaEff", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("0", dimMass/dimLength/dimTime, 0.0) - ) - ); -} diff --git a/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C b/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C index a8cbdf9f7e6..ea5012e72ea 100644 --- a/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C +++ b/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C @@ -54,8 +54,6 @@ int main(int argc, char *argv[]) #include "createFields.H" #include "createFvOptions.H" - const volScalarField& alphaEff = talphaEff(); - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nEvolving thermodynamics\n" << endl; -- GitLab From a56a70b74497b9a5dfc2b587d64e51a14844f3c8 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 29 Sep 2017 19:35:08 +0200 Subject: [PATCH 012/126] ENH: adjust infoSwitch to report host subscription (related to #531) - this compact form shows the subscription per host in the unsorted mpi order nProcs : 18 Hosts : ( (node1 6) (node2 8) (node3 4) ) This provides a succinct overview of which hosts have been subscribed or oversubscribed. - The longer list of "slave.pid" ... remains available on the InfoSwitch 'writeHosts' --- etc/controlDict | 13 +++--- src/OpenFOAM/global/argList/argList.C | 62 ++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/etc/controlDict b/etc/controlDict index 77a630c3fb8..37ebba2b46e 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -38,21 +38,24 @@ InfoSwitches // The default ASCII write precision writePrecision 6; - // Enable job info - writeJobInfo 0; - writeDictionaries 0; writeOptionalEntries 0; // Write lagrangian "positions" file in v1706 format (at earlier) writeLagrangianPositions 0; - // Report list of slaves/pids used (parallel) - writeSlaves 1; + // Report hosts used (parallel) + // - 0 = none + // - 1 = per-host-count, but unsorted + // - 2 = long output of "slave.pid" ... + writeHosts 1; // Report list of roots used (parallel) writeRoots 1; + // Enable job info + writeJobInfo 0; + // Allow profiling allowProfiling 1; diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 20d4bffbc71..d832a6d7f25 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -102,6 +102,53 @@ Foam::argList::initValidTables::initValidTables() Foam::argList::initValidTables dummyInitValidTables; +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Counted per machine name +// Does not include any sorting since we wish to know the ordering according to +// mpi rank. +// +// Always include the master too. +// This provides a better overview of the subscription +static void printHostsSubscription(const UList<string>& slaveProcs) +{ + Info<< "Hosts :" << nl << "(" << nl; + + std::string prev = hostName(); + int count = 1; + + for (const auto& str : slaveProcs) + { + const auto dot = str.rfind('.'); + const std::string curr(std::move(str.substr(0, dot))); + + if (prev != curr) + { + if (count) + { + // Finish previous + Info<<" (" << prev.c_str() << " " << count << ")" << nl; + count = 0; + } + + prev = std::move(curr); + } + ++count; + } + + if (count) + { + // Finished last one + Info<<" (" << prev.c_str() << " " << count << ")" << nl; + } + + Info<< ")" << nl; +} + +} // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -931,6 +978,7 @@ void Foam::argList::parse } stringList slaveProcs; + const int writeHostsSwitch = debug::infoSwitch("writeHosts", 1); // Collect slave machine/pid, and check that the build is identical if (parRunControl_.parRun()) @@ -981,8 +1029,9 @@ void Foam::argList::parse // Keep or discard slave and root information for reporting: if (Pstream::master() && parRunControl_.parRun()) { - if (!debug::infoSwitch("writeSlaves", 1)) + if (!writeHostsSwitch) { + // Clear here to ensures it doesn't show in the jobInfo slaveProcs.clear(); } if (!debug::infoSwitch("writeRoots", 1)) @@ -1000,7 +1049,16 @@ void Foam::argList::parse { if (slaveProcs.size()) { - Info<< "Slaves : " << slaveProcs << nl; + if (writeHostsSwitch == 1) + { + // Compact output (see etc/controlDict) + printHostsSubscription(slaveProcs); + } + else + { + // Full output of "slave.pid" + Info<< "Slaves : " << slaveProcs << nl; + } } if (roots.size()) { -- GitLab From b9d97d96c13be6bf93598dd91cd54256d85c651c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 3 Nov 2017 10:18:22 +0100 Subject: [PATCH 013/126] ENH: expose null constructible dictionary searcher --- src/OpenFOAM/db/dictionary/dictionary.C | 29 +++++++++++++------ src/OpenFOAM/db/dictionary/dictionary.H | 15 +++++----- src/OpenFOAM/db/dictionary/dictionarySearch.C | 1 + 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index a39fbf48629..f4fc9d63369 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -271,7 +271,7 @@ const Foam::entry& Foam::dictionary::lookupEntry bool patternMatch ) const { - auto finder = csearch(keyword, recursive, patternMatch); + const const_searcher finder(csearch(keyword, recursive, patternMatch)); if (!finder.found()) { @@ -320,7 +320,7 @@ bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry) const word varName(keyword.substr(1), false); // Lookup the variable name in the given dictionary - const_searcher finder = csearch(varName, true, true); + const const_searcher finder(csearch(varName, true, true)); // If defined insert its entries into this dictionary if (finder.found()) @@ -354,7 +354,7 @@ bool Foam::dictionary::substituteScopedKeyword const word varName(keyword.substr(1), false); // Lookup the variable name in the given dictionary - const_searcher finder = csearchScoped(varName, true, true); + const const_searcher finder(csearchScoped(varName, true, true)); // If defined insert its entries into this dictionary if (finder.found()) @@ -397,7 +397,7 @@ Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const { // Find non-recursive with patterns - auto finder = csearch(keyword, false, true); + const const_searcher finder(csearch(keyword, false, true)); if (!finder.found()) { @@ -416,7 +416,7 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) { // Find non-recursive with patterns - auto finder = search(keyword, false, true); + searcher finder = search(keyword, false, true); if (!finder.found()) { @@ -439,7 +439,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict ) const { // Find non-recursive with patterns - auto finder = csearch(keyword, false, true); + const const_searcher finder(csearch(keyword, false, true)); if (finder.isDict()) { @@ -475,7 +475,7 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict const word& keyword ) const { - auto finder = csearch(keyword, false, true); + const const_searcher finder(csearch(keyword, false, true)); if (finder.isDict()) { @@ -535,6 +535,11 @@ Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) { + if (!entryPtr) + { + return false; + } + auto iter = hashedEntries_.find(entryPtr->keyword()); if (mergeEntry && iter.found()) @@ -543,8 +548,8 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) if (iter()->isDict() && entryPtr->isDict()) { iter()->dict().merge(entryPtr->dict()); - delete entryPtr; + delete entryPtr; return true; } @@ -576,6 +581,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) << " in dictionary " << name() << endl; parent_type::remove(entryPtr); + delete entryPtr; return false; } @@ -657,8 +663,13 @@ void Foam::dictionary::add void Foam::dictionary::set(entry* entryPtr) { + if (!entryPtr) + { + return; + } + // Find non-recursive with patterns - auto finder = search(entryPtr->keyword(), false, true); + searcher finder(search(entryPtr->keyword(), false, true)); // Clear dictionary so merge acts like overwrite if (finder.isDict()) diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 75ef089de29..918ee9b7fe5 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -222,13 +222,6 @@ public: pointer eptr_; - //- Construct null - Searcher() - : - dict_(nullptr), - eptr_(nullptr) - {} - //- Construct for the given dictionary context Searcher(dict_pointer dict) : @@ -245,6 +238,14 @@ public: public: + //- Construct null + Searcher() + : + dict_(nullptr), + eptr_(nullptr) + {} + + //- Entry was found. inline bool found() const { diff --git a/src/OpenFOAM/db/dictionary/dictionarySearch.C b/src/OpenFOAM/db/dictionary/dictionarySearch.C index cc711af70a5..cea0844cdfc 100644 --- a/src/OpenFOAM/db/dictionary/dictionarySearch.C +++ b/src/OpenFOAM/db/dictionary/dictionarySearch.C @@ -587,6 +587,7 @@ Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath) } else { + // Note: a failed add() deletes the eptr passed return nullptr; } } -- GitLab From 1cfb59fe1a4bc72bd036cfee9a2d4facde9a106c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 4 Oct 2017 08:19:39 +0200 Subject: [PATCH 014/126] ENH: add read-option for polyTopoChanger (issue #608) - avoid meshModifier contents from being read immediately upon construction, since this recreates an existing modifier instead of allowing us to specify our own. --- .../mesh/manipulation/stitchMesh/stitchMesh.C | 11 ++-- .../polyTopoChanger/polyTopoChanger.C | 53 +++++++++++-------- .../polyTopoChanger/polyTopoChanger.H | 22 ++++---- 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index 9723c1cdb7f..ca0289a10e5 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +27,6 @@ Application Group grpMeshManipulationUtilities - Description 'Stitches' a mesh. @@ -332,7 +331,8 @@ int main(int argc, char *argv[]) isf[i] = masterPatch.start() + i; } - polyTopoChanger stitcher(mesh); + polyTopoChanger stitcher(mesh, IOobject::NO_READ); + stitcher.clear(); stitcher.setSize(1); mesh.pointZones().clearAddressing(); @@ -414,7 +414,6 @@ int main(int argc, char *argv[]) ); } - // Search for list of objects for this time IOobjectList objects(mesh, runTime.timeName()); @@ -435,7 +434,7 @@ int main(int argc, char *argv[]) PtrList<volTensorField> volTensorFields; ReadFields(mesh, objects, volTensorFields); - //- Uncomment if you want to interpolate surface fields (usually bad idea) + //- Uncomment if you want to interpolate surface fields (usually a bad idea) //Info<< "Reading all current surfaceFields" << endl; //PtrList<surfaceScalarField> surfaceScalarFields; //ReadFields(mesh, objects, surfaceScalarFields); @@ -469,7 +468,7 @@ int main(int argc, char *argv[]) // Bypass runTime write (since only writes at writeTime) if ( - !runTime.objectRegistry::writeObject + !runTime.objectRegistry::writeObject ( runTime.writeFormat(), IOstream::currentVersion, diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C index 8023a5d98b2..ee40ecc48a9 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +36,7 @@ namespace Foam } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::polyTopoChanger::readModifiers() { @@ -73,7 +73,6 @@ void Foam::polyTopoChanger::readModifiers() ); } - // Check state of IOstream is.check(FUNCTION_NAME); close(); @@ -81,6 +80,8 @@ void Foam::polyTopoChanger::readModifiers() } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + Foam::polyTopoChanger::polyTopoChanger ( const IOobject& io, @@ -95,10 +96,14 @@ Foam::polyTopoChanger::polyTopoChanger } -Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) +Foam::polyTopoChanger::polyTopoChanger +( + polyMesh& mesh, + const IOobject::readOption rOpt + +) : - PtrList<polyMeshModifier>(), - regIOobject + polyTopoChanger ( IOobject ( @@ -107,32 +112,36 @@ Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) ( mesh.meshDir(), "meshModifiers", - IOobject::READ_IF_PRESENT + rOpt ), mesh.meshSubDir, mesh, - IOobject::READ_IF_PRESENT, + rOpt, IOobject::NO_WRITE - ) - ), - mesh_(mesh) -{ - readModifiers(); -} + ), + mesh + ) +{} + + +Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) +: + polyTopoChanger(mesh, IOobject::readOption::READ_IF_PRESENT) +{} Foam::wordList Foam::polyTopoChanger::types() const { const PtrList<polyMeshModifier>& modifiers = *this; - wordList t(modifiers.size()); + wordList lst(modifiers.size()); - forAll(modifiers, modifierI) + forAll(modifiers, i) { - t[modifierI] = modifiers[modifierI].type(); + lst[i] = modifiers[i].type(); } - return t; + return lst; } @@ -140,14 +149,14 @@ Foam::wordList Foam::polyTopoChanger::names() const { const PtrList<polyMeshModifier>& modifiers = *this; - wordList t(modifiers.size()); + wordList lst(modifiers.size()); - forAll(modifiers, modifierI) + forAll(modifiers, i) { - t[modifierI] = modifiers[modifierI].name(); + lst[i] = modifiers[i].name(); } - return t; + return lst; } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H index b9f4cbff2e5..94ff7bea97c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,13 +69,13 @@ class polyTopoChanger { // Private Member Functions + void readModifiers(); + //- Disallow default bitwise copy construct - polyTopoChanger(const polyTopoChanger&); + polyTopoChanger(const polyTopoChanger&) = delete; //- Disallow default bitwise assignment - void operator=(const polyTopoChanger&); - - void readModifiers(); + void operator=(const polyTopoChanger&) = delete; protected: @@ -93,11 +93,15 @@ public: // Constructors - //- Read constructor given IOobject and a polyMesh - polyTopoChanger(const IOobject&, polyMesh&); + //- Read construct given IOobject and a polyMesh + polyTopoChanger(const IOobject& io, polyMesh& mesh); + + //- Read construct for given polyMesh and read-option + polyTopoChanger(polyMesh& mesh, const IOobject::readOption rOpt); - //- Read constructor for given polyMesh - explicit polyTopoChanger(polyMesh&); + //- Read construct for given polyMesh. + // Uses read-option READ_IF_PRESENT + explicit polyTopoChanger(polyMesh& mesh); //- Destructor -- GitLab From 90c8c6d174fc866e12618192dfafea1bc0cba4c9 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 4 Oct 2017 08:50:00 +0200 Subject: [PATCH 015/126] STYLE: add setHit/setMiss methods to objectHit - consistency with PointHit and PointIndexHit --- .../meshes/primitiveShapes/objectHit/PointHit.H | 4 ++++ .../primitiveShapes/objectHit/objectHit.H | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H index 1c55ad2d05c..7664b3cc863 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H @@ -117,6 +117,8 @@ public: // Member Functions + // Access + //- Is there a hit bool hit() const { @@ -167,6 +169,8 @@ public: return eligibleMiss_; } + // Edit + void setHit() { hit_ = true; diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H index dd8a081b6df..e4637ecde19 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,6 +83,8 @@ public: // Member Functions + // Access + //- Is there a hit inline bool hit() const { @@ -96,6 +98,19 @@ public: } + // Edit + + void setHit() + { + hit_ = true; + } + + void setMiss() + { + hit_ = false; + } + + // Ostream operator inline friend Ostream& operator<<(Ostream& os, const objectHit& obj) -- GitLab From 44cfc93b82aecdeac93aef933ba88ec58c44842c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 4 Oct 2017 08:50:30 +0200 Subject: [PATCH 016/126] STYLE: replace unused indirect{Cell,Face,Point}List typedefs - provide shorter versions: pointIndList, pointUIndList, etc. and indirect versions of commonly used types: labelIndList, scalarIndList, vectorIndList --- .../cell/cellIndList.H} | 22 +++++-- .../meshes/meshShapes/cell/cellList.H | 31 ++++++---- .../cell/cellListFwd.H} | 22 ++++--- .../edge/edgeIndList.H} | 22 +++++-- .../meshes/meshShapes/edge/edgeList.H | 24 ++++++++ .../meshes/meshShapes/face/faceIndList.H | 58 +++++++++++++++++++ .../meshes/meshShapes/face/faceList.H | 21 ++++++- .../meshes/meshShapes/face/faceListFwd.H | 6 +- .../zones/faceZone/primitiveFaceZone.H | 2 +- .../primitivePatch/indirectPrimitivePatch.H | 2 +- .../primitivePatch/uindirectPrimitivePatch.H | 2 +- .../primitiveShapes/point/pointIndList.H | 58 +++++++++++++++++++ .../meshes/primitiveShapes/point/pointList.H | 21 +++++-- src/OpenFOAM/primitives/Pair/labelPair.H | 12 +++- .../primitives/Scalar/lists/scalarIndList.H | 58 +++++++++++++++++++ .../primitives/Scalar/lists/scalarList.C | 3 - .../primitives/Scalar/lists/scalarList.H | 15 ++++- .../primitives/Vector/lists/vectorIndList.H | 58 +++++++++++++++++++ .../primitives/Vector/lists/vectorList.H | 16 ++++- .../primitives/ints/lists/labelIndList.H | 58 +++++++++++++++++++ .../primitives/ints/lists/labelList.H | 18 ++++-- .../primitives/strings/lists/fileNameList.H | 9 ++- .../primitives/strings/lists/stringList.H | 9 ++- .../primitives/strings/lists/wordList.H | 9 ++- 24 files changed, 500 insertions(+), 56 deletions(-) rename src/OpenFOAM/meshes/{polyMesh/zones/faceZone/indirectFaceList.H => meshShapes/cell/cellIndList.H} (77%) rename src/OpenFOAM/meshes/{polyMesh/zones/cellZone/indirectCellList.H => meshShapes/cell/cellListFwd.H} (78%) rename src/OpenFOAM/meshes/{polyMesh/zones/pointZone/indirectPointList.H => meshShapes/edge/edgeIndList.H} (77%) create mode 100644 src/OpenFOAM/meshes/meshShapes/face/faceIndList.H create mode 100644 src/OpenFOAM/meshes/primitiveShapes/point/pointIndList.H create mode 100644 src/OpenFOAM/primitives/Scalar/lists/scalarIndList.H create mode 100644 src/OpenFOAM/primitives/Vector/lists/vectorIndList.H create mode 100644 src/OpenFOAM/primitives/ints/lists/labelIndList.H diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/indirectFaceList.H b/src/OpenFOAM/meshes/meshShapes/cell/cellIndList.H similarity index 77% rename from src/OpenFOAM/meshes/polyMesh/zones/faceZone/indirectFaceList.H rename to src/OpenFOAM/meshes/meshShapes/cell/cellIndList.H index 81a125cfe66..26a5b634ca7 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/indirectFaceList.H +++ b/src/OpenFOAM/meshes/meshShapes/cell/cellIndList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,23 +22,33 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Typedef - Foam::indirectFaceList + Foam::cellIndList Description + An IndirectList of cells. + +Typedef + Foam::cellUIndList + +Description + A UIndirectList of cells. \*---------------------------------------------------------------------------*/ -#ifndef indirectFaceList_H -#define indirectFaceList_H +#ifndef cellIndList_H +#define cellIndList_H -#include "face.H" +// Include all normal list typedefs as well +#include "cellList.H" #include "IndirectList.H" +#include "UIndirectList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - typedef IndirectList<face> indirectFaceList; + typedef IndirectList<cell> cellIndList; + typedef UIndirectList<cell> cellUIndList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cellList.H b/src/OpenFOAM/meshes/meshShapes/cell/cellList.H index 5f776bb7aed..e878ce05958 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/cellList.H +++ b/src/OpenFOAM/meshes/meshShapes/cell/cellList.H @@ -25,7 +25,25 @@ Typedef Foam::cellList Description - list of cells + A List of cells. + +Typedef + Foam::cellUList + +Description + A UList of cells. + +Typedef + Foam::cellSubList + +Description + A SubList of cells. + +Typedef + Foam::cellListList + +Description + A List of cellList. \*---------------------------------------------------------------------------*/ @@ -34,15 +52,8 @@ Description #include "cell.H" #include "List.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef List<cell> cellList; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "SubList.H" +#include "cellListFwd.H" #endif diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/indirectCellList.H b/src/OpenFOAM/meshes/meshShapes/cell/cellListFwd.H similarity index 78% rename from src/OpenFOAM/meshes/polyMesh/zones/cellZone/indirectCellList.H rename to src/OpenFOAM/meshes/meshShapes/cell/cellListFwd.H index 0ac8c1c38e5..c616384a7aa 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/indirectCellList.H +++ b/src/OpenFOAM/meshes/meshShapes/cell/cellListFwd.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,24 +21,30 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Typedef - Foam::indirectCellList +Header + cellListFwd.H Description + Forwards for various types of cell lists \*---------------------------------------------------------------------------*/ -#ifndef indirectCellList_H -#define indirectCellList_H +#ifndef cellListFwd_H +#define cellListFwd_H -#include "cell.H" -#include "IndirectList.H" +#include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - typedef IndirectList<cell> indirectCellList; + class cell; + + typedef UList<cell> cellUList; + typedef List<cell> cellList; + typedef SubList<cell> cellSubList; + typedef List<cellList> cellListList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/indirectPointList.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeIndList.H similarity index 77% rename from src/OpenFOAM/meshes/polyMesh/zones/pointZone/indirectPointList.H rename to src/OpenFOAM/meshes/meshShapes/edge/edgeIndList.H index 87f963d7408..2cd77b797ea 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/indirectPointList.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeIndList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,23 +22,33 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Typedef - Foam::indirectPointList + Foam::edgeIndList Description + An IndirectList of edges. + +Typedef + Foam::edgeUIndList + +Description + A UIndirectList of edges. \*---------------------------------------------------------------------------*/ -#ifndef indirectPointList_H -#define indirectPointList_H +#ifndef edgeIndList_H +#define edgeIndList_H -#include "point.H" +// Include all normal list typedefs as well +#include "edgeList.H" #include "IndirectList.H" +#include "UIndirectList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - typedef IndirectList<point> indirectPointList; + typedef IndirectList<edge> edgeIndList; + typedef UIndirectList<edge> edgeUIndList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H index 177a36aeb48..17f0ab96e28 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H @@ -24,18 +24,42 @@ License Typedef Foam::edgeList +Description + A List of edges. + +Typedef + Foam::edgeUList + +Description + A UList of edges. + +Typedef + Foam::edgeSubList + +Description + A SubList of edges. + +Typedef + Foam::edgeListList + +Description + A List of edgeList. + \*---------------------------------------------------------------------------*/ #ifndef edgeList_H #define edgeList_H #include "edge.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { + typedef UList<edge> edgeUList; typedef List<edge> edgeList; + typedef SubList<edge> edgeSubList; typedef List<edgeList> edgeListList; } diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceIndList.H b/src/OpenFOAM/meshes/meshShapes/face/faceIndList.H new file mode 100644 index 00000000000..b7a89ee7374 --- /dev/null +++ b/src/OpenFOAM/meshes/meshShapes/face/faceIndList.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Typedef + Foam::faceIndList + +Description + An IndirectList of faces. + +Typedef + Foam::faceUIndList + +Description + A UIndirectList of faces. + +\*---------------------------------------------------------------------------*/ + +#ifndef faceIndList_H +#define faceIndList_H + +// Include all normal list typedefs as well +#include "faceList.H" +#include "IndirectList.H" +#include "UIndirectList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IndirectList<face> faceIndList; + typedef UIndirectList<face> faceUIndList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceList.H b/src/OpenFOAM/meshes/meshShapes/face/faceList.H index 19684fff190..337b3f24029 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceList.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceList.H @@ -25,6 +25,25 @@ Typedef Foam::faceList Description + A List of faces. + +Typedef + Foam::faceUList + +Description + A UList of faces. + +Typedef + Foam::faceSubList + +Description + A SubList of faces. + +Typedef + Foam::faceListList + +Description + A List of faceList. \*---------------------------------------------------------------------------*/ @@ -36,8 +55,6 @@ Description #include "SubList.H" #include "faceListFwd.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H b/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H index 0caf8a454a2..fadad20bebd 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H @@ -21,10 +21,11 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Typedef - Foam::faceListFwd +Header + faceListFwd.H Description + Forwards for various types of face lists \*---------------------------------------------------------------------------*/ @@ -39,6 +40,7 @@ Description namespace Foam { class face; + typedef UList<face> faceUList; typedef List<face> faceList; typedef SubList<face> faceSubList; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H index 18f1147ac0e..aa887135152 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H @@ -33,7 +33,7 @@ Description #include "face.H" #include "PrimitivePatch.H" -#include "indirectFaceList.H" +#include "IndirectList.H" #include "pointField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H index 2899d00149a..3d7733deba0 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H @@ -25,7 +25,7 @@ Typedef Foam::indirectPrimitivePatch Description - Foam::indirectPrimitivePatch + A PrimitivePatch using an IndirectList for the faces. \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H index 0bb30e55fbf..630e9e5be08 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H @@ -25,7 +25,7 @@ Typedef Foam::uindirectPrimitivePatch Description - Foam::uindirectPrimitivePatch + A PrimitivePatch using a UIndirectList for the faces. \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/meshes/primitiveShapes/point/pointIndList.H b/src/OpenFOAM/meshes/primitiveShapes/point/pointIndList.H new file mode 100644 index 00000000000..e27e72a629a --- /dev/null +++ b/src/OpenFOAM/meshes/primitiveShapes/point/pointIndList.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Typedef + Foam::pointIndList + +Description + An IndirectList of points. + +Typedef + Foam::pointUIndList + +Description + A UIndirectList of points. + +\*---------------------------------------------------------------------------*/ + +#ifndef pointIndList_H +#define pointIndList_H + +// Include all normal list typedefs as well +#include "pointList.H" +#include "IndirectList.H" +#include "UIndirectList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IndirectList<point> pointIndList; + typedef UIndirectList<point> pointUIndList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H index 8eab5ae007f..aa3d96e8c9f 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H +++ b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H @@ -25,13 +25,25 @@ Typedef Foam::pointList Description - A List of points + A List of points. + +Typedef + Foam::pointUList + +Description + A UList of points. + +Typedef + Foam::pointSubList + +Description + A SubList of points. Typedef Foam::pointListList Description - A List of labelList + A List of pointList. \*---------------------------------------------------------------------------*/ @@ -40,14 +52,15 @@ Description #include "point.H" #include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - // Note: frequently used UList version is located in container itself - + typedef UList<point> pointUList; typedef List<point> pointList; + typedef SubList<point> pointSubList; typedef List<pointList> pointListList; } diff --git a/src/OpenFOAM/primitives/Pair/labelPair.H b/src/OpenFOAM/primitives/Pair/labelPair.H index 0e798e7b151..a2fa0f1168d 100644 --- a/src/OpenFOAM/primitives/Pair/labelPair.H +++ b/src/OpenFOAM/primitives/Pair/labelPair.H @@ -37,13 +37,19 @@ Typedef Foam::labelPairList Description - List of labelPairs + List of labelPairs. Typedef Foam::labelPairUList Description - UList of labelPairs + UList of labelPairs. + +Typedef + Foam::labelPairSubList + +Description + A SubList of labelPairs. \*---------------------------------------------------------------------------*/ @@ -51,6 +57,7 @@ Description #define labelPair_H #include "List.H" +#include "SubList.H" #include "Pair.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,6 +68,7 @@ namespace Foam typedef Pair<labelPair> labelPairPair; typedef List<labelPair> labelPairList; typedef UList<labelPair> labelPairUList; + typedef SubList<labelPair> labelPairSubList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Scalar/lists/scalarIndList.H b/src/OpenFOAM/primitives/Scalar/lists/scalarIndList.H new file mode 100644 index 00000000000..00a2a37050f --- /dev/null +++ b/src/OpenFOAM/primitives/Scalar/lists/scalarIndList.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Typedef + Foam::scalarIndList + +Description + An IndirectList of scalars. + +Typedef + Foam::scalarUIndList + +Description + A UIndirectList of scalars. + +\*---------------------------------------------------------------------------*/ + +#ifndef scalarIndList_H +#define scalarIndList_H + +// Include all normal list typedefs as well +#include "scalarList.H" +#include "IndirectList.H" +#include "UIndirectList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IndirectList<scalar> scalarIndList; + typedef UIndirectList<scalar> scalarUIndList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Scalar/lists/scalarList.C b/src/OpenFOAM/primitives/Scalar/lists/scalarList.C index 8b81dba9849..24a5f392cf4 100644 --- a/src/OpenFOAM/primitives/Scalar/lists/scalarList.C +++ b/src/OpenFOAM/primitives/Scalar/lists/scalarList.C @@ -21,9 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Specialisation of List\<T\> for scalar. - \*---------------------------------------------------------------------------*/ #include "scalarList.H" diff --git a/src/OpenFOAM/primitives/Scalar/lists/scalarList.H b/src/OpenFOAM/primitives/Scalar/lists/scalarList.H index eaad958adba..ef366eafde4 100644 --- a/src/OpenFOAM/primitives/Scalar/lists/scalarList.H +++ b/src/OpenFOAM/primitives/Scalar/lists/scalarList.H @@ -33,6 +33,18 @@ Typedef Description A List of scalars. +Typedef + Foam::scalarSubList + +Description + A SubList of scalars. + +Typedef + Foam::scalarListList + +Description + A List of scalarList. + \*---------------------------------------------------------------------------*/ #ifndef scalarList_H @@ -40,14 +52,15 @@ Description #include "scalar.H" #include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { typedef UList<scalar> scalarUList; - typedef List<scalar> scalarList; + typedef SubList<scalar> scalarSubList; typedef List<scalarList> scalarListList; } diff --git a/src/OpenFOAM/primitives/Vector/lists/vectorIndList.H b/src/OpenFOAM/primitives/Vector/lists/vectorIndList.H new file mode 100644 index 00000000000..b035cb45657 --- /dev/null +++ b/src/OpenFOAM/primitives/Vector/lists/vectorIndList.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Typedef + Foam::vectorIndList + +Description + An IndirectList of vectors. + +Typedef + Foam::vectorUIndList + +Description + A UIndirectList of vectors. + +\*---------------------------------------------------------------------------*/ + +#ifndef vectorIndList_H +#define vectorIndList_H + +// Include all normal list typedefs as well +#include "vectorList.H" +#include "IndirectList.H" +#include "UIndirectList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IndirectList<vector> vectorIndList; + typedef UIndirectList<vector> vectorUIndList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector/lists/vectorList.H b/src/OpenFOAM/primitives/Vector/lists/vectorList.H index ba921ced145..a582586c4e6 100644 --- a/src/OpenFOAM/primitives/Vector/lists/vectorList.H +++ b/src/OpenFOAM/primitives/Vector/lists/vectorList.H @@ -33,6 +33,18 @@ Typedef Description A List of vectors. +Typedef + Foam::vectorSubList + +Description + A SubList of vectors. + +Typedef + Foam::vectorListList + +Description + A List of vectorList. + \*---------------------------------------------------------------------------*/ #ifndef vectorList_H @@ -40,14 +52,16 @@ Description #include "vector.H" #include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { typedef UList<vector> vectorUList; - typedef List<vector> vectorList; + typedef SubList<vector> vectorSubList; + typedef List<vectorList> vectorListList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/ints/lists/labelIndList.H b/src/OpenFOAM/primitives/ints/lists/labelIndList.H new file mode 100644 index 00000000000..3a20c2469cc --- /dev/null +++ b/src/OpenFOAM/primitives/ints/lists/labelIndList.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Typedef + Foam::labelIndList + +Description + A IndirectList of labels. + +Typedef + Foam::labelUIndList + +Description + An UIndirectList of labels. + +\*---------------------------------------------------------------------------*/ + +#ifndef labelIndList_H +#define labelIndList_H + +// Include all normal list typedefs as well +#include "labelList.H" +#include "IndirectList.H" +#include "UIndirectList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IndirectList<label> labelIndList; + typedef UIndirectList<label> labelUIndList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/ints/lists/labelList.H b/src/OpenFOAM/primitives/ints/lists/labelList.H index b64aead4439..30536a59a91 100644 --- a/src/OpenFOAM/primitives/ints/lists/labelList.H +++ b/src/OpenFOAM/primitives/ints/lists/labelList.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,19 +25,25 @@ Typedef Foam::labelList Description - A List of labels + A List of labels. + +Typedef + Foam::labelSubList + +Description + A SubList of labels. Typedef Foam::labelListList Description - A List of labelList + A List of labelList. Typedef Foam::labelListListList Description - A List of labelListList + A List of labelListList. \*---------------------------------------------------------------------------*/ @@ -46,14 +52,16 @@ Description #include "label.H" #include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - // Note: frequently used UList version is located in container itself + // Note: frequently used labelUList is defined in UList itself typedef List<label> labelList; + typedef SubList<label> labelSubList; typedef List<labelList> labelListList; typedef List<labelListList> labelListListList; } diff --git a/src/OpenFOAM/primitives/strings/lists/fileNameList.H b/src/OpenFOAM/primitives/strings/lists/fileNameList.H index c4e65aed79a..ee059804526 100644 --- a/src/OpenFOAM/primitives/strings/lists/fileNameList.H +++ b/src/OpenFOAM/primitives/strings/lists/fileNameList.H @@ -33,6 +33,12 @@ Typedef Description A List of fileNames. +Typedef + Foam::fileNameSubList + +Description + A SubList of fileNames. + \*---------------------------------------------------------------------------*/ #ifndef fileNameList_H @@ -40,14 +46,15 @@ Description #include "fileName.H" #include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { typedef UList<fileName> fileNameUList; - typedef List<fileName> fileNameList; + typedef SubList<fileName> fileNameSubList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/strings/lists/stringList.H b/src/OpenFOAM/primitives/strings/lists/stringList.H index af53c186ca8..8c69b339c79 100644 --- a/src/OpenFOAM/primitives/strings/lists/stringList.H +++ b/src/OpenFOAM/primitives/strings/lists/stringList.H @@ -33,6 +33,12 @@ Typedef Description A List of strings. +Typedef + Foam::stringSubList + +Description + A SubList of strings. + \*---------------------------------------------------------------------------*/ #ifndef stringList_H @@ -40,14 +46,15 @@ Description #include "string.H" #include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { typedef UList<string> stringUList; - typedef List<string> stringList; + typedef SubList<string> stringSubList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/strings/lists/wordList.H b/src/OpenFOAM/primitives/strings/lists/wordList.H index ca083041403..a12d2afcb16 100644 --- a/src/OpenFOAM/primitives/strings/lists/wordList.H +++ b/src/OpenFOAM/primitives/strings/lists/wordList.H @@ -33,6 +33,12 @@ Typedef Description A List of words. +Typedef + Foam::wordSubList + +Description + A SubList of words. + \*---------------------------------------------------------------------------*/ #ifndef wordList_H @@ -40,14 +46,15 @@ Description #include "word.H" #include "List.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { typedef UList<word> wordUList; - typedef List<word> wordList; + typedef SubList<word> wordSubList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -- GitLab From 24577907a1c5f6fd5d485b8d83efd663b64fb3c6 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 4 Oct 2017 08:55:00 +0200 Subject: [PATCH 017/126] ENH: add faceZone::resetAddressing with constant flipMap - remove unused static variable, use updated hashtable methods --- .../mesh/manipulation/stitchMesh/stitchMesh.C | 148 ++++++++---------- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C | 16 +- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H | 8 +- .../polyMesh/zones/ZoneMesh/cellZoneMesh.H | 2 - .../polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H | 2 +- .../polyMesh/zones/ZoneMesh/faceZoneMesh.H | 2 - .../polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H | 2 +- .../polyMesh/zones/ZoneMesh/pointZoneMesh.H | 2 - .../zones/ZoneMesh/pointZoneMeshFwd.H | 2 +- .../meshes/polyMesh/zones/cellZone/cellZone.C | 1 + .../meshes/polyMesh/zones/cellZone/cellZone.H | 58 ++++--- .../meshes/polyMesh/zones/faceZone/faceZone.C | 49 +++++- .../meshes/polyMesh/zones/faceZone/faceZone.H | 121 ++++++++------ .../polyMesh/zones/pointZone/pointZone.C | 1 + .../polyMesh/zones/pointZone/pointZone.H | 49 +++--- .../meshes/polyMesh/zones/zone/zone.C | 34 ++-- .../meshes/polyMesh/zones/zone/zone.H | 30 ++-- 17 files changed, 275 insertions(+), 252 deletions(-) diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index 1fa978d1259..9723c1cdb7f 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -76,100 +76,102 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -label addPointZone(const polyMesh& mesh, const word& name) +label addPointZone(polyMesh& mesh, const word& name) { - label zoneID = mesh.pointZones().findZoneID(name); + pointZoneMesh& zones = mesh.pointZones(); + label zoneID = zones.findZoneID(name); if (zoneID != -1) { - Info<< "Reusing existing pointZone " - << mesh.pointZones()[zoneID].name() + Info<< "Reusing existing pointZone " << zones[zoneID].name() << " at index " << zoneID << endl; + + return zoneID; } - else - { - pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh).pointZones(); - zoneID = pointZones.size(); - Info<< "Adding pointZone " << name << " at index " << zoneID << endl; - pointZones.setSize(zoneID+1); - pointZones.set + zoneID = zones.size(); + Info<< "Adding pointZone " << name << " at index " << zoneID << endl; + + zones.setSize(zoneID+1); + zones.set + ( + zoneID, + new pointZone ( + name, + labelList(0), zoneID, - new pointZone - ( - name, - labelList(0), - zoneID, - pointZones - ) - ); - } + zones + ) + ); + return zoneID; } -label addFaceZone(const polyMesh& mesh, const word& name) +label addFaceZone(polyMesh& mesh, const word& name) { - label zoneID = mesh.faceZones().findZoneID(name); + faceZoneMesh& zones = mesh.faceZones(); + label zoneID = zones.findZoneID(name); if (zoneID != -1) { - Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name() + Info<< "Reusing existing faceZone " << zones[zoneID].name() << " at index " << zoneID << endl; + + return zoneID; } - else - { - faceZoneMesh& faceZones = const_cast<polyMesh&>(mesh).faceZones(); - zoneID = faceZones.size(); - Info<< "Adding faceZone " << name << " at index " << zoneID << endl; - faceZones.setSize(zoneID+1); - faceZones.set + zoneID = zones.size(); + Info<< "Adding faceZone " << name << " at index " << zoneID << endl; + + zones.setSize(zoneID+1); + zones.set + ( + zoneID, + new faceZone ( + name, + labelList(0), + boolList(), zoneID, - new faceZone - ( - name, - labelList(0), - boolList(), - zoneID, - faceZones - ) - ); - } + zones + ) + ); + return zoneID; } -label addCellZone(const polyMesh& mesh, const word& name) +label addCellZone(polyMesh& mesh, const word& name) { - label zoneID = mesh.cellZones().findZoneID(name); + cellZoneMesh& zones = mesh.cellZones(); + label zoneID = zones.findZoneID(name); if (zoneID != -1) { - Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name() + Info<< "Reusing existing cellZone " << zones[zoneID].name() << " at index " << zoneID << endl; + + return zoneID; } - else - { - cellZoneMesh& cellZones = const_cast<polyMesh&>(mesh).cellZones(); - zoneID = cellZones.size(); - Info<< "Adding cellZone " << name << " at index " << zoneID << endl; - cellZones.setSize(zoneID+1); - cellZones.set + zoneID = zones.size(); + Info<< "Adding cellZone " << name << " at index " << zoneID << endl; + + zones.setSize(zoneID+1); + zones.set + ( + zoneID, + new cellZone ( + name, + labelList(0), zoneID, - new cellZone - ( - name, - labelList(0), - zoneID, - cellZones - ) - ); - } + zones + ) + ); + return zoneID; } @@ -340,13 +342,9 @@ int main(int argc, char *argv[]) if (perfectCover) { // Add empty zone for resulting internal faces - label cutZoneID = addFaceZone(mesh, cutZoneName); + const label cutZoneID = addFaceZone(mesh, cutZoneName); - mesh.faceZones()[cutZoneID].resetAddressing - ( - isf, - boolList(masterPatch.size(), false) - ); + mesh.faceZones()[cutZoneID].resetAddressing(isf.xfer(), false); // Add the perfect interface mesh modifier stitcher.set @@ -370,11 +368,7 @@ int main(int argc, char *argv[]) label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone"); - mesh.faceZones()[masterZoneID].resetAddressing - ( - isf, - boolList(masterPatch.size(), false) - ); + mesh.faceZones()[masterZoneID].resetAddressing(isf.xfer(), false); // Slave patch const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName]; @@ -387,19 +381,11 @@ int main(int argc, char *argv[]) } label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone"); - mesh.faceZones()[slaveZoneID].resetAddressing - ( - osf, - boolList(slavePatch.size(), false) - ); + mesh.faceZones()[slaveZoneID].resetAddressing(osf.xfer(), false); // Add empty zone for cut faces - label cutZoneID = addFaceZone(mesh, cutZoneName); - mesh.faceZones()[cutZoneID].resetAddressing - ( - labelList(0), - boolList(0, false) - ); + const label cutZoneID = addFaceZone(mesh, cutZoneName); + mesh.faceZones()[cutZoneID].resetAddressing(labelList(0), false); // Add the sliding interface mesh modifier diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index 066c9c268f8..9c67afde9b4 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -247,17 +247,7 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::whichZone const label objectIndex ) const { - const Map<label>& zm = zoneMap(); - Map<label>::const_iterator zmIter = zm.find(objectIndex); - - if (zmIter == zm.end()) - { - return -1; - } - else - { - return zmIter(); - } + return zoneMap().lookup(objectIndex, -1); } @@ -579,13 +569,13 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::checkParallelSync template<class ZoneType, class MeshType> -void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& p) +void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& pts) { PtrList<ZoneType>& zones = *this; forAll(zones, zonei) { - zones[zonei].movePoints(p); + zones[zonei].movePoints(pts); } } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index d76823b8522..9c83890d767 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -176,7 +176,7 @@ public: //- Return zone index for the first match, return -1 if not found label findIndex(const keyType& key) const; - //- Find zone index given a name + //- Find zone index given a name, return -1 if not found label findZoneID(const word& zoneName) const; //- Mark cells that match the zone specification @@ -191,12 +191,12 @@ public: //- Check zone definition. Return true if in error. bool checkDefinition(const bool report = false) const; - //- Check whether all procs have all zones and in same order. Return - // true if in error. + //- Check whether all procs have all zones and in same order. + // \return True if any errors. bool checkParallelSync(const bool report = false) const; //- Correct zone mesh after moving points - void movePoints(const pointField& p); + void movePoints(const pointField& pts); //- writeData member function required by regIOobject bool writeData(Ostream& os) const; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H index bd760cbcced..fdb46615524 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H @@ -33,8 +33,6 @@ Description #include "cellZone.H" #include "cellZoneMeshFwd.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H index 2ddd1eda9e5..9d3eca8b9ff 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H @@ -36,10 +36,10 @@ Description namespace Foam { - template<class Zone, class MeshType> class ZoneMesh; class cellZone; class polyMesh; + template<class Zone, class MeshType> class ZoneMesh; typedef ZoneMesh<cellZone, polyMesh> cellZoneMesh; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H index 3f9a51c2b74..d0a41ea5ef3 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H @@ -33,8 +33,6 @@ Description #include "faceZone.H" #include "faceZoneMeshFwd.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H index 9642d2e5530..89d66b6baf4 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H @@ -36,10 +36,10 @@ Description namespace Foam { - template<class Zone, class MeshType> class ZoneMesh; class faceZone; class polyMesh; + template<class Zone, class MeshType> class ZoneMesh; typedef ZoneMesh<faceZone, polyMesh> faceZoneMesh; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H index 13bdddd5f95..c2547c19e02 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H @@ -33,8 +33,6 @@ Description #include "pointZone.H" #include "pointZoneMeshFwd.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H index 24974a68b13..6cc67017bc4 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H @@ -36,10 +36,10 @@ Description namespace Foam { - template<class Zone, class MeshType> class ZoneMesh; class pointZone; class polyMesh; + template<class Zone, class MeshType> class ZoneMesh; typedef ZoneMesh<pointZone, polyMesh> pointZoneMesh; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C index c59ec220911..4940529e115 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C @@ -42,6 +42,7 @@ namespace Foam const char * const Foam::cellZone::labelsName = "cellLabels"; + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cellZone::cellZone diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H index c5027f3eaae..3d3658b207e 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H @@ -52,7 +52,7 @@ namespace Foam // Forward declaration of friend functions and operators class cellZone; -Ostream& operator<<(Ostream&, const cellZone&); +Ostream& operator<<(Ostream& os, const cellZone& zn); /*---------------------------------------------------------------------------*\ @@ -64,6 +64,12 @@ class cellZone public zone { + // Private Member Functions + + //- Disallow default bitwise copy construct + cellZone(const cellZone&) = delete; + + protected: // Protected data @@ -72,14 +78,6 @@ protected: const cellZoneMesh& zoneMesh_; -private: - - // Private Member Functions - - //- Disallow default bitwise copy construct - cellZone(const cellZone&); - - public: // Static data members @@ -117,7 +115,7 @@ public: const word& name, const labelUList& addr, const label index, - const cellZoneMesh& + const cellZoneMesh& zm ); //- Construct from components, transferring contents @@ -126,36 +124,36 @@ public: const word& name, const Xfer<labelList>& addr, const label index, - const cellZoneMesh& + const cellZoneMesh& zm ); //- Construct from dictionary cellZone ( const word& name, - const dictionary&, + const dictionary& dict, const label index, - const cellZoneMesh& + const cellZoneMesh& zm ); - //- Construct given the original zone and resetting the - // cell list and zone mesh information + //- Construct given the original zone, + // resetting the cell list and zone mesh information cellZone ( - const cellZone&, + const cellZone& cz, const labelUList& addr, const label index, - const cellZoneMesh& + const cellZoneMesh& zm ); - //- Construct given the original zone, resetting the - // cell list and zone mesh information + //- Construct given the original zone, + // resetting the cell list and zone mesh information cellZone ( - const cellZone&, + const cellZone& cz, const Xfer<labelList>& addr, const label index, - const cellZoneMesh& + const cellZoneMesh& zm ); //- Construct and return a clone, resetting the zone mesh @@ -190,9 +188,9 @@ public: static autoPtr<cellZone> New ( const word& name, - const dictionary&, + const dictionary& dict, const label index, - const cellZoneMesh& + const cellZoneMesh& zm ); @@ -211,33 +209,33 @@ public: //- Check zone definition. Return true if in error. virtual bool checkDefinition(const bool report = false) const; - //- Check whether zone is synchronised across coupled boundaries. Return - // true if in error. + //- Check whether zone is synchronised across coupled boundaries. + // \return True if any errors. virtual bool checkParallelSync(const bool report = false) const { return false; } //- Write dictionary - virtual void writeDict(Ostream&) const; + virtual void writeDict(Ostream& os) const; // Member Operators //- Assign to zone, clearing demand-driven data - void operator=(const cellZone&); + void operator=(const cellZone& zn); //- Assign addressing, clearing demand-driven data - void operator=(const labelUList&); + void operator=(const labelUList& addr); //- Assign addressing, clearing demand-driven data - void operator=(const Xfer<labelList>&); + void operator=(const Xfer<labelList>& addr); // I-O //- Ostream Operator - friend Ostream& operator<<(Ostream&, const cellZone&); + friend Ostream& operator<<(Ostream& os, const cellZone& zn); }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C index 459e8002d7e..f91a48b9e33 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C @@ -43,6 +43,23 @@ namespace Foam const char* const Foam::faceZone::labelsName = "faceLabels"; +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::faceZone::setFlipMap(const bool flipValue) +{ + // Match size for flipMap + if (flipMap_.size() == this->size()) + { + flipMap_ = flipValue; + } + else + { + // Avoid copying old values on resize + flipMap_.clear(); + flipMap_.setSize(this->size(), flipValue); + } +} + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -128,8 +145,8 @@ void Foam::faceZone::calcCellLayers() const forAll(mf, facei) { - label ownCelli = own[mf[facei]]; - label neiCelli = + const label ownCelli = own[mf[facei]]; + const label neiCelli = ( zoneMesh().mesh().isInternalFace(mf[facei]) ? nei[mf[facei]] @@ -386,6 +403,30 @@ void Foam::faceZone::resetAddressing } +void Foam::faceZone::resetAddressing +( + const labelUList& addr, + const bool flipValue +) +{ + clearAddressing(); + labelList::operator=(addr); + setFlipMap(flipValue); +} + + +void Foam::faceZone::resetAddressing +( + const Xfer<labelList>& addr, + const bool flipValue +) +{ + clearAddressing(); + labelList::operator=(addr); + setFlipMap(flipValue); +} + + void Foam::faceZone::updateMesh(const mapPolyMesh& mpm) { clearAddressing(); @@ -511,11 +552,11 @@ bool Foam::faceZone::checkParallelSync(const bool report) const } -void Foam::faceZone::movePoints(const pointField& p) +void Foam::faceZone::movePoints(const pointField& pts) { if (patchPtr_) { - patchPtr_->movePoints(p); + patchPtr_->movePoints(pts); } } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H index 253c78e1da5..5a6896db7c1 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H @@ -55,7 +55,7 @@ class mapPolyMesh; // Forward declaration of friend functions and operators class faceZone; -Ostream& operator<<(Ostream&, const faceZone&); +Ostream& operator<<(Ostream& os, const faceZone& zn); /*---------------------------------------------------------------------------*\ @@ -66,46 +66,43 @@ class faceZone : public zone { - // Private data - - //- The name associated with the zone-labels dictionary entry - static const word labelsName_; - - // Private Member Functions + //- Set flip-map to constant value + void setFlipMap(const bool flipValue); + //- Disallow default bitwise copy construct - faceZone(const faceZone&); + faceZone(const faceZone&) = delete; //- Disallow default bitwise assignment - void operator=(const faceZone&); + void operator=(const faceZone&) = delete; protected: // Protected data - //- Flip map for all faces in the zone. Set to true if the - // face needs to be flipped to achieve the correct orientation. + //- Flip map for all faces in the zone. + // Use true if the face needs flipping for the correct orientation. boolList flipMap_; //- Reference to zone list const faceZoneMesh& zoneMesh_; - // Demand-driven private data + // Demand-driven data - //- Primitive patch made out of correctly flipped faces - mutable primitiveFacePatch* patchPtr_; + //- Primitive patch made out of correctly flipped faces + mutable primitiveFacePatch* patchPtr_; - //- Master cell layer - mutable labelList* masterCellsPtr_; + //- Master cell layer + mutable labelList* masterCellsPtr_; - //- Slave cell layer - mutable labelList* slaveCellsPtr_; + //- Slave cell layer + mutable labelList* slaveCellsPtr_; - //- Global edge addressing - mutable labelList* mePtr_; + //- Global edge addressing + mutable labelList* mePtr_; // Protected Member Functions @@ -168,38 +165,38 @@ public: const Xfer<labelList>& addr, const Xfer<boolList>& fm, const label index, - const faceZoneMesh& + const faceZoneMesh& zm ); //- Construct from dictionary faceZone ( const word& name, - const dictionary&, + const dictionary& dict, const label index, - const faceZoneMesh& + const faceZoneMesh& zm ); //- Construct given the original zone and resetting the // face list and zone mesh information faceZone ( - const faceZone&, + const faceZone& fz, const labelUList& addr, const boolList& fm, const label index, - const faceZoneMesh& + const faceZoneMesh& zm ); - //- Construct given the original zone, resetting the - // face list and zone mesh information + //- Construct given the original zone, + // resetting the face list and zone mesh information faceZone ( - const faceZone&, + const faceZone& fz, const Xfer<labelList>& addr, const Xfer<boolList>& fm, const label index, - const faceZoneMesh& + const faceZoneMesh& zm ); //- Construct and return a clone, resetting the zone mesh @@ -235,9 +232,9 @@ public: static autoPtr<faceZone> New ( const word& name, - const dictionary&, + const dictionary& dict, const label index, - const faceZoneMesh& + const faceZoneMesh& zm ); @@ -247,6 +244,9 @@ public: // Member Functions + //- Return zoneMesh reference + const faceZoneMesh& zoneMesh() const; + //- Return face flip map const boolList& flipMap() const { @@ -259,52 +259,71 @@ public: //- Return reference to primitive patch const primitiveFacePatch& operator()() const; - //- Return zoneMesh reference - const faceZoneMesh& zoneMesh() const; - - // Addressing into mesh + // Addressing into mesh - //- Return labels of master cells (cells next to the master face - // zone in the prescribed direction) - const labelList& masterCells() const; + //- Return labels of master cells (cells next to the master face + // zone in the prescribed direction) + const labelList& masterCells() const; - //- Return labels of slave cells - const labelList& slaveCells() const; + //- Return labels of slave cells + const labelList& slaveCells() const; - //- Return global edge index for local edges - const labelList& meshEdges() const; + //- Return global edge index for local edges + const labelList& meshEdges() const; //- Clear addressing virtual void clearAddressing(); - //- Reset addressing and flip map (clearing demand-driven data) - virtual void resetAddressing(const labelUList&, const boolList&); + //- Reset addressing and flip map. + // Clears demand-driven data. + virtual void resetAddressing + ( + const labelUList& addr, + const boolList& flipMap + ); + + //- Reset addressing - use constant flip map + // Clears demand-driven data. + virtual void resetAddressing + ( + const labelUList& addr, + const bool flipValue + ); + + //- Reset addressing - use constant flip map + // Clears demand-driven data. + virtual void resetAddressing + ( + const Xfer<labelList>& addr, + const bool flipValue + ); //- Check zone definition. Return true if in error. virtual bool checkDefinition(const bool report = false) const; - //- Check whether all procs have faces synchronised. Return - // true if in error. + //- Check whether all procs have faces synchronised. + // \return True if any errors. virtual bool checkParallelSync(const bool report = false) const; //- Correct patch after moving points - virtual void movePoints(const pointField&); + virtual void movePoints(const pointField& pts); //- Update for changes in topology - virtual void updateMesh(const mapPolyMesh&); + virtual void updateMesh(const mapPolyMesh& mpm); //- Write - virtual void write(Ostream&) const; + virtual void write(Ostream& os) const; //- Write dictionary - virtual void writeDict(Ostream&) const; + virtual void writeDict(Ostream& os) const; + // I-O //- Ostream Operator - friend Ostream& operator<<(Ostream&, const faceZone&); + friend Ostream& operator<<(Ostream& os, const faceZone& zn); }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C index 31680ccf1a0..7a197bef349 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C @@ -42,6 +42,7 @@ namespace Foam const char* const Foam::pointZone::labelsName = "pointLabels"; + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::pointZone::pointZone diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H index 9bc911153ad..d8e71270b0c 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H @@ -53,7 +53,7 @@ namespace Foam // Forward declaration of friend functions and operators class pointZone; -Ostream& operator<<(Ostream&, const pointZone&); +Ostream& operator<<(Ostream& os, const pointZone& zn); /*---------------------------------------------------------------------------*\ @@ -64,6 +64,11 @@ class pointZone : public zone { + // Private Member Functions + + //- Disallow default bitwise copy construct + pointZone(const pointZone&) = delete; + protected: @@ -72,10 +77,6 @@ protected: //- Reference to zone list const pointZoneMesh& zoneMesh_; - // Private Member Functions - - //- Disallow default bitwise copy construct - pointZone(const pointZone&); public: @@ -114,7 +115,7 @@ public: const word& name, const labelUList& addr, const label index, - const pointZoneMesh& + const pointZoneMesh& zm ); //- Construct from components, transferring contents @@ -123,36 +124,36 @@ public: const word& name, const Xfer<labelList>& addr, const label index, - const pointZoneMesh& + const pointZoneMesh& zm ); //- Construct from dictionary pointZone ( const word& name, - const dictionary&, + const dictionary& dict, const label index, - const pointZoneMesh& + const pointZoneMesh& zm ); //- Construct given the original zone and resetting the // point list and zone mesh information pointZone ( - const pointZone&, + const pointZone& pz, const labelUList& addr, const label index, - const pointZoneMesh& + const pointZoneMesh& zm ); - //- Construct given the original zone, resetting the - // face list and zone mesh information + //- Construct given the original zone, + // resetting the point list and zone mesh information pointZone ( - const pointZone&, + const pointZone& pz, const Xfer<labelList>& addr, const label index, - const pointZoneMesh& + const pointZoneMesh& zm ); //- Construct and return a clone, resetting the zone mesh @@ -187,9 +188,9 @@ public: static autoPtr<pointZone> New ( const word& name, - const dictionary&, + const dictionary& dict, const label index, - const pointZoneMesh& + const pointZoneMesh& zm ); @@ -208,8 +209,8 @@ public: //- Check zone definition. Return true if in error. virtual bool checkDefinition(const bool report = false) const; - //- Check whether zone is synchronised across coupled boundaries. Return - // true if in error. + //- Check whether zone is synchronised across coupled boundaries. + // \return True if any errors. virtual bool checkParallelSync(const bool report = false) const; //- Correct patch after moving points @@ -217,25 +218,25 @@ public: {} //- Write dictionary - virtual void writeDict(Ostream&) const; + virtual void writeDict(Ostream& os) const; // Member Operators //- Assign to zone, clearing demand-driven data - void operator=(const pointZone&); + void operator=(const pointZone& zn); //- Assign addressing, clearing demand-driven data - void operator=(const labelUList&); + void operator=(const labelUList& addr); //- Assign addressing, clearing demand-driven data - void operator=(const Xfer<labelList>&); + void operator=(const Xfer<labelList>& addr); // I-O //- Ostream Operator - friend Ostream& operator<<(Ostream&, const pointZone&); + friend Ostream& operator<<(Ostream& os, const pointZone& zn); }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C index 5ff0eebb7b4..8e11bc24a71 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C @@ -127,13 +127,13 @@ Foam::zone::zone Foam::zone::zone ( - const zone& z, + const zone& zn, const labelUList& addr, const label index ) : labelList(addr), - name_(z.name()), + name_(zn.name()), index_(index), lookupMapPtr_(nullptr) {} @@ -141,13 +141,13 @@ Foam::zone::zone Foam::zone::zone ( - const zone& z, + const zone& zn, const Xfer<labelList>& addr, const label index ) : labelList(addr), - name_(z.name()), + name_(zn.name()), index_(index), lookupMapPtr_(nullptr) {} @@ -165,18 +165,7 @@ Foam::zone::~zone() Foam::label Foam::zone::localID(const label globalCellID) const { - const Map<label>& lm = lookupMap(); - - Map<label>::const_iterator lmIter = lm.find(globalCellID); - - if (lmIter == lm.end()) - { - return -1; - } - else - { - return lmIter(); - } + return lookupMap().lookup(globalCellID, -1); } @@ -197,7 +186,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const forAll(addr, i) { - if (addr[i] < 0 || addr[i] >= maxSize) + const label idx = addr[i]; + if (idx < 0 || idx >= maxSize) { hasError = true; @@ -205,7 +195,7 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const { SeriousErrorInFunction << "Zone " << name_ - << " contains invalid index label " << addr[i] << nl + << " contains invalid index label " << idx << nl << "Valid index labels are 0.." << maxSize-1 << endl; } @@ -215,13 +205,13 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const break; } } - else if (!elems.insert(addr[i])) + else if (!elems.insert(idx)) { if (report) { WarningInFunction << "Zone " << name_ - << " contains duplicate index label " << addr[i] << endl; + << " contains duplicate index label " << idx << endl; } } } @@ -239,9 +229,9 @@ void Foam::zone::write(Ostream& os) const // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -Foam::Ostream& Foam::operator<<(Ostream& os, const zone& z) +Foam::Ostream& Foam::operator<<(Ostream& os, const zone& zn) { - z.write(os); + zn.write(os); os.check(FUNCTION_NAME); return os; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H index 924a97db55d..db769812957 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H @@ -49,7 +49,7 @@ namespace Foam // Forward declaration of friend functions and operators class zone; -Ostream& operator<<(Ostream&, const zone&); +Ostream& operator<<(Ostream& os, const zone& zn); /*---------------------------------------------------------------------------*\ Class zone Declaration @@ -59,6 +59,11 @@ class zone : public labelList { + // Private Member Functions + + //- Disallow default bitwise copy construct + zone(const zone&) = delete; + protected: @@ -71,10 +76,10 @@ protected: label index_; - // Demand-driven private data + // Demand-driven private data - //- Map of labels in zone for fast location lookup - mutable Map<label>* lookupMapPtr_; + //- Map of labels in zone for fast location lookup + mutable Map<label>* lookupMapPtr_; // Protected Member Functions @@ -82,9 +87,6 @@ protected: //- Construct the look-up map void calcLookupMap() const; - //- Disallow default bitwise copy construct - zone(const zone&); - public: @@ -114,7 +116,7 @@ public: zone ( const word& name, - const dictionary&, + const dictionary& dict, const word& labelsName, const label index ); @@ -123,7 +125,7 @@ public: // cell list and zone mesh information zone ( - const zone&, + const zone& zn, const labelUList& addr, const label index ); @@ -132,7 +134,7 @@ public: // cell list and zone mesh information zone ( - const zone&, + const zone& zn, const Xfer<labelList>& addr, const label index ); @@ -178,20 +180,20 @@ public: ) const; //- Correct patch after moving points - virtual void movePoints(const pointField&) + virtual void movePoints(const pointField& pts) {} //- Write - virtual void write(Ostream&) const; + virtual void write(Ostream& os) const; //- Write dictionary - virtual void writeDict(Ostream&) const = 0; + virtual void writeDict(Ostream& os) const = 0; // I-O //- Ostream Operator - friend Ostream& operator<<(Ostream&, const zone&); + friend Ostream& operator<<(Ostream& os, const zone& zn); }; -- GitLab From ff95b8446e6185c2ea1da3183153b8b641725d63 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 4 Oct 2017 11:16:29 +0200 Subject: [PATCH 018/126] BUG: index error when parsing integers from prefix_rayId_lambdaId --- .../radiation/radiationModels/fvDOM/fvDOM/fvDOM.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C index b8f959c1568..3250cc66b00 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C @@ -530,11 +530,11 @@ void Foam::radiation::fvDOM::setRayIdLambdaId label& lambdaId ) const { - // assuming name is in the form: CHARS_rayId_lambdaId + // Assuming name is in the form: CHARS_rayId_lambdaId const auto i1 = name.find('_'); - const auto i2 = name.rfind('_'); + const auto i2 = name.find('_', i1+1); - rayId = readLabel(name.substr(i1+1, i2-1)); + rayId = readLabel(name.substr(i1+1, i2-i1-1)); lambdaId = readLabel(name.substr(i2+1)); } -- GitLab From b02623f974d2112227d5b2b77dd2505ce063eca8 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 4 Oct 2017 16:49:45 +0200 Subject: [PATCH 019/126] STYLE: remove substring operator() (issue #554) - duplicate functionality to the substr() method and more difficult to notice when it is being used. --- src/OpenFOAM/primitives/strings/string/string.H | 15 +-------------- src/OpenFOAM/primitives/strings/string/stringI.H | 16 ---------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H index 78a25c00f2a..3af6835f144 100644 --- a/src/OpenFOAM/primitives/strings/string/string.H +++ b/src/OpenFOAM/primitives/strings/string/string.H @@ -151,7 +151,7 @@ public: inline string(const char c); //- Construct from copies of a single character - inline string(const size_type, const char); + inline string(const size_type len, const char c); //- Construct from Istream string(Istream& is); @@ -267,19 +267,6 @@ public: // \return True when strings match literally. inline bool operator()(const std::string& text) const; - //- Return sub-string from the i-th character for \a n characters - inline string operator() - ( - const size_type i, - const size_type n - ) const; - - //- Return sub-string from the first character for \a n characters - inline string operator() - ( - const size_type n - ) const; - // IOstream Operators diff --git a/src/OpenFOAM/primitives/strings/string/stringI.H b/src/OpenFOAM/primitives/strings/string/stringI.H index 9c485deda3d..89a36cc3ee8 100644 --- a/src/OpenFOAM/primitives/strings/string/stringI.H +++ b/src/OpenFOAM/primitives/strings/string/stringI.H @@ -243,22 +243,6 @@ inline bool Foam::string::operator()(const std::string& text) const } -inline Foam::string Foam::string::operator() -( - const size_type i, - const size_type n -) const -{ - return substr(i, n); -} - - -inline Foam::string Foam::string::operator()(const size_type n) const -{ - return substr(0, n); -} - - inline unsigned Foam::string::hash::operator() ( const string& str, -- GitLab From c903c397638281f34dccbf2b80f9980400900b66 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 5 Oct 2017 09:52:17 +0100 Subject: [PATCH 020/126] BUG: Allrun: run in non-test mode. Handle ./Alltest correctly --- bin/foamRunTutorials | 11 ++++++++--- tutorials/Allrun | 2 +- tutorials/Alltest | 2 +- tutorials/IO/fileHandler/Alltest | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100755 tutorials/IO/fileHandler/Alltest diff --git a/bin/foamRunTutorials b/bin/foamRunTutorials index dac6fc894fc..df8f148ca5f 100755 --- a/bin/foamRunTutorials +++ b/bin/foamRunTutorials @@ -51,6 +51,7 @@ do case "$1" in -t | -test) passArgs="-test" + runTests=true shift ;; -s | -skipFirst) @@ -64,10 +65,14 @@ do done # If an argument is supplied do not execute ./Allrun to avoid recursion -if ! $skipFirst && [ -f "./Allrun" ] +if ! $skipFirst && $runTests && [ -f "./Alltest" ] +then + # Run speciallised Alltest script. + ./Alltest $passArgs $* +elif ! $skipFirst && [ -f "./Allrun" ] then # Run specialised Allrun script. - ./Allrun $passArgs + ./Allrun $passArgs $* elif [ -d system ] then # Run normal case. @@ -89,7 +94,7 @@ else # Run all cases which have not already been run $make -k -f $WM_PROJECT_DIR/bin/tools/MakefileDirs \ FOAM_TARGETS="$FOAM_TARGETS" \ - FOAM_APP="$thisScript" FOAM_ARGS="$passArgs" + FOAM_APP="$thisScript" FOAM_ARGS="$passArgs $*" fi #------------------------------------------------------------------------------ diff --git a/tutorials/Allrun b/tutorials/Allrun index 28e4fe6a451..bf468c143e6 100755 --- a/tutorials/Allrun +++ b/tutorials/Allrun @@ -124,7 +124,7 @@ logReport() if [ -z "$optCollectOnly" ] then # Recursively run all tutorials - foamRunTutorials -test -skipFirst + foamRunTutorials -skipFirst $* fi diff --git a/tutorials/Alltest b/tutorials/Alltest index f1923619425..39da77fb7a6 100755 --- a/tutorials/Alltest +++ b/tutorials/Alltest @@ -244,7 +244,7 @@ fi cp -f $FOAM_TUTORIALS/Allrun . -./Allrun +./Allrun -test sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp APPLICATIONS=\ diff --git a/tutorials/IO/fileHandler/Alltest b/tutorials/IO/fileHandler/Alltest new file mode 100755 index 00000000000..98f9166d69b --- /dev/null +++ b/tutorials/IO/fileHandler/Alltest @@ -0,0 +1,16 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +# Reset the controlDict +if [ -f system/controlDict.orig ] +then + echo "$0: restoring the controlDict from controlDict.orig" + mv system/controlDict.orig system/controlDict +fi + +./Allrun + +#------------------------------------------------------------------------------ -- GitLab From 85f5fb730f712338c8c0ef82cd101e691e227326 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 5 Oct 2017 14:27:48 +0200 Subject: [PATCH 021/126] TUT: avoid backticks in scripts - consistent versions in headers --- tutorials/IO/fileHandler/Allclean | 9 +++++++++ tutorials/IO/fileHandler/Allrun | 8 +++++--- tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun | 4 ++-- tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun | 4 ++-- .../buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun | 2 +- .../chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T | 2 +- .../chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U | 2 +- .../windshieldDefrost/0.orig/cabin/alphat | 2 +- .../chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k | 2 +- .../windshieldDefrost/0.orig/cabin/mut | 2 +- .../windshieldDefrost/0.orig/cabin/omega | 2 +- .../chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p | 2 +- .../windshieldDefrost/0.orig/cabin/p_rgh | 2 +- .../windshieldDefrost/0.orig/exterior/T | 2 +- .../windshieldDefrost/0.orig/exterior/U | 2 +- .../windshieldDefrost/0.orig/exterior/alphat | 2 +- .../windshieldDefrost/0.orig/exterior/k | 2 +- .../windshieldDefrost/0.orig/exterior/omega | 2 +- .../windshieldDefrost/0.orig/exterior/p | 2 +- .../windshieldDefrost/0.orig/exterior/p_rgh | 2 +- .../chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T | 2 +- .../chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U | 2 +- .../chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p | 2 +- .../windshieldDefrost/0.orig/ice/p_rgh | 2 +- .../cylinder/cylinderAndBackground/0.orig/U | 2 +- .../cylinder/cylinderAndBackground/0.orig/epsilon | 2 +- .../cylinder/cylinderAndBackground/0.orig/k | 2 +- .../cylinder/cylinderAndBackground/0.orig/nut | 2 +- .../cylinder/cylinderAndBackground/0.orig/p | 2 +- .../cylinderAndBackground/0.orig/pointDisplacement | 2 +- .../cylinder/cylinderAndBackground/0.orig/zoneID | 2 +- .../cylinderAndBackground/constant/dynamicMeshDict | 2 +- .../cylinderAndBackground/constant/transportProperties | 2 +- .../cylinder/cylinderAndBackground/system/setFieldsDict | 2 +- .../cylinder/cylinderAndBackground/system/topoSetDict | 2 +- .../cylinder/cylinderMesh/system/createPatchDict | 2 +- .../overPimpleDyMFoam/simpleRotor/0.orig/U | 2 +- .../overPimpleDyMFoam/simpleRotor/0.orig/epsilon | 3 +-- .../overPimpleDyMFoam/simpleRotor/0.orig/k | 2 +- .../overPimpleDyMFoam/simpleRotor/0.orig/nuTilda | 2 +- .../overPimpleDyMFoam/simpleRotor/0.orig/nut | 2 +- .../overPimpleDyMFoam/simpleRotor/0.orig/p | 2 +- .../simpleRotor/0.orig/pointDisplacement | 2 +- .../overPimpleDyMFoam/simpleRotor/0.orig/zoneID | 2 +- .../overPimpleDyMFoam/simpleRotor/constant/RASProperties | 2 +- .../simpleRotor/constant/dynamicMeshDict | 2 +- .../simpleRotor/constant/transportProperties | 2 +- .../simpleRotor/constant/turbulenceProperties | 2 +- .../overPimpleDyMFoam/simpleRotor/system/blockMeshDict | 2 +- .../overPimpleDyMFoam/simpleRotor/system/controlDict | 2 +- .../overPimpleDyMFoam/simpleRotor/system/fvSchemes | 2 +- .../overPimpleDyMFoam/simpleRotor/system/fvSolution | 2 +- .../overPimpleDyMFoam/simpleRotor/system/setFieldsDict | 2 +- .../overPimpleDyMFoam/simpleRotor/system/topoSetDict | 2 +- .../overPimpleDyMFoam/twoSimpleRotors/0.orig/U | 2 +- .../overPimpleDyMFoam/twoSimpleRotors/0.orig/p | 2 +- .../twoSimpleRotors/0.orig/pointDisplacement | 2 +- .../overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID | 2 +- .../twoSimpleRotors/constant/dynamicMeshDict | 2 +- .../twoSimpleRotors/constant/transportProperties | 2 +- .../twoSimpleRotors/constant/turbulenceProperties | 2 +- .../twoSimpleRotors/system/blockMeshDict | 2 +- .../overPimpleDyMFoam/twoSimpleRotors/system/controlDict | 2 +- .../overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes | 2 +- .../overPimpleDyMFoam/twoSimpleRotors/system/fvSolution | 2 +- .../twoSimpleRotors/system/setFieldsDict | 2 +- .../overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict | 2 +- .../wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement | 1 - .../box2D_moveDynamicMesh/0.orig/cellDisplacement | 4 +--- .../box2D_moveDynamicMesh/0.orig/pointDisplacement | 1 - .../interDyMFoam/laminar/sloshingCylinder/Allrun | 2 +- .../interDyMFoam/laminar/sloshingTank3D6DoF/Allrun | 2 +- .../floatingBody/floatingBody/Allrun.pre | 3 --- 73 files changed, 84 insertions(+), 81 deletions(-) create mode 100755 tutorials/IO/fileHandler/Allclean diff --git a/tutorials/IO/fileHandler/Allclean b/tutorials/IO/fileHandler/Allclean new file mode 100755 index 00000000000..6b45f82a41b --- /dev/null +++ b/tutorials/IO/fileHandler/Allclean @@ -0,0 +1,9 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase + +#------------------------------------------------------------------------------ diff --git a/tutorials/IO/fileHandler/Allrun b/tutorials/IO/fileHandler/Allrun index d032798abbd..d70139ef72e 100755 --- a/tutorials/IO/fileHandler/Allrun +++ b/tutorials/IO/fileHandler/Allrun @@ -6,9 +6,11 @@ cd ${0%/*} || exit 1 # Run from this directory runApplication blockMesh +application=$(getApplication) + #- Test writing collated format runApplication decomposePar -fileHandler collated -runParallel `getApplication` -fileHandler collated +runParallel $application -fileHandler collated runApplication reconstructPar -latestTime -fileHandler collated #- Delete collated files @@ -16,10 +18,10 @@ rm -rf processors #- Test writing uncollated format runApplication -s uncollated decomposePar -fileHandler uncollated -runParallel -s uncollated `getApplication` -fileHandler uncollated +runParallel -s uncollated $application -fileHandler uncollated #- Restart from uncollated -runParallel -s collated `getApplication` -fileHandler collated +runParallel -s collated $application -fileHandler collated runApplication -s collated reconstructPar -latestTime -fileHandler collated #- Convert the parallel format to uncollated diff --git a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun index 40a38f4eca5..a3d72f117c5 100755 --- a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun +++ b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun @@ -4,8 +4,8 @@ cd ${0%/*} || exit 1 # Run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions -# Set application name -application=`getApplication` +# Application name +application=$(getApplication) rm -f 0/T cp 0/T.orig 0/T diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun index ae405888c0b..5afd8b9d746 100755 --- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun +++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun @@ -4,8 +4,8 @@ cd ${0%/*} || exit 1 # Run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions -# Set application name -application=`getApplication` +# Application name +application=$(getApplication) rm -f 0 cp -r 0.orig 0 diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun index ca4be116d7c..afe3cd23cfe 100755 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun @@ -20,7 +20,7 @@ runApplication $(getApplication) # foamDictionary "$f" > "../processors/0/$f"; done \ #) # -#runParallel `getApplication` -fileHandler collated +#runParallel $(getApplication) -fileHandler collated #runApplication reconstructParMesh -constant -mergeTol 1e-6 #runApplication reconstructPar diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T index cb41965f6d0..210f21c3c2a 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/cabin"; + location "0/cabin"; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U index 39f76c7d608..6417f769772 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volVectorField; - location "0.0001/cabin"; + location "0/cabin"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat index 0ae4684ecd1..619fface6f3 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/cabin"; + location "0/cabin"; object alphat; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k index 7af0caf3efa..1ec07db6207 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/cabin"; + location "0/cabin"; object k; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut index 5fec8a0f136..c058f200375 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/cabin"; + location "0/cabin"; object mut; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega index 408dbbd7f50..b139e99405f 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/cabin"; + location "0/cabin"; object omega; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p index f4e17657dab..4ff4f2aab2f 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/cabin"; + location "0/cabin"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh index e999538886a..904e2543585 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/cabin"; + location "0/cabin"; object p_rgh; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T index dd56368c393..316d0a4d79d 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/exterior"; + location "0/exterior"; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U index 1dcf7568ed0..798d170bed0 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volVectorField; - location "0.0001/exterior"; + location "0/exterior"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat index 90db16eef7b..8c0ad63614b 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/exterior"; + location "0/exterior"; object alphat; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k index 47032402600..fbbe93014d7 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/exterior"; + location "0/exterior"; object k; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega index a7cca7714ab..0e0856fe393 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/exterior"; + location "0/exterior"; object omega; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p index 764aecbeb41..20ef4a3e5ac 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/exterior"; + location "0/exterior"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh index d1c78a163b1..672028547d3 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/exterior"; + location "0/exterior"; object p_rgh; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T index e48d2b0c5a9..84ba951a2fe 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/ice"; + location "0/ice"; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U index ebe245ba297..e3efcba0f63 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volVectorField; - location "0.0001/ice"; + location "0/ice"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p index 8860f98c60c..9015143ba71 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/ice"; + location "0/ice"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh index 66de1672f5c..06578deae9a 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh @@ -10,7 +10,7 @@ FoamFile version 2.0; format binary; class volScalarField; - location "0.0001/ice"; + location "0/ice"; object p_rgh; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U index c14119ee33c..1f740ae49d6 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon index 6491f886514..cf852c72dce 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k index e264adb202d..ffd3df6c700 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut index 9ec55e9f01b..9200b0098b0 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p index f5688d226d7..e0d247b2fdd 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement index 0bcc4e3481f..14d636e1226 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID index 88d3b0af1d5..1a0b8c3b47f 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict index 799c4a059b7..9f766ac2725 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties index 4efbc8b9325..312de2197d3 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict index 21c7adb08ee..8efb92d6102 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict index 9c6d9767824..1b24f69a27d 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict index 74214eea863..a4e3a644b32 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U index 4d9613a87a0..4c6e3407fc6 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon index 3fe3a7428cd..a5dfa71fb2f 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -10,7 +10,6 @@ FoamFile version 2.0; format ascii; class volScalarField; - location "0"; object epsilon; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k index e3c6782ce05..2b47f7341be 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda index 55de8c57bcc..889292d92b6 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut index b68e974c96d..db24c1bdad7 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p index ab7fd5c2877..08a3949e59a 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement index fe072121d35..67ac84306f1 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID index 84f0d963f3a..6dc74df3939 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties index ec34b4c47c9..a90687f88c8 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict index 951bd08dae5..64a310b628f 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties index 4efbc8b9325..312de2197d3 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties index c1f1b1a8341..59fa7b96ea5 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict index bc0d9c02a8c..aaa029026d1 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict index d9178735a16..b2b8647c64e 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes index 067d2aa43b6..d31d118e8aa 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution index 464100d29a4..925faa16666 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict index 21c7adb08ee..8efb92d6102 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict index 4b0957e2889..52a30892d55 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U index 3d7fddaaaaa..807ff39559c 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p index 363e7193fde..1baa7b03df7 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement index b218758016c..7252992283e 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID index 88d3b0af1d5..1a0b8c3b47f 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict index 391eb516ead..d84a86685dc 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties index ab4d80f3308..d0519e17b40 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties index 9abf14eeecd..3defecdc911 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict index abcbd45e794..a198025ce9c 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict index 7e93ade3783..6f6e02ca72e 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes index 4e18294c71a..d849549fd87 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution index 464100d29a4..925faa16666 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict index b3f3729fe8b..0a1f69b2771 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict index db08fe53b5d..a42ec579e4a 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement b/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement index aa09fbff1b1..15ba53c5518 100644 --- a/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement +++ b/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement @@ -10,7 +10,6 @@ FoamFile version 2.0; format ascii; class pointVectorField; - location "0.01"; object pointDisplacement; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement index c542662e7ca..422d3dd3044 100644 --- a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement +++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus-overset | +| \\ / O peration | Version: plus | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -10,7 +10,6 @@ FoamFile version 2.0; format ascii; class volVectorField; - location "0.034"; object cellDisplacement; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,5 +58,4 @@ boundaryField } } - // ************************************************************************* // diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement index 0748b9df809..92758708dee 100644 --- a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement +++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement @@ -10,7 +10,6 @@ FoamFile version 2.0; format ascii; class pointVectorField; - location "0"; object pointMotionU; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun index 44bb710e510..355fea57a8d 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun @@ -8,6 +8,6 @@ runApplication blockMesh runApplication snappyHexMesh -overwrite cp 0/alpha.water.orig 0/alpha.water runApplication setFields -runApplication `getApplication` +runApplication $(getApplication) #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun index 603304a5ae3..31527e6ec22 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun @@ -8,6 +8,6 @@ m4 system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh cp 0/alpha.water.orig 0/alpha.water runApplication setFields -runApplication `getApplication` +runApplication $(getApplication) #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre index 36d051548df..0a33b80dda3 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre @@ -4,9 +4,6 @@ cd ${0%/*} || exit 1 # run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions -# Set application name -application=`getApplication` - runApplication blockMesh runApplication topoSet runApplication subsetMesh -overwrite c0 -patch floatingObject -- GitLab From 13346ec5b154917f6c14c9af7f63c5ae9cd476b6 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 6 Oct 2017 11:36:40 +0200 Subject: [PATCH 022/126] BUG: incorrect xml format tag for VTK surface mesh writer (closes #611) --- src/conversion/vtk/output/foamVtkPatchWriter.C | 2 +- src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C | 2 +- src/meshTools/output/foamVtkWriteCellSetFaces.C | 2 +- src/meshTools/output/foamVtkWriteFaceSet.C | 2 +- src/meshTools/output/foamVtkWritePointSet.C | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conversion/vtk/output/foamVtkPatchWriter.C b/src/conversion/vtk/output/foamVtkPatchWriter.C index fcbe032cfd2..18764148cd6 100644 --- a/src/conversion/vtk/output/foamVtkPatchWriter.C +++ b/src/conversion/vtk/output/foamVtkPatchWriter.C @@ -245,7 +245,7 @@ Foam::vtk::patchWriter::patchWriter nFaces_(0) { outputOptions opts(outOpts); - opts.append(false); // No append + opts.append(false); // No append supported os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); format_ = opts.newFormatter(os_); diff --git a/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C b/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C index df54f039cda..f5ba90efc17 100644 --- a/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C +++ b/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C @@ -193,7 +193,7 @@ Foam::vtk::surfaceMeshWriter::surfaceMeshWriter os_() { outputOptions opts(outOpts); - opts.legacy(true); // No append supported + opts.append(false); // No append supported os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); format_ = opts.newFormatter(os_); diff --git a/src/meshTools/output/foamVtkWriteCellSetFaces.C b/src/meshTools/output/foamVtkWriteCellSetFaces.C index a84b5d5b706..d18eb9f97e9 100644 --- a/src/meshTools/output/foamVtkWriteCellSetFaces.C +++ b/src/meshTools/output/foamVtkWriteCellSetFaces.C @@ -41,7 +41,7 @@ void Foam::vtk::writeCellSetFaces ) { outputOptions opts(outOpts); - opts.legacy(true); // Legacy only, no append + opts.legacy(true); // Legacy only, no xml, no append const bool legacy_(opts.legacy()); diff --git a/src/meshTools/output/foamVtkWriteFaceSet.C b/src/meshTools/output/foamVtkWriteFaceSet.C index 59c11329d41..26a37e13ecd 100644 --- a/src/meshTools/output/foamVtkWriteFaceSet.C +++ b/src/meshTools/output/foamVtkWriteFaceSet.C @@ -41,7 +41,7 @@ void Foam::vtk::writeFaceSet ) { outputOptions opts(outOpts); - opts.legacy(true); // Legacy only, no append + opts.legacy(true); // Legacy only, no xml, no append const bool legacy_(opts.legacy()); diff --git a/src/meshTools/output/foamVtkWritePointSet.C b/src/meshTools/output/foamVtkWritePointSet.C index 66cbfc8c443..2cf1e1085b7 100644 --- a/src/meshTools/output/foamVtkWritePointSet.C +++ b/src/meshTools/output/foamVtkWritePointSet.C @@ -40,7 +40,7 @@ void Foam::vtk::writePointSet ) { outputOptions opts(outOpts); - opts.legacy(true); // Legacy only, no append + opts.legacy(true); // Legacy only, no xml, no append const bool legacy_(opts.legacy()); -- GitLab From 00b94c4a406e2c0d589f682e2934f1b57a1651f8 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 6 Oct 2017 14:18:54 +0200 Subject: [PATCH 023/126] ENH: handle partially attached master/slave faces (issue #608) - addresses problems if faces are already partly attached (eg, on a single vertex or along an edge). --- .../polyTopoChange/polyTopoChange.C | 513 +++++++--------- .../polyTopoChange/polyTopoChange.H | 151 +++-- .../polyTopoChange/polyTopoChangeTemplates.C | 38 +- .../slidingInterface/coupleSlidingInterface.C | 569 +++++++++--------- .../decoupleSlidingInterface.C | 132 ++-- .../enrichedPatch/enrichedPatch.C | 39 +- .../enrichedPatch/enrichedPatch.H | 37 +- .../enrichedPatch/enrichedPatchCutFaces.C | 64 +- .../enrichedPatch/enrichedPatchFaces.C | 220 +++---- .../enrichedPatch/enrichedPatchI.H | 63 ++ .../enrichedPatch/enrichedPatchMasterPoints.C | 82 +-- .../enrichedPatch/enrichedPatchPointMap.C | 29 +- .../enrichedPatch/enrichedPatchPointPoints.C | 11 +- .../slidingInterfaceAttachedAddressing.C | 84 ++- .../slidingInterfaceProjectPoints.C | 293 +++++---- .../mesh/stitchMesh/simple-cube1/Allclean | 8 + .../mesh/stitchMesh/simple-cube1/Allmesh | 19 + tutorials/mesh/stitchMesh/simple-cube1/Allrun | 12 + .../stitchMesh/simple-cube1/scripts/stitch | 50 ++ .../simple-cube1/system/blockMeshDict | 132 ++++ .../simple-cube1/system/controlDict | 45 ++ .../simple-cube1/system/createPatchDict | 53 ++ .../stitchMesh/simple-cube1/system/fvSchemes | 55 ++ .../stitchMesh/simple-cube1/system/fvSolution | 43 ++ .../simple-cube1/system/topoSetDict | 106 ++++ .../simple-cube1/system/topoSetDict.patches | 88 +++ 26 files changed, 1739 insertions(+), 1197 deletions(-) create mode 100644 src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchI.H create mode 100755 tutorials/mesh/stitchMesh/simple-cube1/Allclean create mode 100755 tutorials/mesh/stitchMesh/simple-cube1/Allmesh create mode 100755 tutorials/mesh/stitchMesh/simple-cube1/Allrun create mode 100755 tutorials/mesh/stitchMesh/simple-cube1/scripts/stitch create mode 100644 tutorials/mesh/stitchMesh/simple-cube1/system/blockMeshDict create mode 100644 tutorials/mesh/stitchMesh/simple-cube1/system/controlDict create mode 100644 tutorials/mesh/stitchMesh/simple-cube1/system/createPatchDict create mode 100644 tutorials/mesh/stitchMesh/simple-cube1/system/fvSchemes create mode 100644 tutorials/mesh/stitchMesh/simple-cube1/system/fvSolution create mode 100644 tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict create mode 100644 tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 78e9b7b3091..90c3c635201 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,22 +54,22 @@ namespace Foam // Renumber with special handling for merged items (marked with <-1) void Foam::polyTopoChange::renumberReverseMap ( - const labelList& map, + const labelUList& oldToNew, DynamicList<label>& elems ) { forAll(elems, elemI) { - label val = elems[elemI]; + const label val = elems[elemI]; if (val >= 0) { - elems[elemI] = map[val]; + elems[elemI] = oldToNew[val]; } else if (val < -1) { - label mergedVal = -val-2; - elems[elemI] = -map[mergedVal]-2; + const label mergedVal = -val-2; + elems[elemI] = -oldToNew[mergedVal]-2; } } } @@ -77,52 +77,52 @@ void Foam::polyTopoChange::renumberReverseMap void Foam::polyTopoChange::renumber ( - const labelList& map, - labelHashSet& elems + const labelUList& oldToNew, + labelHashSet& labels ) { - labelHashSet newElems(elems.size()); + labelHashSet newSet(labels.capacity()); - forAllConstIter(labelHashSet, elems, iter) + for (const label val : labels) { - label newElem = map[iter.key()]; + const label newVal = oldToNew[val]; - if (newElem >= 0) + if (newVal >= 0) { - newElems.insert(newElem); + newSet.insert(newVal); } } - elems.transfer(newElems); + labels.transfer(newSet); } // Renumber and remove -1 elements. void Foam::polyTopoChange::renumberCompact ( - const labelList& map, + const labelUList& oldToNew, labelList& elems ) { - label newElemI = 0; + label nElem = 0; - forAll(elems, elemI) + for (const label val : elems) { - label newVal = map[elems[elemI]]; + const label newVal = oldToNew[val]; if (newVal != -1) { - elems[newElemI++] = newVal; + elems[nElem++] = newVal; } } - elems.setSize(newElemI); + elems.setSize(nElem); } void Foam::polyTopoChange::countMap ( - const labelList& map, - const labelList& reverseMap, + const labelUList& map, + const labelUList& reverseMap, label& nAdd, label& nInflate, label& nMerge, @@ -136,7 +136,7 @@ void Foam::polyTopoChange::countMap forAll(map, newCelli) { - label oldCelli = map[newCelli]; + const label oldCelli = map[newCelli]; if (oldCelli >= 0) { @@ -164,7 +164,7 @@ void Foam::polyTopoChange::countMap forAll(reverseMap, oldCelli) { - label newCelli = reverseMap[oldCelli]; + const label newCelli = reverseMap[oldCelli]; if (newCelli >= 0) { @@ -224,8 +224,8 @@ void Foam::polyTopoChange::writeMeshStats(const polyMesh& mesh, Ostream& os) void Foam::polyTopoChange::getMergeSets ( - const labelList& reverseCellMap, - const labelList& cellMap, + const labelUList& reverseCellMap, + const labelUList& cellMap, List<objectMap>& cellsFromCells ) { @@ -234,7 +234,7 @@ void Foam::polyTopoChange::getMergeSets forAll(reverseCellMap, oldCelli) { - label newCelli = reverseCellMap[oldCelli]; + const label newCelli = reverseCellMap[oldCelli]; if (newCelli < -1) { @@ -267,15 +267,15 @@ void Foam::polyTopoChange::getMergeSets forAll(reverseCellMap, oldCelli) { - label newCelli = reverseCellMap[oldCelli]; + const label newCelli = reverseCellMap[oldCelli]; if (newCelli < -1) { - label mergeCelli = -newCelli-2; + const label mergeCelli = -newCelli-2; // oldCelli was merged into mergeCelli - label setI = cellToMergeSet[mergeCelli]; + const label setI = cellToMergeSet[mergeCelli]; objectMap& mergeSet = cellsFromCells[setI]; @@ -305,9 +305,9 @@ void Foam::polyTopoChange::getMergeSets bool Foam::polyTopoChange::hasValidPoints(const face& f) const { - forAll(f, fp) + for (const label fp : f) { - if (f[fp] < 0 || f[fp] >= points_.size()) + if (fp < 0 || fp >= points_.size()) { return false; } @@ -595,7 +595,7 @@ void Foam::polyTopoChange::makeCellCells // Handles removed cells. Returns number of remaining cells. Foam::label Foam::polyTopoChange::getCellOrder ( - const CompactListList<label>& cellCellAddressing, + const CompactListList<label, labelList>& cellCellAddressing, labelList& oldToNew ) const { @@ -716,8 +716,8 @@ Foam::label Foam::polyTopoChange::getCellOrder void Foam::polyTopoChange::getFaceOrder ( const label nActiveFaces, - const labelList& cellFaces, - const labelList& cellFaceOffsets, + const labelUList& cellFaces, + const labelUList& cellFaceOffsets, labelList& oldToNew, labelList& patchSizes, @@ -882,7 +882,7 @@ void Foam::polyTopoChange::getFaceOrder void Foam::polyTopoChange::reorderCompactFaces ( const label newSize, - const labelList& oldToNew + const labelUList& oldToNew ) { reorder(oldToNew, faces_); @@ -1069,9 +1069,9 @@ void Foam::polyTopoChange::compact newPointi = nActivePoints; } - forAllConstIter(labelHashSet, retiredPoints_, iter) + for (const label pointi : retiredPoints_) { - localPointMap[iter.key()] = newPointi++; + localPointMap[pointi] = newPointi++; } @@ -1282,7 +1282,7 @@ void Foam::polyTopoChange::compact Foam::labelList Foam::polyTopoChange::selectFaces ( const primitiveMesh& mesh, - const labelList& faceLabels, + const labelUList& faceLabels, const bool internalFacesOnly ) { @@ -1331,7 +1331,7 @@ Foam::labelList Foam::polyTopoChange::selectFaces // label) void Foam::polyTopoChange::calcPatchPointMap ( - const List<Map<label>>& oldPatchMeshPointMaps, + const UList<Map<label>>& oldPatchMeshPointMaps, const polyBoundaryMesh& boundary, labelListList& patchPointMap ) const @@ -1353,19 +1353,11 @@ void Foam::polyTopoChange::calcPatchPointMap if (meshPoints[i] < pointMap_.size()) { // Check if old point was part of same patch - Map<label>::const_iterator ozmpmIter = oldMeshPointMap.find + curPatchPointRnb[i] = oldMeshPointMap.lookup ( - pointMap_[meshPoints[i]] + pointMap_[meshPoints[i]], + -1 ); - - if (ozmpmIter != oldMeshPointMap.end()) - { - curPatchPointRnb[i] = ozmpmIter(); - } - else - { - curPatchPointRnb[i] = -1; - } } else { @@ -1394,38 +1386,24 @@ void Foam::polyTopoChange::calcFaceInflationMaps label nFacesFromPoints = 0; // Collect all still existing faces connected to this point. - forAllConstIter(Map<label>, faceFromPoint_, iter) + forAllConstIters(faceFromPoint_, iter) { - label newFacei = iter.key(); + const label facei = iter.key(); + const label pointi = iter.object(); - if (region_[newFacei] == -1) - { - // Get internal faces using point on old mesh - facesFromPoints[nFacesFromPoints++] = objectMap - ( - newFacei, - selectFaces - ( - mesh, - mesh.pointFaces()[iter()], - true - ) - ); - } - else - { - // Get patch faces using point on old mesh - facesFromPoints[nFacesFromPoints++] = objectMap + // Get internal or patch faces using point on old mesh + const bool internal = (region_[facei] == -1); + + facesFromPoints[nFacesFromPoints++] = objectMap + ( + facei, + selectFaces ( - newFacei, - selectFaces - ( - mesh, - mesh.pointFaces()[iter()], - false - ) - ); - } + mesh, + mesh.pointFaces()[pointi], + internal + ) + ); } } @@ -1440,38 +1418,24 @@ void Foam::polyTopoChange::calcFaceInflationMaps label nFacesFromEdges = 0; // Collect all still existing faces connected to this edge. - forAllConstIter(Map<label>, faceFromEdge_, iter) + forAllConstIters(faceFromEdge_, iter) { - label newFacei = iter.key(); + const label facei = iter.key(); + const label edgei = iter.object(); - if (region_[newFacei] == -1) - { - // Get internal faces using edge on old mesh - facesFromEdges[nFacesFromEdges++] = objectMap - ( - newFacei, - selectFaces - ( - mesh, - mesh.edgeFaces(iter()), - true - ) - ); - } - else - { - // Get patch faces using edge on old mesh - facesFromEdges[nFacesFromEdges++] = objectMap + // Get internal or patch faces using edge on old mesh + const bool internal = (region_[facei] == -1); + + facesFromEdges[nFacesFromEdges++] = objectMap + ( + facei, + selectFaces ( - newFacei, - selectFaces - ( - mesh, - mesh.edgeFaces(iter()), - false - ) - ); - } + mesh, + mesh.edgeFaces(edgei), + internal + ) + ); } } @@ -1503,13 +1467,16 @@ void Foam::polyTopoChange::calcCellInflationMaps { label nCellsFromPoints = 0; - // Collect all still existing faces connected to this point. - forAllConstIter(Map<label>, cellFromPoint_, iter) + // Collect all still existing cells connected to this point. + forAllConstIters(cellFromPoint_, iter) { + const label celli = iter.key(); + const label pointi = iter.object(); + cellsFromPoints[nCellsFromPoints++] = objectMap ( - iter.key(), - mesh.pointCells()[iter()] + celli, + mesh.pointCells()[pointi] ); } } @@ -1521,13 +1488,16 @@ void Foam::polyTopoChange::calcCellInflationMaps { label nCellsFromEdges = 0; - // Collect all still existing faces connected to this point. - forAllConstIter(Map<label>, cellFromEdge_, iter) + // Collect all still existing cells connected to this edge. + forAllConstIters(cellFromEdge_, iter) { + const label celli = iter.key(); + const label edgei = iter.object(); + cellsFromEdges[nCellsFromEdges++] = objectMap ( - iter.key(), - mesh.edgeCells()[iter()] + celli, + mesh.edgeCells()[edgei] ); } } @@ -1542,9 +1512,10 @@ void Foam::polyTopoChange::calcCellInflationMaps labelList twoCells(2); // Collect all still existing faces connected to this point. - forAllConstIter(Map<label>, cellFromFace_, iter) + forAllConstIters(cellFromFace_, iter) { - label oldFacei = iter(); + const label celli = iter.key(); + const label oldFacei = iter.object(); if (mesh.isInternalFace(oldFacei)) { @@ -1552,7 +1523,7 @@ void Foam::polyTopoChange::calcCellInflationMaps twoCells[1] = mesh.faceNeighbour()[oldFacei]; cellsFromFaces[nCellsFromFaces++] = objectMap ( - iter.key(), + celli, twoCells ); } @@ -1560,7 +1531,7 @@ void Foam::polyTopoChange::calcCellInflationMaps { cellsFromFaces[nCellsFromFaces++] = objectMap ( - iter.key(), + celli, labelList(1, mesh.faceOwner()[oldFacei]) ); } @@ -1600,49 +1571,51 @@ void Foam::polyTopoChange::resetZones labelList nPoints(pointZones.size(), 0); - forAllConstIter(Map<label>, pointZone_, iter) + forAllConstIters(pointZone_, iter) { - label zoneI = iter(); + const label pointi = iter.key(); + const label zonei = iter.object(); - if (zoneI < 0 || zoneI >= pointZones.size()) + if (zonei < 0 || zonei >= pointZones.size()) { FatalErrorInFunction - << "Illegal zoneID " << zoneI << " for point " - << iter.key() << " coord " << mesh.points()[iter.key()] + << "Illegal zoneID " << zonei << " for point " + << pointi << " coord " << mesh.points()[pointi] << abort(FatalError); } - nPoints[zoneI]++; + nPoints[zonei]++; } // Distribute points per zone labelListList addressing(pointZones.size()); - forAll(addressing, zoneI) + forAll(addressing, zonei) { - addressing[zoneI].setSize(nPoints[zoneI]); + addressing[zonei].setSize(nPoints[zonei]); } nPoints = 0; - forAllConstIter(Map<label>, pointZone_, iter) + forAllConstIters(pointZone_, iter) { - label zoneI = iter(); + const label pointi = iter.key(); + const label zonei = iter.object(); - addressing[zoneI][nPoints[zoneI]++] = iter.key(); + addressing[zonei][nPoints[zonei]++] = pointi; } // Sort the addressing - forAll(addressing, zoneI) + forAll(addressing, zonei) { - stableSort(addressing[zoneI]); + stableSort(addressing[zonei]); } // So now we both have old zones and the new addressing. // Invert the addressing to get pointZoneMap. - forAll(addressing, zoneI) + forAll(addressing, zonei) { - const pointZone& oldZone = pointZones[zoneI]; - const labelList& newZoneAddr = addressing[zoneI]; + const pointZone& oldZone = pointZones[zonei]; + const labelList& newZoneAddr = addressing[zonei]; - labelList& curPzRnb = pointZoneMap[zoneI]; + labelList& curPzRnb = pointZoneMap[zonei]; curPzRnb.setSize(newZoneAddr.size()); forAll(newZoneAddr, i) @@ -1660,17 +1633,17 @@ void Foam::polyTopoChange::resetZones // Reset the addresing on the zone newMesh.pointZones().clearAddressing(); - forAll(newMesh.pointZones(), zoneI) + forAll(newMesh.pointZones(), zonei) { if (debug) { - Pout<< "pointZone:" << zoneI - << " name:" << newMesh.pointZones()[zoneI].name() - << " size:" << addressing[zoneI].size() + Pout<< "pointZone:" << zonei + << " name:" << newMesh.pointZones()[zonei].name() + << " size:" << addressing[zonei].size() << endl; } - newMesh.pointZones()[zoneI] = addressing[zoneI]; + newMesh.pointZones()[zonei] = addressing[zonei]; } } @@ -1684,71 +1657,73 @@ void Foam::polyTopoChange::resetZones labelList nFaces(faceZones.size(), 0); - forAllConstIter(Map<label>, faceZone_, iter) + forAllConstIters(faceZone_, iter) { - label zoneI = iter(); + const label facei = iter.key(); + const label zonei = iter.object(); - if (zoneI < 0 || zoneI >= faceZones.size()) + if (zonei < 0 || zonei >= faceZones.size()) { FatalErrorInFunction - << "Illegal zoneID " << zoneI << " for face " - << iter.key() + << "Illegal zoneID " << zonei << " for face " + << facei << abort(FatalError); } - nFaces[zoneI]++; + nFaces[zonei]++; } labelListList addressing(faceZones.size()); boolListList flipMode(faceZones.size()); - forAll(addressing, zoneI) + forAll(addressing, zonei) { - addressing[zoneI].setSize(nFaces[zoneI]); - flipMode[zoneI].setSize(nFaces[zoneI]); + addressing[zonei].setSize(nFaces[zonei]); + flipMode[zonei].setSize(nFaces[zonei]); } nFaces = 0; - forAllConstIter(Map<label>, faceZone_, iter) + forAllConstIters(faceZone_, iter) { - label zoneI = iter(); - label facei = iter.key(); + const label facei = iter.key(); + const label zonei = iter.object(); - label index = nFaces[zoneI]++; + const label index = nFaces[zonei]++; - addressing[zoneI][index] = facei; - flipMode[zoneI][index] = faceZoneFlip_[facei]; + addressing[zonei][index] = facei; + flipMode[zonei][index] = faceZoneFlip_[facei]; } + // Sort the addressing - forAll(addressing, zoneI) + forAll(addressing, zonei) { labelList newToOld; - sortedOrder(addressing[zoneI], newToOld); + sortedOrder(addressing[zonei], newToOld); { - labelList newAddressing(addressing[zoneI].size()); + labelList newAddressing(addressing[zonei].size()); forAll(newAddressing, i) { - newAddressing[i] = addressing[zoneI][newToOld[i]]; + newAddressing[i] = addressing[zonei][newToOld[i]]; } - addressing[zoneI].transfer(newAddressing); + addressing[zonei].transfer(newAddressing); } { - boolList newFlipMode(flipMode[zoneI].size()); + boolList newFlipMode(flipMode[zonei].size()); forAll(newFlipMode, i) { - newFlipMode[i] = flipMode[zoneI][newToOld[i]]; + newFlipMode[i] = flipMode[zonei][newToOld[i]]; } - flipMode[zoneI].transfer(newFlipMode); + flipMode[zonei].transfer(newFlipMode); } } // So now we both have old zones and the new addressing. // Invert the addressing to get faceZoneFaceMap. - forAll(addressing, zoneI) + forAll(addressing, zonei) { - const faceZone& oldZone = faceZones[zoneI]; - const labelList& newZoneAddr = addressing[zoneI]; + const faceZone& oldZone = faceZones[zonei]; + const labelList& newZoneAddr = addressing[zonei]; - labelList& curFzFaceRnb = faceZoneFaceMap[zoneI]; + labelList& curFzFaceRnb = faceZoneFaceMap[zonei]; curFzFaceRnb.setSize(newZoneAddr.size()); @@ -1769,20 +1744,20 @@ void Foam::polyTopoChange::resetZones // Reset the addresing on the zone newMesh.faceZones().clearAddressing(); - forAll(newMesh.faceZones(), zoneI) + forAll(newMesh.faceZones(), zonei) { if (debug) { - Pout<< "faceZone:" << zoneI - << " name:" << newMesh.faceZones()[zoneI].name() - << " size:" << addressing[zoneI].size() + Pout<< "faceZone:" << zonei + << " name:" << newMesh.faceZones()[zonei].name() + << " size:" << addressing[zonei].size() << endl; } - newMesh.faceZones()[zoneI].resetAddressing + newMesh.faceZones()[zonei].resetAddressing ( - addressing[zoneI], - flipMode[zoneI] + addressing[zonei], + flipMode[zonei] ); } } @@ -1799,51 +1774,51 @@ void Foam::polyTopoChange::resetZones forAll(cellZone_, celli) { - label zoneI = cellZone_[celli]; + const label zonei = cellZone_[celli]; - if (zoneI >= cellZones.size()) + if (zonei >= cellZones.size()) { FatalErrorInFunction - << "Illegal zoneID " << zoneI << " for cell " + << "Illegal zoneID " << zonei << " for cell " << celli << abort(FatalError); } - if (zoneI >= 0) + if (zonei >= 0) { - nCells[zoneI]++; + nCells[zonei]++; } } labelListList addressing(cellZones.size()); - forAll(addressing, zoneI) + forAll(addressing, zonei) { - addressing[zoneI].setSize(nCells[zoneI]); + addressing[zonei].setSize(nCells[zonei]); } nCells = 0; forAll(cellZone_, celli) { - label zoneI = cellZone_[celli]; + const label zonei = cellZone_[celli]; - if (zoneI >= 0) + if (zonei >= 0) { - addressing[zoneI][nCells[zoneI]++] = celli; + addressing[zonei][nCells[zonei]++] = celli; } } // Sort the addressing - forAll(addressing, zoneI) + forAll(addressing, zonei) { - stableSort(addressing[zoneI]); + stableSort(addressing[zonei]); } // So now we both have old zones and the new addressing. // Invert the addressing to get cellZoneMap. - forAll(addressing, zoneI) + forAll(addressing, zonei) { - const cellZone& oldZone = cellZones[zoneI]; - const labelList& newZoneAddr = addressing[zoneI]; + const cellZone& oldZone = cellZones[zonei]; + const labelList& newZoneAddr = addressing[zonei]; - labelList& curCellRnb = cellZoneMap[zoneI]; + labelList& curCellRnb = cellZoneMap[zonei]; curCellRnb.setSize(newZoneAddr.size()); @@ -1863,17 +1838,17 @@ void Foam::polyTopoChange::resetZones // Reset the addresing on the zone newMesh.cellZones().clearAddressing(); - forAll(newMesh.cellZones(), zoneI) + forAll(newMesh.cellZones(), zonei) { if (debug) { - Pout<< "cellZone:" << zoneI - << " name:" << newMesh.cellZones()[zoneI].name() - << " size:" << addressing[zoneI].size() + Pout<< "cellZone:" << zonei + << " name:" << newMesh.cellZones()[zonei].name() + << " size:" << addressing[zonei].size() << endl; } - newMesh.cellZones()[zoneI] = addressing[zoneI]; + newMesh.cellZones()[zonei] = addressing[zonei]; } } } @@ -1882,7 +1857,7 @@ void Foam::polyTopoChange::resetZones void Foam::polyTopoChange::calcFaceZonePointMap ( const polyMesh& mesh, - const List<Map<label>>& oldFaceZoneMeshPointMaps, + const UList<Map<label>>& oldFaceZoneMeshPointMaps, labelListList& faceZonePointMap ) const { @@ -1890,15 +1865,15 @@ void Foam::polyTopoChange::calcFaceZonePointMap faceZonePointMap.setSize(faceZones.size()); - forAll(faceZones, zoneI) + forAll(faceZones, zonei) { - const faceZone& newZone = faceZones[zoneI]; + const faceZone& newZone = faceZones[zonei]; const labelList& newZoneMeshPoints = newZone().meshPoints(); - const Map<label>& oldZoneMeshPointMap = oldFaceZoneMeshPointMaps[zoneI]; + const Map<label>& oldZoneMeshPointMap = oldFaceZoneMeshPointMaps[zonei]; - labelList& curFzPointRnb = faceZonePointMap[zoneI]; + labelList& curFzPointRnb = faceZonePointMap[zonei]; curFzPointRnb.setSize(newZoneMeshPoints.size()); @@ -1906,20 +1881,12 @@ void Foam::polyTopoChange::calcFaceZonePointMap { if (newZoneMeshPoints[pointi] < pointMap_.size()) { - Map<label>::const_iterator ozmpmIter = - oldZoneMeshPointMap.find + curFzPointRnb[pointi] = + oldZoneMeshPointMap.lookup ( - pointMap_[newZoneMeshPoints[pointi]] + pointMap_[newZoneMeshPoints[pointi]], + -1 ); - - if (ozmpmIter != oldZoneMeshPointMap.end()) - { - curFzPointRnb[pointi] = ozmpmIter(); - } - else - { - curFzPointRnb[pointi] = -1; - } } else { @@ -1934,8 +1901,8 @@ void Foam::polyTopoChange::reorderCoupledFaces ( const bool syncParallel, const polyBoundaryMesh& boundary, - const labelList& patchStarts, - const labelList& patchSizes, + const labelUList& patchStarts, + const labelUList& patchSizes, const pointField& points ) { @@ -1986,7 +1953,7 @@ void Foam::polyTopoChange::reorderCoupledFaces labelList patchFaceMap(patchSizes[patchi], -1); labelList patchFaceRotation(patchSizes[patchi], 0); - bool changed = boundary[patchi].order + const bool changed = boundary[patchi].order ( pBufs, primitivePatch @@ -2006,7 +1973,7 @@ void Foam::polyTopoChange::reorderCoupledFaces if (changed) { // Merge patch face reordering into mesh face reordering table - label start = patchStarts[patchi]; + const label start = patchStarts[patchi]; forAll(patchFaceMap, patchFacei) { @@ -2169,11 +2136,11 @@ void Foam::polyTopoChange::compactAndReorder // later on to calculate the faceZone pointMaps. oldFaceZoneMeshPointMaps.setSize(mesh.faceZones().size()); - forAll(mesh.faceZones(), zoneI) + forAll(mesh.faceZones(), zonei) { - const faceZone& oldZone = mesh.faceZones()[zoneI]; + const faceZone& oldZone = mesh.faceZones()[zonei]; - oldFaceZoneMeshPointMaps[zoneI] = oldZone().meshPointMap(); + oldFaceZoneMeshPointMaps[zonei] = oldZone().meshPointMap(); } } @@ -2290,16 +2257,16 @@ void Foam::polyTopoChange::clear() void Foam::polyTopoChange::addMesh ( const polyMesh& mesh, - const labelList& patchMap, - const labelList& pointZoneMap, - const labelList& faceZoneMap, - const labelList& cellZoneMap + const labelUList& patchMap, + const labelUList& pointZoneMap, + const labelUList& faceZoneMap, + const labelUList& cellZoneMap ) { label maxRegion = nPatches_ - 1; - forAll(patchMap, i) + for (const label regioni : patchMap) { - maxRegion = max(maxRegion, patchMap[i]); + maxRegion = max(maxRegion, regioni); } nPatches_ = maxRegion + 1; @@ -2318,13 +2285,13 @@ void Foam::polyTopoChange::addMesh // Precalc offset zones labelList newZoneID(points.size(), -1); - forAll(pointZones, zoneI) + forAll(pointZones, zonei) { - const labelList& pointLabels = pointZones[zoneI]; + const labelList& pointLabels = pointZones[zonei]; - forAll(pointLabels, j) + for (const label pointi : pointLabels) { - newZoneID[pointLabels[j]] = pointZoneMap[zoneI]; + newZoneID[pointi] = pointZoneMap[zonei]; } } @@ -2362,14 +2329,12 @@ void Foam::polyTopoChange::addMesh // Precalc offset zones labelList newZoneID(nAllCells, -1); - forAll(cellZones, zoneI) + forAll(cellZones, zonei) { - const labelList& cellLabels = cellZones[zoneI]; + const labelList& cellLabels = cellZones[zonei]; - forAll(cellLabels, j) + for (const label celli : cellLabels) { - label celli = cellLabels[j]; - if (newZoneID[celli] != -1) { WarningInFunction @@ -2377,13 +2342,13 @@ void Foam::polyTopoChange::addMesh << " centre:" << mesh.cellCentres()[celli] << " is in two zones:" << cellZones[newZoneID[celli]].name() - << " and " << cellZones[zoneI].name() << endl + << " and " << cellZones[zonei].name() << endl << " This is not supported." << " Continuing with first zone only." << endl; } else { - newZoneID[celli] = cellZoneMap[zoneI]; + newZoneID[celli] = cellZoneMap[zonei]; } } } @@ -2424,15 +2389,15 @@ void Foam::polyTopoChange::addMesh labelList newZoneID(nAllFaces, -1); boolList zoneFlip(nAllFaces, false); - forAll(faceZones, zoneI) + forAll(faceZones, zonei) { - const labelList& faceLabels = faceZones[zoneI]; - const boolList& flipMap = faceZones[zoneI].flipMap(); + const labelList& faceLabels = faceZones[zonei]; + const boolList& flipMap = faceZones[zonei].flipMap(); - forAll(faceLabels, j) + forAll(faceLabels, facei) { - newZoneID[faceLabels[j]] = faceZoneMap[zoneI]; - zoneFlip[faceLabels[j]] = flipMap[j]; + newZoneID[faceLabels[facei]] = faceZoneMap[zonei]; + zoneFlip[faceLabels[facei]] = flipMap[facei]; } } @@ -2473,7 +2438,7 @@ void Foam::polyTopoChange::addMesh } forAll(pp, patchFacei) { - label facei = pp.start() + patchFacei; + const label facei = pp.start() + patchFacei; addFace ( @@ -2663,7 +2628,7 @@ Foam::label Foam::polyTopoChange::addPoint const bool inCell ) { - label pointi = points_.size(); + const label pointi = points_.size(); points_.append(pt); pointMap_.append(masterPointID); @@ -2687,7 +2652,7 @@ void Foam::polyTopoChange::modifyPoint ( const label pointi, const point& pt, - const label newZoneID, + const label zoneID, const bool inCell ) { @@ -2706,22 +2671,13 @@ void Foam::polyTopoChange::modifyPoint } points_[pointi] = pt; - Map<label>::iterator pointFnd = pointZone_.find(pointi); - - if (pointFnd != pointZone_.end()) + if (zoneID >= 0) { - if (newZoneID >= 0) - { - pointFnd() = newZoneID; - } - else - { - pointZone_.erase(pointFnd); - } + pointZone_.set(pointi, zoneID); } - else if (newZoneID >= 0) + else { - pointZone_.insert(pointi, newZoneID); + pointZone_.erase(pointi); } if (inCell) @@ -2889,29 +2845,24 @@ void Foam::polyTopoChange::modifyFace region_[facei] = patchID; flipFaceFlux_[facei] = (flipFaceFlux ? 1 : 0); + faceZoneFlip_[facei] = (zoneFlip ? 1 : 0); - Map<label>::iterator faceFnd = faceZone_.find(facei); - - if (faceFnd != faceZone_.end()) + if (zoneID >= 0) { - if (zoneID >= 0) - { - faceFnd() = zoneID; - } - else - { - faceZone_.erase(faceFnd); - } + faceZone_.set(facei, zoneID); } - else if (zoneID >= 0) + else { - faceZone_.insert(facei, zoneID); + faceZone_.erase(facei); } - faceZoneFlip_[facei] = (zoneFlip ? 1 : 0); } -void Foam::polyTopoChange::removeFace(const label facei, const label mergeFacei) +void Foam::polyTopoChange::removeFace +( + const label facei, + const label mergeFacei +) { if (facei < 0 || facei >= faces_.size()) { @@ -2949,8 +2900,8 @@ void Foam::polyTopoChange::removeFace(const label facei, const label mergeFacei) faceFromEdge_.erase(facei); faceFromPoint_.erase(facei); flipFaceFlux_[facei] = 0; - faceZone_.erase(facei); faceZoneFlip_[facei] = 0; + faceZone_.erase(facei); } @@ -3001,7 +2952,11 @@ void Foam::polyTopoChange::modifyCell } -void Foam::polyTopoChange::removeCell(const label celli, const label mergeCelli) +void Foam::polyTopoChange::removeCell +( + const label celli, + const label mergeCelli +) { if (celli < 0 || celli >= cellMap_.size()) { @@ -3124,7 +3079,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh forAll(pointMap_, newPointi) { - label oldPointi = pointMap_[newPointi]; + const label oldPointi = pointMap_[newPointi]; if (oldPointi >= 0) { diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H index e97c6ef7dbf..f9d7640583c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -197,30 +197,57 @@ class polyTopoChange // Private Member Functions - //- Reorder contents of container according to map + //- Reorder contents of container according to oldToNew map template<class T> - static void reorder(const labelList& map, DynamicList<T>&); + static void reorder + ( + const labelUList& oldToNew, + DynamicList<T>& lst + ); + template<class T> - static void reorder(const labelList& map, List<DynamicList<T>>&); + static void reorder + ( + const labelUList& oldToNew, + List<DynamicList<T>>& lst + ); + template<class T> - static void renumberKey(const labelList& map, Map<T>&); + static void renumberKey + ( + const labelUList& oldToNew, + Map<T>& map + ); + + //- Renumber elements of container according to oldToNew map + static void renumber + ( + const labelUList& oldToNew, + labelHashSet& labels + ); - //- Renumber elements of container according to map - static void renumber(const labelList&, labelHashSet&); //- Special handling of reverse maps which have <-1 in them - static void renumberReverseMap(const labelList&, DynamicList<label>&); + static void renumberReverseMap + ( + const labelUList& oldToNew, + DynamicList<label>& elems + ); //- Renumber & compact elements of list according to map - static void renumberCompact(const labelList&, labelList&); + static void renumberCompact + ( + const labelUList& oldToNew, + labelList& elems + ); //- Get all set elements as a labelHashSet - static labelHashSet getSetIndices(const PackedBoolList&); + static labelHashSet getSetIndices(const PackedBoolList& lst); //- Count number of added and removed quantities from maps. static void countMap ( - const labelList& map, - const labelList& reverseMap, + const labelUList& map, + const labelUList& reverseMap, label& nAdd, label& nInflate, label& nMerge, @@ -228,19 +255,19 @@ class polyTopoChange ); //- Print some stats about mesh - static void writeMeshStats(const polyMesh& mesh, Ostream&); + static void writeMeshStats(const polyMesh& mesh, Ostream& os); //- Calculate object maps. Requires reverseMap to have destination // to be marked with <-1. static void getMergeSets ( - const labelList& reverseCellMap, - const labelList& cellMap, + const labelUList& reverseCellMap, + const labelUList& cellMap, List<objectMap>& cellsFromCells ); //- Are all face vertices valid - bool hasValidPoints(const face&) const; + bool hasValidPoints(const face& f) const; //- Return face points pointField facePoints(const face& f) const; @@ -248,7 +275,7 @@ class polyTopoChange //- Check inputs to modFace or addFace void checkFace ( - const face&, + const face& f, const label facei, const label own, const label nei, @@ -274,16 +301,16 @@ class polyTopoChange //- Cell ordering (bandCompression). Returns number of remaining cells. label getCellOrder ( - const CompactListList<label, labelList>&, - labelList& + const CompactListList<label, labelList>& cellCellAddressing, + labelList& oldToNew ) const; //- Do upper-triangular ordering and patch ordering. void getFaceOrder ( const label nActiveFaces, - const labelList& cellFaces, - const labelList& cellFaceOffsets, + const labelUList& cellFaces, + const labelUList& cellFaceOffsets, labelList& oldToNew, labelList& patchSizes, @@ -294,7 +321,7 @@ class polyTopoChange void reorderCompactFaces ( const label newSize, - const labelList& oldToNew + const labelUList& oldToNew ); //- Remove all unused/removed points/faces/cells and update @@ -314,50 +341,50 @@ class polyTopoChange //- Select either internal or external faces out of faceLabels static labelList selectFaces ( - const primitiveMesh&, - const labelList& faceLabels, + const primitiveMesh& mesh, + const labelUList& faceLabels, const bool internalFacesOnly ); //- Calculate mapping for patchpoints only void calcPatchPointMap ( - const List<Map<label>>&, - const polyBoundaryMesh&, - labelListList& + const UList<Map<label>>& oldPatchMeshPointMaps, + const polyBoundaryMesh& boundary, + labelListList& patchPointMap ) const; void calcFaceInflationMaps ( - const polyMesh&, - List<objectMap>&, - List<objectMap>&, - List<objectMap>& + const polyMesh& mesh, + List<objectMap>& facesFromPoints, + List<objectMap>& facesFromEdges, + List<objectMap>& facesFromFaces ) const; void calcCellInflationMaps ( - const polyMesh&, - List<objectMap>&, - List<objectMap>&, - List<objectMap>&, - List<objectMap>& + const polyMesh& mesh, + List<objectMap>& cellsFromPoints, + List<objectMap>& cellsFromEdges, + List<objectMap>& cellsFromFaces, + List<objectMap>& cellsFromCells ) const; void resetZones ( - const polyMesh&, // mesh to get existing info from - polyMesh&, // mesh to change zones on - labelListList&, - labelListList&, - labelListList& + const polyMesh& mesh, // mesh to get existing info from + polyMesh& newMesh, // mesh to change zones on + labelListList& pointZoneMap, + labelListList& faceZoneFaceMap, + labelListList& cellZoneMap ) const; void calcFaceZonePointMap ( - const polyMesh&, - const List<Map<label>>&, - labelListList& + const polyMesh& mesh, + const UList<Map<label>>& oldFaceZoneMeshPointMaps, + labelListList& faceZonePointMap ) const; @@ -367,15 +394,15 @@ class polyTopoChange void reorderCoupledFaces ( const bool syncParallel, - const polyBoundaryMesh&, - const labelList& patchStarts, - const labelList& patchSizes, + const polyBoundaryMesh& boundary, + const labelUList& patchStarts, + const labelUList& patchSizes, const pointField& points ); void compactAndReorder ( - const polyMesh&, + const polyMesh& mesh, const bool syncParallel, const bool orderCells, const bool orderPoints, @@ -445,12 +472,15 @@ public: } //- Is point removed? + // Considered removed if point is GREAT. inline bool pointRemoved(const label pointi) const; //- Is face removed? + // Considered removed if face is empty inline bool faceRemoved(const label facei) const; //- Is cell removed? + // Considered removed if the cellMap is -2 inline bool cellRemoved(const label celli) const; @@ -463,11 +493,11 @@ public: // or zone ids. void addMesh ( - const polyMesh&, - const labelList& patchMap, - const labelList& pointZoneMap, - const labelList& faceZoneMap, - const labelList& cellZoneMap + const polyMesh& mesh, + const labelUList& patchMap, + const labelUList& pointZoneMap, + const labelUList& faceZoneMap, + const labelUList& cellZoneMap ); //- Explicitly pre-size the dynamic storage for expected mesh @@ -491,7 +521,7 @@ public: // - inCell = false: add retired point (to end of point list) label addPoint ( - const point&, + const point& pt, const label masterPointID, const label zoneID, const bool inCell @@ -499,17 +529,18 @@ public: //- Modify coordinate. // Notes: + // - zoneID = +ve (add to zoneID), -ve (remove from zones) // - inCell = false: add retired point (to end of point list) void modifyPoint ( - const label, - const point&, - const label newZoneID, + const label pointi, + const point& pt, + const label zoneID, const bool inCell ); //- Remove/merge point. - void removePoint(const label, const label); + void removePoint(const label pointi, const label mergePointi); //- Add face to cells. Return new face label. // own,nei<0, zoneID>=0 : add inactive face (to end of face list) @@ -541,7 +572,7 @@ public: ); //- Remove/merge face. - void removeFace(const label, const label); + void removeFace(const label facei, const label mergeFacei); //- Add cell. Return new cell label. label addCell @@ -554,10 +585,10 @@ public: ); //- Modify zone of cell - void modifyCell(const label, const label zoneID); + void modifyCell(const label celli, const label zoneID); //- Remove/merge cell. - void removeCell(const label, const label); + void removeCell(const label celli, const label mergeCelli); //- Explicitly set the number of patches if construct-without-mesh // used. diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.C index ddca640d04e..731d0beb018 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,20 +30,20 @@ License template<class T> void Foam::polyTopoChange::reorder ( - const labelList& oldToNew, + const labelUList& oldToNew, DynamicList<T>& lst ) { // Create copy DynamicList<T> oldLst(lst); - forAll(oldToNew, elemI) + forAll(oldToNew, i) { - label newElemI = oldToNew[elemI]; + const label newIdx = oldToNew[i]; - if (newElemI != -1) + if (newIdx >= 0) { - lst[newElemI] = oldLst[elemI]; + lst[newIdx] = oldLst[i]; } } } @@ -52,20 +52,20 @@ void Foam::polyTopoChange::reorder template<class T> void Foam::polyTopoChange::reorder ( - const labelList& oldToNew, + const labelUList& oldToNew, List<DynamicList<T>>& lst ) { // Create copy List<DynamicList<T>> oldLst(lst); - forAll(oldToNew, elemI) + forAll(oldToNew, i) { - label newElemI = oldToNew[elemI]; + const label newIdx = oldToNew[i]; - if (newElemI != -1) + if (newIdx >= 0) { - lst[newElemI].transfer(oldLst[elemI]); + lst[newIdx].transfer(oldLst[i]); } } } @@ -74,23 +74,23 @@ void Foam::polyTopoChange::reorder template<class T> void Foam::polyTopoChange::renumberKey ( - const labelList& oldToNew, - Map<T>& elems + const labelUList& oldToNew, + Map<T>& map ) { - Map<T> newElems(elems.size()); + Map<T> newMap(map.capacity()); - forAllConstIter(typename Map<T>, elems, iter) + forAllConstIters(map, iter) { - label newElem = oldToNew[iter.key()]; + const label newKey = oldToNew[iter.key()]; - if (newElem >= 0) + if (newKey >= 0) { - newElems.insert(newElem, iter()); + newMap.insert(newKey, iter.object()); } } - elems.transfer(newElems); + map.transfer(newMap); } diff --git a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C index 1d5794a5074..9257fa57d25 100644 --- a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,6 +44,7 @@ License const Foam::scalar Foam::slidingInterface::edgeCoPlanarTolDefault_ = 0.8; + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Index of debug signs: @@ -69,16 +70,13 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const { if (debug) { - Pout<< "void slidingInterface::coupleInterface" - << "(polyTopoChange& ref) : " - << "Coupling sliding interface " << name() << endl; + Pout<< FUNCTION_NAME << nl + << ": Coupling sliding interface " << name() << endl; } const polyMesh& mesh = topoChanger().mesh(); - const pointField& points = mesh.points(); const faceList& faces = mesh.faces(); - const labelList& own = mesh.faceOwner(); const labelList& nei = mesh.faceNeighbour(); const faceZoneMesh& faceZones = mesh.faceZones(); @@ -156,20 +154,19 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // Create mapping for every merged point of the slave patch forAll(slavePointPointHits, pointi) { - if (slavePointPointHits[pointi] >= 0) - { - // Pout<< "Inserting point merge pair: " << slaveMeshPoints[pointi] - // << " : " << masterMeshPoints[slavePointPointHits[pointi]] - // << endl; + const label slaveHitPti = slavePointPointHits[pointi]; + if (slaveHitPti >= 0) + { pointMergeMap.insert ( slaveMeshPoints[pointi], - masterMeshPoints[slavePointPointHits[pointi]] + masterMeshPoints[slaveHitPti] ); } } + // Collect the list of used edges for every slave edge List<labelHashSet> usedMasterEdges(slaveEdges.size()); @@ -187,22 +184,20 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // Mark all current master edges as used for all the current slave // edges - forAll(curSlaveEdges, slaveEdgeI) + for (const label slaveEdgei : curSlaveEdges) { - labelHashSet& sm = usedMasterEdges[curSlaveEdges[slaveEdgeI]]; - - forAll(curMasterEdges, masterEdgeI) - { - sm.insert(curMasterEdges[masterEdgeI]); - } + usedMasterEdges[slaveEdgei].insert + ( + curMasterEdges + ); } } else if (slavePointEdgeHits[pointi] > -1) { // For edge hits, add the master edge - forAll(curSlaveEdges, slaveEdgeI) + for (const label slaveEdgei : curSlaveEdges) { - usedMasterEdges[curSlaveEdges[slaveEdgeI]].insert + usedMasterEdges[slaveEdgei].insert ( slavePointEdgeHits[pointi] ); @@ -219,21 +214,18 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const { const labelList& curMasterEdges = masterPointEdges[masterPointi]; - labelHashSet& sm = - usedMasterEdges[masterPointEdgeHits[masterPointi]]; - - forAll(curMasterEdges, masterEdgeI) - { - sm.insert(curMasterEdges[masterEdgeI]); - } + usedMasterEdges[masterPointEdgeHits[masterPointi]].insert + ( + curMasterEdges + ); } } // Pout<< "used edges: " << endl; - // forAll(usedMasterEdges, edgeI) + // forAll(usedMasterEdges, edgei) // { - // Pout<< "edge: " << edgeI - // << " used: " << usedMasterEdges[edgeI].toc() + // Pout<< "edge: " << edgei + // << " used: " << usedMasterEdges[edgei].toc() // << endl; // } @@ -249,13 +241,13 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const { // Create a new point on the master edge - point edgeCutPoint = + const point edgeCutPoint = masterEdges[slavePointEdgeHits[pointi]].line ( masterLocalPoints ).nearestDist(projectedSlavePoints[pointi]).hitPoint(); - label newPoint = + const label newPointi = ref.setAction ( polyAddPoint @@ -267,32 +259,37 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const ) ); - // Pout<< "Inserting merge pair off edge: " - // << slaveMeshPoints[pointi] << " " << newPoint - // << " cut point: " << edgeCutPoint - // << " orig: " << slaveLocalPoints[pointi] - // << " proj: " << projectedSlavePoints[pointi] - // << endl; - // Add the new edge point into the merge map - pointMergeMap.insert(slaveMeshPoints[pointi], newPoint); + pointMergeMap.insert + ( + slaveMeshPoints[pointi], + newPointi + ); pointsIntoMasterEdges[slavePointEdgeHits[pointi]].append ( - newPoint + newPointi ); // Add the point into the enriched patch map pointMap.insert ( - newPoint, + newPointi, edgeCutPoint ); if (debug) { Pout<< "e"; - // Pout<< newPoint << " = " << edgeCutPoint << endl; + + // Pout<< "Inserting merge pair off edge: " + // << slaveMeshPoints[pointi] << " " << newPointi + // << " cut point: " << edgeCutPoint + // << " orig: " << slaveLocalPoints[pointi] + // << " proj: " << projectedSlavePoints[pointi] + // << endl; + + // Pout<< newPointi << " = " << edgeCutPoint << endl; } } } @@ -312,7 +309,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const && slavePointFaceHits[pointi].hit() ) { - label newPoint = + const label newPointi = ref.setAction ( polyAddPoint @@ -326,22 +323,26 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // Pout<< "Inserting merge pair off face: " // << slaveMeshPoints[pointi] - // << " " << newPoint + // << " " << newPointi // << endl; // Add the new edge point into the merge map - pointMergeMap.insert(slaveMeshPoints[pointi], newPoint); + pointMergeMap.insert + ( + slaveMeshPoints[pointi], + newPointi + ); // Add the point into the enriched patch map pointMap.insert ( - newPoint, + newPointi, projectedSlavePoints[pointi] ); if (debug) { - Pout<< "f: " << newPoint << " = " + Pout<< "f: " << newPointi << " = " << projectedSlavePoints[pointi] << endl; } } @@ -390,7 +391,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // if (debug) { - Pout<< "Processing slave edges " << endl; + Pout<< "Processing slave edges" << endl; } if (!cutPointEdgePairMapPtr_) @@ -430,65 +431,72 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // << " curUme: " << curUme // << endl; - // Clear the maps - curFaceMap.clear(); - addedFaces.clear(); - // Grab the faces for start and end points. const label startFace = slavePointFaceHits[curEdge.start()].hitObject(); - const label endFace = slavePointFaceHits[curEdge.end()].hitObject(); + + const label endFace = + slavePointFaceHits[curEdge.end()].hitObject(); // Pout<< "startFace: " << slavePointFaceHits[curEdge.start()] // << " endFace: " << slavePointFaceHits[curEdge.end()] // << endl; - // Insert the start face into the list - curFaceMap.insert(startFace); - addedFaces.insert(startFace); - - // Pout<< "curFaceMap: " << curFaceMap.toc() << endl; - - label nSweeps = 0; bool completed = false; - while (nSweeps < edgeFaceEscapeLimit_) + if (!completed) { - nSweeps++; + // Forward sweep - if (addedFaces.found(endFace)) - { - completed = true; - } - - // Add all face neighbours of face in the map - const labelList cf = addedFaces.toc(); + // Clear the maps + curFaceMap.clear(); addedFaces.clear(); - forAll(cf, cfI) + // Insert the start face into the list + curFaceMap.insert(startFace); + addedFaces.insert(startFace); + + // Pout<< "curFaceMap: " << curFaceMap.toc() << endl; + + for + ( + label nSweeps = 0; + nSweeps < edgeFaceEscapeLimit_; + ++nSweeps + ) { - const labelList& curNbrs = masterFaceFaces[cf[cfI]]; + completed = addedFaces.found(endFace); - forAll(curNbrs, nbrI) + // Add all face neighbours of face in the map + const labelList cf(std::move(addedFaces.toc())); + addedFaces.clear(); + + for (const label cfi : cf) { - if (!curFaceMap.found(curNbrs[nbrI])) + const labelList& curNbrs = masterFaceFaces[cfi]; + + for (const label nbri : curNbrs) { - curFaceMap.insert(curNbrs[nbrI]); - addedFaces.insert(curNbrs[nbrI]); + if (curFaceMap.insert(nbri)) + { + addedFaces.insert(nbri); + } } } - } - if (completed) break; + if (completed) break; - if (debug) - { - Pout<< "."; + if (debug) + { + Pout<< "."; + } } } if (!completed) { + // Reverse sweep + if (debug) { Pout<< "x"; @@ -497,34 +505,31 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // It is impossible to reach the end from the start, probably // due to disconnected domain. Do search in opposite direction - label nReverseSweeps = 0; - addedFaces.clear(); addedFaces.insert(endFace); - while (nReverseSweeps < edgeFaceEscapeLimit_) + for + ( + label nSweeps = 0; + nSweeps < edgeFaceEscapeLimit_; + ++nSweeps + ) { - nReverseSweeps++; - - if (addedFaces.found(startFace)) - { - completed = true; - } + completed = addedFaces.found(startFace); // Add all face neighbours of face in the map - const labelList cf = addedFaces.toc(); + const labelList cf(std::move(addedFaces.toc())); addedFaces.clear(); - forAll(cf, cfI) + for (const label cfi : cf) { - const labelList& curNbrs = masterFaceFaces[cf[cfI]]; + const labelList& curNbrs = masterFaceFaces[cfi]; - forAll(curNbrs, nbrI) + for (const label nbri : curNbrs) { - if (!curFaceMap.found(curNbrs[nbrI])) + if (curFaceMap.insert(nbri)) { - curFaceMap.insert(curNbrs[nbrI]); - addedFaces.insert(curNbrs[nbrI]); + addedFaces.insert(nbri); } } } @@ -561,27 +566,22 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const nFacesPerSlaveEdge_*primitiveMesh::edgesPerFace_ ); - const labelList curFaces = curFaceMap.toc(); - - // Pout<< "curFaces: " << curFaces << endl; - - forAll(curFaces, facei) + for (const label facei : curFaceMap) { - // Pout<< "face: " << curFaces[facei] << " " - // << masterPatch[curFaces[facei]] + // Pout<< "face: " << facei << " " + // << masterPatch[facei] // << " local: " - // << masterPatch.localFaces()[curFaces[facei]] + // << masterPatch.localFaces()[facei] // << endl; - const labelList& me = masterFaceEdges[curFaces[facei]]; - - forAll(me, meI) - { - curMasterEdgesMap.insert(me[meI]); - } + curMasterEdgesMap.insert + ( + masterFaceEdges[facei] + ); } - const labelList curMasterEdges = curMasterEdgesMap.toc(); + const labelList curMasterEdges(std::move(curMasterEdgesMap.toc())); + curMasterEdgesMap.clear(); // For all master edges to intersect, skip the ones // already used and cut the rest with a cutting plane. If @@ -597,7 +597,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const const point& a = projectedSlavePoints[curEdge.start()]; const point& b = projectedSlavePoints[curEdge.end()]; - point c = + const point c = 0.5* ( slaveLocalPoints[curEdge.start()] @@ -607,7 +607,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const ); // Create the plane - plane cutPlane(a, b, c); + const plane cutPlane(a, b, c); // Pout<< "a: " << a // << " b: " << b @@ -615,14 +615,16 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // << " plane: " << cutPlane // << endl; - linePointRef curSlaveLine = curEdge.line(projectedSlavePoints); + const linePointRef curSlaveLine = + curEdge.line(projectedSlavePoints); + const scalar curSlaveLineMag = curSlaveLine.mag(); // Pout<< "curSlaveLine: " << curSlaveLine << endl; - forAll(curMasterEdges, masterEdgeI) + for (const label cmeIndex : curMasterEdges) { - if (!curUme.found(curMasterEdges[masterEdgeI])) + if (!curUme.found(cmeIndex)) { // New edge if (debug) @@ -630,7 +632,6 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const Pout<< "n"; } - const label cmeIndex = curMasterEdges[masterEdgeI]; const edge& cme = masterEdges[cmeIndex]; // Pout<< "Edge " << cmeIndex @@ -638,7 +639,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // << " line: " << cme.line(masterLocalPoints) // << endl; - scalar cutOnMaster = + const scalar cutOnMaster = cutPlane.lineIntersect ( cme.line(masterLocalPoints) @@ -651,18 +652,18 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const ) { // Master is cut, check the slave - point masterCutPoint = + const point masterCutPoint = masterLocalPoints[cme.start()] + cutOnMaster*cme.vec(masterLocalPoints); - pointHit slaveCut = + const pointHit slaveCut = curSlaveLine.nearestDist(masterCutPoint); if (slaveCut.hit()) { // Strict checking of slave cut to avoid capturing // end points. - scalar cutOnSlave = + const scalar cutOnSlave = ( ( slaveCut.hitPoint() @@ -672,7 +673,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // Calculate merge tolerance from the // target edge length - scalar mergeTol = edgeCoPlanarTol_*mag(b - a); + const scalar mergeTol = edgeCoPlanarTol_*mag(b - a); // Pout<< "cutOnMaster: " << cutOnMaster // << " masterCutPoint: " << masterCutPoint @@ -697,7 +698,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // to edge points The point is nominally // added from the start of the master edge // and added to the cut point zone - label newPoint = + const label newPointi = ref.setAction ( polyAddPoint @@ -709,7 +710,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const ) ); - // Pout<< "Inserting point: " << newPoint + // Pout<< "Inserting point: " << newPointi // << " as edge to edge intersection. " // << "Slave edge: " // << edgeI << " " << curEdge @@ -717,16 +718,19 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // << cmeIndex << " " << cme // << endl; - pointsIntoSlaveEdges[edgeI].append(newPoint); + pointsIntoSlaveEdges[edgeI].append + ( + newPointi + ); pointsIntoMasterEdges[cmeIndex].append ( - newPoint + newPointi ); // Add the point into the enriched patch map pointMap.insert ( - newPoint, + newPointi, masterCutPoint ); @@ -734,25 +738,25 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // create cut point addToCpepm.insert ( - newPoint, // Cut point index + newPointi, // Cut point index Pair<edge> ( edge ( masterMeshPoints[cme.start()], masterMeshPoints[cme.end()] - ), // Master edge + ), // Master edge edge ( slaveMeshPoints[curEdge.start()], slaveMeshPoints[curEdge.end()] - )// Slave edge + ) // Slave edge ) ); if (debug) { - Pout<< " " << newPoint << " = " + Pout<< " " << newPointi << " = " << masterCutPoint << " "; } } @@ -955,12 +959,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const forAll(rsf, i) { - Map<label>::const_iterator mpIter = pointMergeMap.find(rsf[i]); - - if (mpIter != pointMergeMap.end()) - { - rsf[i] = mpIter(); - } + rsf[i] = pointMergeMap.lookup(rsf[i], rsf[i]); } if (curCutFace == rsf) @@ -1240,10 +1239,10 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const if (debug) { - Pout<< "Number of orphaned faces: " - << "master = " << nOrphanedMasters << " out of " + Pout<< "Orphaned faces: " + << "master = " << nOrphanedMasters << "/" << orphanedMaster.size() - << " slave = " << nOrphanedSlaves << " out of " + << " slave = " << nOrphanedSlaves << "/" << orphanedSlave.size() << endl; } @@ -1268,12 +1267,9 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // Pout<< "masterStickOuts: " << masterStickOuts << endl; // Re-create the master stick-out faces - forAll(masterStickOuts, facei) + for (const label curFaceID : masterStickOuts) { // Renumber the face and remove additional points - - const label curFaceID = masterStickOuts[facei]; - const face& oldRichFace = faces[curFaceID]; bool changed = false; @@ -1282,47 +1278,46 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const face oldFace(oldRichFace.size()); label nOldFace = 0; - forAll(oldRichFace, pointi) + for (const label pointi : oldRichFace) { - if (ref.pointRemoved(oldRichFace[pointi])) + if (ref.pointRemoved(pointi)) { changed = true; } else { // Point off patch - oldFace[nOldFace] = oldRichFace[pointi]; + oldFace[nOldFace] = pointi; nOldFace++; } } oldFace.setSize(nOldFace); - // Pout<< "old rich master face: " << oldRichFace - // << " old face: " << oldFace - // << endl; + // Pout<< "old rich face[" << curFaceID << "]: " << oldRichFace + // << " old face: " << oldFace << endl; DynamicList<label> newFaceLabels(2*oldFace.size()); forAll(oldFace, pointi) { - if (masterMeshPointMap.found(oldFace[pointi])) + const label localFirstLabel = + masterMeshPointMap.lookup(oldFace[pointi], -1); + + if (localFirstLabel != -1) { // Point is in master patch. Add it - // If the point is a direct hit, grab its label; otherwise - // keep the original - if (pointMergeMap.found(oldFace[pointi])) + // If the point is a direct hit, grab its label; + // otherwise keep the original + newFaceLabels.append + ( + pointMergeMap.lookup(oldFace[pointi], oldFace[pointi]) + ); + + if (newFaceLabels.last() != oldFace[pointi]) { changed = true; - newFaceLabels.append - ( - pointMergeMap.find(oldFace[pointi])() - ); - } - else - { - newFaceLabels.append(oldFace[pointi]); } // Find if there are additional points inserted onto the edge @@ -1331,39 +1326,35 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // 1) Find all the edges in the master patch coming // out of the current point. // 2) If the next point in the face to pick the right edge - const label localFirstLabel = - masterMeshPointMap.find(oldFace[pointi])(); const labelList& curEdges = masterPointEdges[localFirstLabel]; - const label nextLabel = oldFace.nextLabel(pointi); + const label nextLabel = oldFace.nextLabel(pointi); - Map<label>::const_iterator mmpmIter = - masterMeshPointMap.find(nextLabel); + const label localNextLabel = + masterMeshPointMap.lookup(nextLabel, -1); - if (mmpmIter != masterMeshPointMap.end()) + if (localNextLabel != -1) { // Pout<< "found label pair " << oldFace[pointi] // << " and " << nextLabel; // Find the points on the edge between them - const label localNextLabel = mmpmIter(); - forAll(curEdges, curEdgeI) + for (const label curEdgei : curEdges) { if ( - masterEdges[curEdges[curEdgeI]].otherVertex + masterEdges[curEdgei].otherVertex ( localFirstLabel ) == localNextLabel ) { - // Pout<< " found edge: " << curEdges[curEdgeI] - // << endl; + // Pout<< " found edge: " << curEdgei << endl; // Get points on current edge - const labelList& curPime = pime[curEdges[curEdgeI]]; + const labelList& curPime = pime[curEdgei]; if (curPime.size()) { @@ -1374,9 +1365,10 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const const point& startPoint = masterLocalPoints[localFirstLabel]; - vector e = - masterLocalPoints[localNextLabel] - - startPoint; + const point& endPoint = + masterLocalPoints[localNextLabel]; + + vector e = (endPoint - startPoint); e /= magSqr(e); @@ -1385,13 +1377,13 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const forAll(curPime, curPimeI) { edgePointWeights[curPimeI] = - ( - e - & ( - pointMap.find(curPime[curPimeI])() - - startPoint - ) - ); + ( + e + & ( + pointMap[curPime[curPimeI]] + - startPoint + ) + ); } if (debug) @@ -1466,25 +1458,24 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const } // Get face zone and its flip - label modifiedFaceZone = faceZones.whichZone(curFaceID); - bool modifiedFaceZoneFlip = false; + const label modifiedFaceZone = faceZones.whichZone(curFaceID); - if (modifiedFaceZone >= 0) - { - modifiedFaceZoneFlip = - faceZones[modifiedFaceZone].flipMap() - [ - faceZones[modifiedFaceZone].whichFace(curFaceID) - ]; - } + const bool modifiedFaceZoneFlip = + ( + modifiedFaceZone >= 0 + ? + faceZones[modifiedFaceZone].flipMap() + [ + faceZones[modifiedFaceZone].whichFace(curFaceID) + ] + : false + ); face newFace; newFace.transfer(newFaceLabels); - // Pout<< "Modifying master stick-out face " << curFaceID - // << " old face: " << oldFace - // << " new face: " << newFace - // << endl; + // Pout<< "Modifying master stick-out face[" << curFaceID + // << "]: old: " << oldFace << " new: " << newFace << endl; // Modify the face if (mesh.isInternalFace(curFaceID)) @@ -1540,11 +1531,9 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // Re-create the slave stick-out faces - forAll(slaveStickOuts, facei) + for (const label curFaceID : slaveStickOuts) { // Renumber the face and remove additional points - const label curFaceID = slaveStickOuts[facei]; - const face& oldRichFace = faces[curFaceID]; bool changed = false; @@ -1553,33 +1542,28 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const face oldFace(oldRichFace.size()); label nOldFace = 0; - forAll(oldRichFace, pointi) + for (const label pointi : oldRichFace) { if ( - rpm.found(oldRichFace[pointi]) - || slaveMeshPointMap.found(oldRichFace[pointi]) + rpm.found(pointi) + || slaveMeshPointMap.found(pointi) ) { // Point definitely live. Add it - oldFace[nOldFace] = oldRichFace[pointi]; + oldFace[nOldFace] = pointi; nOldFace++; } - else if - ( - ref.pointRemoved(oldRichFace[pointi]) - || masterMeshPointMap.found(oldRichFace[pointi]) - ) + else if (ref.pointRemoved(pointi)) { - // Point removed and not on slave patch - // (first if takes care of that!) or - // point belonging to master patch + // Point removed, not on slave patch and not retired + // (first if takes care of that!) changed = true; } else { - // Point off patch - oldFace[nOldFace] = oldRichFace[pointi]; + // Point on master or slave patch + oldFace[nOldFace] = pointi; nOldFace++; } } @@ -1595,33 +1579,29 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const forAll(oldFace, pointi) { // Try to find the point in retired points - label curP = oldFace[pointi]; - - Map<label>::const_iterator rpmIter = rpm.find(oldFace[pointi]); + const label curP = rpm.lookup(oldFace[pointi], oldFace[pointi]); - if (rpmIter != rpm.end()) + if (curP != oldFace[pointi]) { changed = true; - curP = rpmIter(); } - if (slaveMeshPointMap.found(curP)) + const label localFirstLabel = slaveMeshPointMap.lookup(curP, -1); + + if (localFirstLabel != -1) { // Point is in slave patch. Add it - // If the point is a direct hit, grab its label; otherwise - // keep the original - if (pointMergeMap.found(curP)) + // If the point is a direct hit, grab its label; + // otherwise keep the original + newFaceLabels.append + ( + pointMergeMap.lookup(curP, curP) + ); + + if (newFaceLabels.last() != curP) { changed = true; - newFaceLabels.append - ( - pointMergeMap.find(curP)() - ); - } - else - { - newFaceLabels.append(curP); } // Find if there are additional points inserted onto the edge @@ -1631,59 +1611,51 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // out of the current point. // 2) Use the next point in the face to pick the right edge - const label localFirstLabel = - slaveMeshPointMap.find(curP)(); - const labelList& curEdges = slavePointEdges[localFirstLabel]; label nextLabel = oldFace.nextLabel(pointi); - Map<label>::const_iterator rpmNextIter = - rpm.find(nextLabel); + nextLabel = rpm.lookup(nextLabel, nextLabel); - if (rpmNextIter != rpm.end()) - { - nextLabel = rpmNextIter(); - } + const label localNextLabel = + slaveMeshPointMap.lookup(nextLabel, -1); - Map<label>::const_iterator mmpmIter = - slaveMeshPointMap.find(nextLabel); - - if (mmpmIter != slaveMeshPointMap.end()) + if (localNextLabel != -1) { // Both points on the slave patch. // Find the points on the edge between them - const label localNextLabel = mmpmIter(); - forAll(curEdges, curEdgeI) + for (const label curEdgei : curEdges) { if ( - slaveEdges[curEdges[curEdgeI]].otherVertex + slaveEdges[curEdgei].otherVertex ( localFirstLabel ) == localNextLabel ) { - // Pout<< " found edge: " << curEdges[curEdgeI] + // Pout<< " found edge: " << curEdgei // << endl; // Get points on current edge - const labelList& curPise = pise[curEdges[curEdgeI]]; + const labelList& curPise = pise[curEdgei]; if (curPise.size()) { changed = true; + // Pout<< "curPise: " << curPise << endl; // Insert the edge points into the face // in the correct order const point& startPoint = projectedSlavePoints[localFirstLabel]; - vector e = - projectedSlavePoints[localNextLabel] - - startPoint; + const point& endPoint = + projectedSlavePoints[localNextLabel]; + + vector e = endPoint - startPoint; e /= magSqr(e); @@ -1695,7 +1667,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const ( e & ( - pointMap.find(curPise[curPiseI])() + pointMap[curPise[curPiseI]] - startPoint ) ); @@ -1773,24 +1745,25 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const } // Get face zone and its flip - label modifiedFaceZone = faceZones.whichZone(curFaceID); - bool modifiedFaceZoneFlip = false; + const label modifiedFaceZone = + faceZones.whichZone(curFaceID); - if (modifiedFaceZone >= 0) - { - modifiedFaceZoneFlip = - faceZones[modifiedFaceZone].flipMap() - [ - faceZones[modifiedFaceZone].whichFace(curFaceID) - ]; - } + const bool modifiedFaceZoneFlip + ( + modifiedFaceZone >= 0 + ? + faceZones[modifiedFaceZone].flipMap() + [ + faceZones[modifiedFaceZone].whichFace(curFaceID) + ] + : false + ); face newFace; newFace.transfer(newFaceLabels); - // Pout<< "Modifying slave stick-out face " << curFaceID - // << " old face: " << oldFace - // << " new face: " << newFace + // Pout<< "Modifying slave stick-out face[" << curFaceID + // << "]: old: " << oldFace << " new: " << newFace // << endl; // Modify the face @@ -1852,9 +1825,16 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const label nRetiredPoints = 0; - forAll(slaveMeshPoints, pointi) + for (const label slavePointi : slaveMeshPoints) { - if (pointMergeMap.found(slaveMeshPoints[pointi])) + const label masterPointi = pointMergeMap.lookup(slavePointi, -1); + + if (slavePointi == masterPointi) + { + // Identity mapping (ie, slave point already exists on master patch) + continue; + } + else if (masterPointi != -1) { // Retire the point - only used for supporting the detached // slave patch @@ -1862,32 +1842,28 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // ref.setAction // ( - // polyModifyPoint - // ( - // slaveMeshPoints[pointi], // point ID - // points[slaveMeshPoints[pointi]], // point - // false, // remove from zone - // mesh.pointZones().whichZone(slaveMeshPoints[pointi]), - // // zone - // false // in a cell - // ) + // polyModifyPoint + // ( + // slavePointi, // point ID + // points[slavePointi], // point + // false, // remove from zone + // mesh.pointZones().whichZone(slavePointi), // zone + // false // in a cell + // ) // ); - //Pout<< "MJ retire slave point " << slaveMeshPoints[pointi] - // << " coord " << points[slaveMeshPoints[pointi]] + // + //Pout<< "MJ retire slave point " << slavePointi + // << " coord " << points[slavePointi] // << endl; ref.setAction ( polyRemovePoint ( - slaveMeshPoints[pointi] + slavePointi ) ); - addToRpm.insert - ( - pointMergeMap.find(slaveMeshPoints[pointi])(), - slaveMeshPoints[pointi] - ); + addToRpm.insert(masterPointi, slavePointi); } else { @@ -1895,10 +1871,10 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const ( polyModifyPoint ( - slaveMeshPoints[pointi], // point ID - points[slaveMeshPoints[pointi]], // point + slavePointi, // point ID + points[slavePointi], // point false, // remove from zone - mesh.pointZones().whichZone(slaveMeshPoints[pointi]),// zone + mesh.pointZones().whichZone(slavePointi),// zone true // in a cell ) ); @@ -1907,15 +1883,15 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const if (debug) { - Pout<< "Retired " << nRetiredPoints << " out of " + Pout<< "Retired " << nRetiredPoints << "/" << slaveMeshPoints.size() << " points." << endl; } // Grab cut face master and slave addressing - if (cutFaceMasterPtr_) deleteDemandDrivenData(cutFaceMasterPtr_); + deleteDemandDrivenData(cutFaceMasterPtr_); cutFaceMasterPtr_ = new labelList(cutPatch.cutFaceMaster()); - if (cutFaceSlavePtr_) deleteDemandDrivenData(cutFaceSlavePtr_); + deleteDemandDrivenData(cutFaceSlavePtr_); cutFaceSlavePtr_ = new labelList(cutPatch.cutFaceSlave()); // Finished coupling @@ -1923,9 +1899,8 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const if (debug) { - Pout<< "void slidingInterface::coupleInterface(" - << "polyTopoChange& ref) : " - << "Finished coupling sliding interface " << name() << endl; + Pout<< FUNCTION_NAME << nl + << ": Finished coupling sliding interface " << name() << endl; } } diff --git a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C index e454e319811..95c3f91f2e6 100644 --- a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,18 +40,16 @@ void Foam::slidingInterface::decoupleInterface { if (debug) { - Pout<< "void slidingInterface::decoupleInterface(" - << "polyTopoChange& ref) const : " - << "Decoupling sliding interface " << name() << endl; + Pout<< FUNCTION_NAME << nl + << ": Decoupling sliding interface " << name() << endl; } if (!attached_) { if (debug) { - Pout<< "void slidingInterface::decoupleInterface(" - << "polyTopoChange& ref) const : " - << "Interface already decoupled." << endl; + Pout<< FUNCTION_NAME << nl + << ": Interface already decoupled." << endl; } return; @@ -61,22 +59,23 @@ void Foam::slidingInterface::decoupleInterface clearCouple(ref); const polyMesh& mesh = topoChanger().mesh(); + const pointField& points = mesh.points(); const faceList& faces = mesh.faces(); const cellList& cells = mesh.cells(); - const labelList& own = mesh.faceOwner(); const labelList& nei = mesh.faceNeighbour(); + const faceZoneMesh& faceZones = mesh.faceZones(); // Master side const primitiveFacePatch& masterPatch = - mesh.faceZones()[masterFaceZoneID_.index()](); + faceZones[masterFaceZoneID_.index()](); const labelList& masterPatchAddr = - mesh.faceZones()[masterFaceZoneID_.index()]; + faceZones[masterFaceZoneID_.index()]; const boolList& masterPatchFlip = - mesh.faceZones()[masterFaceZoneID_.index()].flipMap(); + faceZones[masterFaceZoneID_.index()].flipMap(); const labelList& masterFc = masterFaceCells(); @@ -119,13 +118,13 @@ void Foam::slidingInterface::decoupleInterface // Slave side const primitiveFacePatch& slavePatch = - mesh.faceZones()[slaveFaceZoneID_.index()](); + faceZones[slaveFaceZoneID_.index()](); const labelList& slavePatchAddr = - mesh.faceZones()[slaveFaceZoneID_.index()]; + faceZones[slaveFaceZoneID_.index()]; const boolList& slavePatchFlip = - mesh.faceZones()[slaveFaceZoneID_.index()].flipMap(); + faceZones[slaveFaceZoneID_.index()].flipMap(); const labelList& slaveFc = slaveFaceCells(); @@ -147,16 +146,7 @@ void Foam::slidingInterface::decoupleInterface // Recover retired points on the slave side forAll(newFace, pointi) { - Map<label>::const_iterator rpmIter = rpm.find(newFace[pointi]); - if (rpmIter != rpm.end()) - { - // Master of retired point; grab its original - // Pout<< "Reinstating retired point: " << newFace[pointi] - // << " with old: " << rpm.find(newFace[pointi])() - // << endl; - - newFace[pointi] = rpmIter(); - } + newFace[pointi] = rpm.lookup(newFace[pointi], newFace[pointi]); } ref.setAction @@ -181,12 +171,10 @@ void Foam::slidingInterface::decoupleInterface // Grab the list of faces in the layer const labelList& masterStickOuts = masterStickOutFaces(); - forAll(masterStickOuts, facei) + for (const label curFaceID : masterStickOuts) { // Renumber the face and remove additional points - const label curFaceID = masterStickOuts[facei]; - const face& oldFace = faces[curFaceID]; DynamicList<label> newFaceLabels(oldFace.size()); @@ -219,17 +207,18 @@ void Foam::slidingInterface::decoupleInterface } // Get face zone and its flip - label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID); - bool modifiedFaceZoneFlip = false; + const label modifiedFaceZone = faceZones.whichZone(curFaceID); - if (modifiedFaceZone >= 0) - { - modifiedFaceZoneFlip = - mesh.faceZones()[modifiedFaceZone].flipMap() - [ - mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID) - ]; - } + const bool modifiedFaceZoneFlip = + ( + modifiedFaceZone >= 0 + ? + faceZones[modifiedFaceZone].flipMap() + [ + faceZones[modifiedFaceZone].whichFace(curFaceID) + ] + : false + ); face newFace; newFace.transfer(newFaceLabels); @@ -265,23 +254,22 @@ void Foam::slidingInterface::decoupleInterface primitiveMesh::facesPerCell_*(masterPatch.size() + slavePatch.size()) ); - forAll(slaveFc, facei) + for (const label slaveFci : slaveFc) { - const labelList& curFaces = cells[slaveFc[facei]]; + const labelList& curFaces = cells[slaveFci]; - forAll(curFaces, facei) + for (const label facei : curFaces) { // Check if the face belongs to the slave face zone; and // if it has been removed; if not add it if ( - mesh.faceZones().whichZone(curFaces[facei]) + faceZones.whichZone(facei) != slaveFaceZoneID_.index() - && !ref.faceRemoved(curFaces[facei]) - + && !ref.faceRemoved(facei) ) { - slaveLayerCellFaceMap.insert(curFaces[facei]); + slaveLayerCellFaceMap.insert(facei); } } } @@ -292,12 +280,10 @@ void Foam::slidingInterface::decoupleInterface // Grab master point mapping const Map<label>& masterPm = masterPatch.meshPointMap(); - forAll(slaveStickOuts, facei) + for (const label curFaceID : slaveStickOuts) { // Renumber the face and remove additional points - const label curFaceID = slaveStickOuts[facei]; - const face& oldFace = faces[curFaceID]; DynamicList<label> newFaceLabels(oldFace.size()); @@ -307,16 +293,19 @@ void Foam::slidingInterface::decoupleInterface forAll(oldFace, pointi) { // Check if the point is removed or retired - if (rpm.found(oldFace[pointi])) + + const label retiredPointi = rpm.lookup(oldFace[pointi], -1); + + if (retiredPointi != -1) { // Master of retired point; grab its original changed = true; // Pout<< "Reinstating retired point: " << oldFace[pointi] - // << " with old: " << rpm.find(oldFace[pointi])() + // << " with old: " << retiredPointi // << endl; - newFaceLabels.append(rpm.find(oldFace[pointi])()); + newFaceLabels.append(retiredPointi); } else if (ref.pointRemoved(oldFace[pointi])) { @@ -346,17 +335,19 @@ void Foam::slidingInterface::decoupleInterface } // Get face zone and its flip - label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID); - bool modifiedFaceZoneFlip = false; + const label modifiedFaceZone = + faceZones.whichZone(curFaceID); - if (modifiedFaceZone >= 0) - { - modifiedFaceZoneFlip = - mesh.faceZones()[modifiedFaceZone].flipMap() - [ - mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID) - ]; - } + const bool modifiedFaceZoneFlip = + ( + modifiedFaceZone >= 0 + ? + faceZones[modifiedFaceZone].flipMap() + [ + faceZones[modifiedFaceZone].whichFace(curFaceID) + ] + : false + ); face newFace; newFace.transfer(newFaceLabels); @@ -386,22 +377,20 @@ void Foam::slidingInterface::decoupleInterface } // Bring all slave patch points back to life - const pointField& points = mesh.points(); - const labelList& slaveMeshPoints = - mesh.faceZones()[slaveFaceZoneID_.index()]().meshPoints(); + faceZones[slaveFaceZoneID_.index()]().meshPoints(); - forAll(slaveMeshPoints, pointi) + for (const label slavePointi : slaveMeshPoints) { ref.setAction ( polyModifyPoint ( - slaveMeshPoints[pointi], // point ID - points[slaveMeshPoints[pointi]], // point - false, // remove from zone - mesh.pointZones().whichZone(slaveMeshPoints[pointi]), // zone - true // in a cell + slavePointi, // point ID + points[slavePointi], // point + false, // remove from zone + mesh.pointZones().whichZone(slavePointi), // zone + true // in a cell ) ); } @@ -414,9 +403,8 @@ void Foam::slidingInterface::decoupleInterface if (debug) { - Pout<< "void slidingInterface::coupleInterface(" - << "polyTopoChange& ref) const : " - << "Finished decoupling sliding interface " << name() << endl; + Pout<< FUNCTION_NAME << nl + << ": Finished decoupling sliding interface " << name() << endl; } } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C index e0ba1fd8e2a..e4df4bc133c 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,7 +47,7 @@ void Foam::enrichedPatch::calcMeshPoints() const << abort(FatalError); } - meshPointsPtr_ = new labelList(pointMap().toc()); + meshPointsPtr_ = new labelList(std::move(pointMap().toc())); labelList& mp = *meshPointsPtr_; sort(mp); @@ -88,7 +88,7 @@ void Foam::enrichedPatch::calcLocalFaces() const forAll(f, pointi) { - curlf[pointi] = mpLookup.find(f[pointi])(); + curlf[pointi] = mpLookup.cfind(f[pointi])(); } } } @@ -110,7 +110,7 @@ void Foam::enrichedPatch::calcLocalPoints() const forAll(lp, i) { - lp[i] = pointMap().find(mp[i])(); + lp[i] = pointMap().cfind(mp[i])(); } } @@ -131,14 +131,13 @@ void Foam::enrichedPatch::clearOut() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::enrichedPatch::enrichedPatch ( const primitiveFacePatch& masterPatch, const primitiveFacePatch& slavePatch, - const labelList& slavePointPointHits, - const labelList& slavePointEdgeHits, - const List<objectHit>& slavePointFaceHits + const labelUList& slavePointPointHits, + const labelUList& slavePointEdgeHits, + const UList<objectHit>& slavePointFaceHits ) : masterPatch_(masterPatch), @@ -252,36 +251,20 @@ void Foam::enrichedPatch::writeOBJ(const fileName& fName) const { OFstream str(fName); - const pointField& lp = localPoints(); - - forAll(lp, pointi) - { - meshTools::writeOBJ(str, lp[pointi]); - } + meshTools::writeOBJ(str, localPoints()); const faceList& faces = localFaces(); - forAll(faces, facei) + for (const face& f : faces) { - const face& f = faces[facei]; - str << 'f'; - forAll(f, fp) + for (const label fp : f) { - str << ' ' << f[fp]+1; + str << ' ' << fp+1; } str << nl; } } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H index f47d46940ad..6d04a55a33f 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H @@ -36,8 +36,7 @@ Description Note: If new points are created during master-slave edge cutting, they - should be registred with the pointMap. - + should be registered with the pointMap. SourceFiles enrichedPatch.C @@ -134,10 +133,10 @@ class enrichedPatch // Private Member Functions //- Disallow default bitwise copy construct - enrichedPatch(const enrichedPatch&); + enrichedPatch(const enrichedPatch&) = delete; //- Disallow default bitwise assignment - void operator=(const enrichedPatch&); + void operator=(const enrichedPatch&) = delete; // Creation of demand-driven private data @@ -196,11 +195,11 @@ public: ( const primitiveFacePatch& masterPatch, const primitiveFacePatch& slavePatch, - const labelList& slavePointPointHits, + const labelUList& slavePointPointHits, // -1 or common point snapped to - const labelList& slavePointEdgeHits, + const labelUList& slavePointEdgeHits, // -1 or common edge snapped to - const List<objectHit>& slavePointFaceHits + const UList<objectHit>& slavePointFaceHits // master face snapped to ); @@ -213,23 +212,17 @@ public: // Access - //- Return non-const access to point map to add points - Map<point>& pointMap(); - //- Return map of points - const Map<point>& pointMap() const; + inline const Map<point>& pointMap() const; + + //- Return non-const access to point map to add points + inline Map<point>& pointMap(); //- Return map of point merges - Map<label>& pointMergeMap() - { - return pointMergeMap_; - } + inline const Map<label>& pointMergeMap() const; //- Return map of point merges - const Map<label>& pointMergeMap() const - { - return pointMergeMap_; - } + inline Map<label>& pointMergeMap(); // Topological data @@ -278,7 +271,7 @@ public: //- Debugging: dump graphical representation to obj format file - void writeOBJ(const fileName&) const; + void writeOBJ(const fileName& fName) const; }; @@ -288,6 +281,10 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "enrichedPatchI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C index 50c1af29f30..4c1fd310968 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,7 @@ Description #include "DynamicList.H" #include "labelPair.H" #include "primitiveMesh.H" -#include "HashSet.H" +#include "edgeHashes.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -94,9 +94,8 @@ void Foam::enrichedPatch::calcCutFaces() const // the points projected onto the face. // Create a set of edge usage parameters - HashSet<edge, Hash<edge>> edgesUsedOnce(pp.size()); - HashSet<edge, Hash<edge>> edgesUsedTwice - (pp.size()*primitiveMesh::edgesPerPoint_); + edgeHashSet edgesUsedOnce(pp.size()); + edgeHashSet edgesUsedTwice(pp.size()*primitiveMesh::edgesPerPoint_); forAll(lf, facei) @@ -145,9 +144,9 @@ void Foam::enrichedPatch::calcCutFaces() const // Insert the edges of current face into the seed list. edgeList cfe = curLocalFace.edges(); - forAll(curLocalFace, edgeI) + for (const edge& e : cfe) { - edgeSeeds.append(cfe[edgeI]); + edgeSeeds.append(e); } // Grab face normal @@ -156,9 +155,7 @@ void Foam::enrichedPatch::calcCutFaces() const while (edgeSeeds.size()) { - // Pout<< "edgeSeeds.size(): " - // << edgeSeeds.size() - // << endl; + // Pout<< "edgeSeeds.size(): " << edgeSeeds.size() << endl; const edge curEdge = edgeSeeds.removeHead(); @@ -198,6 +195,7 @@ void Foam::enrichedPatch::calcCutFaces() const cutFaceGlobalPoints.append(mp[prevPointLabel]); cutFaceLocalPoints.append(prevPointLabel); // Pout<< "prevPointLabel: " << mp[prevPointLabel] << endl; + // Grab current point and append it to the list label curPointLabel = curEdge.end(); point curPoint = lp[curPointLabel]; @@ -266,7 +264,7 @@ void Foam::enrichedPatch::calcCutFaces() const newDir /= magNewDir; - scalar curAtanTurn = + const scalar curAtanTurn = atan2(newDir & right, newDir & ahead); // Pout<< " atan: " << curAtanTurn << endl; @@ -352,19 +350,18 @@ void Foam::enrichedPatch::calcCutFaces() const // If the edge corresponds to a starting face edge, // mark the starting face edge as true - forAll(cutFaceLocal, cutI) + forAll(cutFaceLocal, cuti) { const edge curCutFaceEdge ( - cutFaceLocal[cutI], - cutFaceLocal.nextLabel(cutI) + cutFaceLocal[cuti], + cutFaceLocal.nextLabel(cuti) ); // Increment the usage count using two hash sets - HashSet<edge, Hash<edge>>::iterator euoIter = - edgesUsedOnce.find(curCutFaceEdge); + auto euoIter = edgesUsedOnce.find(curCutFaceEdge); - if (euoIter == edgesUsedOnce.end()) + if (!euoIter.found()) { // Pout<< "Found edge not used before: " // << curCutFaceEdge @@ -435,12 +432,12 @@ void Foam::enrichedPatch::calcCutFaces() const if (facei < slavePatch_.size()) { - Map<labelList>::const_iterator mpfAddrIter = - masterPointFaceAddr.find(cutFaceGlobal[0]); + const auto mpfAddrIter = + masterPointFaceAddr.cfind(cutFaceGlobal[0]); bool otherSideFound = false; - if (mpfAddrIter != masterPointFaceAddr.end()) + if (mpfAddrIter.found()) { bool miss = false; @@ -456,18 +453,13 @@ void Foam::enrichedPatch::calcCutFaces() const pointi++ ) { - Map<labelList>::const_iterator - mpfAddrPointIter = - masterPointFaceAddr.find - ( - cutFaceGlobal[pointi] - ); + const auto mpfAddrPointIter = + masterPointFaceAddr.cfind + ( + cutFaceGlobal[pointi] + ); - if - ( - mpfAddrPointIter - == masterPointFaceAddr.end() - ) + if (!mpfAddrPointIter.found()) { // Point is off the master patch. Skip miss = true; @@ -479,15 +471,11 @@ void Foam::enrichedPatch::calcCutFaces() const // For every current face, try to find it in the // zero-list - forAll(curMasterFaces, i) + for (const label facei : curMasterFaces) { forAll(masterFacesOfPZero, j) { - if - ( - curMasterFaces[i] - == masterFacesOfPZero[j] - ) + if (facei == masterFacesOfPZero[j]) { hits[j]++; break; @@ -644,7 +632,7 @@ void Foam::enrichedPatch::calcCutFaces() const } // end of local faces - // Re-pack the list into compact storage + // Re-pack lists into compact storage cutFacesPtr_ = new faceList(); cutFacesPtr_->transfer(cf); diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C index f6eb9de42e4..af4947e9127 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,11 +26,11 @@ License #include "enrichedPatch.H" #include "DynamicList.H" - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3; + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::enrichedPatch::calcEnrichedFaces @@ -79,68 +79,57 @@ void Foam::enrichedPatch::calcEnrichedFaces forAll(slavePatch_, facei) { - const face oldFace = slavePatch_[facei]; - const face oldLocalFace = slaveLocalFaces[facei]; -// Info<< "old slave face " << facei << ": " << oldFace << endl; + const face& oldFace = slavePatch_[facei]; + const face& oldLocalFace = slaveLocalFaces[facei]; const labelList& curEdges = slaveFaceEdges[facei]; + // Info<< "old slave face[" << facei << "] " << oldFace << endl; + DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_); // Note: The number of points and edges in a face is always identical // so both can be done is the same loop forAll(oldFace, i) { - // Add the point - Map<label>::const_iterator mpIter = - pmm.find(oldFace[i]); + // Add the point. + // Using the mapped point id if possible - if (mpIter == pmm.end()) - { - // Point not mapped - newFace.append(oldFace[i]); - - // Add the projected point into the patch support - pointMap().insert - ( - oldFace[i], // Global label of point - projectedSlavePoints[oldLocalFace[i]] // Projected position - ); - } - else - { - // Point mapped - newFace.append(mpIter()); - - // Add the projected point into the patch support - pointMap().insert - ( - mpIter(), // Merged global label of point - projectedSlavePoints[oldLocalFace[i]] // Projected position - ); - } + const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]); + + newFace.append(mappedPointi); + + // Add the projected point into the patch support + pointMap().insert + ( + mappedPointi, // Global label of point + projectedSlavePoints[oldLocalFace[i]] // Projected position + ); // Grab the edge points - const labelList& slavePointsOnEdge = + const labelList& pointsOnEdge = pointsIntoSlaveEdges[curEdges[i]]; - // Info<< "slavePointsOnEdge for " - // << curEdges[i] << ": " << slavePointsOnEdge + // Info<< "slave pointsOnEdge for " + // << curEdges[i] << ": " << pointsOnEdge // << endl; // If there are no points on the edge, skip everything // If there is only one point, no need for sorting - if (slavePointsOnEdge.size()) + if (pointsOnEdge.size()) { // Sort edge points in order - scalarField edgePointWeights(slavePointsOnEdge.size()); - const point& startPoint = projectedSlavePoints[oldLocalFace[i]]; + scalarField weightOnEdge(pointsOnEdge.size()); + + const point& startPoint = + projectedSlavePoints[oldLocalFace[i]]; - vector e = - projectedSlavePoints[oldLocalFace.nextLabel(i)] - - startPoint; + const point& endPoint = + projectedSlavePoints[oldLocalFace.nextLabel(i)]; - scalar magSqrE = magSqr(e); + vector e = (endPoint - startPoint); + + const scalar magSqrE = magSqr(e); if (magSqrE > SMALL) { @@ -154,27 +143,34 @@ void Foam::enrichedPatch::calcEnrichedFaces << abort(FatalError); } - pointField slavePosOnEdge(slavePointsOnEdge.size()); + pointField positionOnEdge(pointsOnEdge.size()); - forAll(slavePointsOnEdge, edgePointi) + forAll(pointsOnEdge, edgePointi) { - slavePosOnEdge[edgePointi] = - pointMap().find(slavePointsOnEdge[edgePointi])(); + positionOnEdge[edgePointi] = + pointMap()[pointsOnEdge[edgePointi]]; - edgePointWeights[edgePointi] = - (e & (slavePosOnEdge[edgePointi] - startPoint)); + weightOnEdge[edgePointi] = + ( + e + & + ( + positionOnEdge[edgePointi] + - startPoint + ) + ); } if (debug) { // Check weights: all new points should be on the edge - if (min(edgePointWeights) < 0 || max(edgePointWeights) > 1) + if (min(weightOnEdge) < 0 || max(weightOnEdge) > 1) { FatalErrorInFunction << " not on the edge for edge " << curEdges[i] << " of face " << facei << " in slave patch." << nl - << "Min weight: " << min(edgePointWeights) - << " Max weight: " << max(edgePointWeights) + << "Min weight: " << min(weightOnEdge) + << " Max weight: " << max(weightOnEdge) << abort(FatalError); } } @@ -182,101 +178,98 @@ void Foam::enrichedPatch::calcEnrichedFaces // Go through the points and collect them based on // weights from lower to higher. This gives the // correct order of points along the edge. - forAll(edgePointWeights, passI) + forAll(weightOnEdge, passI) { // Max weight can only be one, so the sorting is // done by elimination. label nextPoint = -1; scalar dist = 2; - forAll(edgePointWeights, wI) + forAll(weightOnEdge, wI) { - if (edgePointWeights[wI] < dist) + if (weightOnEdge[wI] < dist) { - dist = edgePointWeights[wI]; + dist = weightOnEdge[wI]; nextPoint = wI; } } // Insert the next point and reset its weight to exclude it // from future picks - newFace.append(slavePointsOnEdge[nextPoint]); - edgePointWeights[nextPoint] = GREAT; + newFace.append(pointsOnEdge[nextPoint]); + weightOnEdge[nextPoint] = GREAT; // Add the point into patch support pointMap().insert ( - slavePointsOnEdge[nextPoint], - slavePosOnEdge[nextPoint] + pointsOnEdge[nextPoint], + positionOnEdge[nextPoint] ); } } } - // Info<< "New slave face " << facei << ": " << newFace << endl; + + // Info<< "New slave face[" << facei << "] " + // << flatOutput(newFace) << " was " << flatOutput(oldFace) + // << endl; // Add the new face to the list enrichedFaces[nEnrichedFaces].transfer(newFace); nEnrichedFaces++; } + // Add master faces into the enriched faces list forAll(masterPatch_, facei) { const face& oldFace = masterPatch_[facei]; const face& oldLocalFace = masterLocalFaces[facei]; -// Info<< "old master face: " << oldFace << endl; const labelList& curEdges = masterFaceEdges[facei]; + // Info<< "old master face[" << facei << "] " << oldFace << endl; + DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_); // Note: The number of points and edges in a face is always identical // so both can be done is the same loop forAll(oldFace, i) { - // Add the point - Map<label>::const_iterator mpIter = - pmm.find(oldFace[i]); + // Add the point. + // Using the mapped point id if possible - if (mpIter == pmm.end()) - { - // Point not mapped - newFace.append(oldFace[i]); - - // Add the point into patch support - pointMap().insert - ( - oldFace[i], - masterLocalPoints[oldLocalFace[i]] - ); - } - else - { - // Point mapped - newFace.append(mpIter()); + const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]); - // Add the point into support - pointMap().insert(mpIter(), masterLocalPoints[oldLocalFace[i]]); - } + newFace.append(mappedPointi); + + // Add the point into patch support + pointMap().insert + ( + mappedPointi, // Global label of point + masterLocalPoints[oldLocalFace[i]] + ); // Grab the edge points - const labelList& masterPointsOnEdge = + const labelList& pointsOnEdge = pointsIntoMasterEdges[curEdges[i]]; // If there are no points on the edge, skip everything // If there is only one point, no need for sorting - if (masterPointsOnEdge.size()) + if (pointsOnEdge.size()) { // Sort edge points in order - scalarField edgePointWeights(masterPointsOnEdge.size()); - const point& startPoint = masterLocalPoints[oldLocalFace[i]]; + scalarField weightOnEdge(pointsOnEdge.size()); + + const point& startPoint = + masterLocalPoints[oldLocalFace[i]]; + + const point& endPoint = + masterLocalPoints[oldLocalFace.nextLabel(i)]; - vector e = - masterLocalPoints[oldLocalFace.nextLabel(i)] - - startPoint; + vector e = (endPoint - startPoint); - scalar magSqrE = magSqr(e); + const scalar magSqrE = magSqr(e); if (magSqrE > SMALL) { @@ -290,27 +283,33 @@ void Foam::enrichedPatch::calcEnrichedFaces << abort(FatalError); } - pointField masterPosOnEdge(masterPointsOnEdge.size()); + pointField positionOnEdge(pointsOnEdge.size()); - forAll(masterPointsOnEdge, edgePointi) + forAll(pointsOnEdge, edgePointi) { - masterPosOnEdge[edgePointi] = - pointMap().find(masterPointsOnEdge[edgePointi])(); + positionOnEdge[edgePointi] = + pointMap()[pointsOnEdge[edgePointi]]; - edgePointWeights[edgePointi] = - (e & (masterPosOnEdge[edgePointi] - startPoint)); + weightOnEdge[edgePointi] = + ( + e + & + ( + positionOnEdge[edgePointi] - startPoint + ) + ); } if (debug) { // Check weights: all new points should be on the edge - if (min(edgePointWeights) < 0 || max(edgePointWeights) > 1) + if (min(weightOnEdge) < 0 || max(weightOnEdge) > 1) { FatalErrorInFunction << " not on the edge for edge " << curEdges[i] << " of face " << facei << " in master patch." << nl - << "Min weight: " << min(edgePointWeights) - << " Max weight: " << max(edgePointWeights) + << "Min weight: " << min(weightOnEdge) + << " Max weight: " << max(weightOnEdge) << abort(FatalError); } } @@ -318,37 +317,40 @@ void Foam::enrichedPatch::calcEnrichedFaces // Go through the points and collect them based on // weights from lower to higher. This gives the // correct order of points along the edge. - forAll(edgePointWeights, passI) + forAll(weightOnEdge, passI) { // Max weight can only be one, so the sorting is // done by elimination. label nextPoint = -1; scalar dist = 2; - forAll(edgePointWeights, wI) + forAll(weightOnEdge, wI) { - if (edgePointWeights[wI] < dist) + if (weightOnEdge[wI] < dist) { - dist = edgePointWeights[wI]; + dist = weightOnEdge[wI]; nextPoint = wI; } } // Insert the next point and reset its weight to exclude it // from future picks - newFace.append(masterPointsOnEdge[nextPoint]); - edgePointWeights[nextPoint] = GREAT; + newFace.append(pointsOnEdge[nextPoint]); + weightOnEdge[nextPoint] = GREAT; // Add the point into patch support pointMap().insert ( - masterPointsOnEdge[nextPoint], - masterPosOnEdge[nextPoint] + pointsOnEdge[nextPoint], + positionOnEdge[nextPoint] ); } } } - // Info<< "New master face: " << newFace << endl; + + // Info<< "New master face[" << facei << "] " + // << flatOutput(newFace) << " was " << flatOutput(oldFace) + // << endl; // Add the new face to the list enrichedFaces[nEnrichedFaces].transfer(newFace); diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchI.H b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchI.H new file mode 100644 index 00000000000..0a03eb2bd22 --- /dev/null +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchI.H @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() const +{ + if (!pointMapComplete_) + { + completePointMap(); + } + + return pointMap_; +} + + +inline Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() +{ + if (!pointMapComplete_) + { + completePointMap(); + } + + return pointMap_; +} + + +inline const Foam::Map<Foam::label>& Foam::enrichedPatch::pointMergeMap() const +{ + return pointMergeMap_; +} + + +inline Foam::Map<Foam::label>& Foam::enrichedPatch::pointMergeMap() +{ + return pointMergeMap_; +} + + + +// ************************************************************************* // diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C index 280f4324d29..18edef858ed 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,6 +32,7 @@ License const Foam::label Foam::enrichedPatch::nFaceHits_ = 4; + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::enrichedPatch::calcMasterPointFaces() const @@ -51,7 +52,7 @@ void Foam::enrichedPatch::calcMasterPointFaces() const // Master face points lists the points of the enriched master face plus // points projected into the master face - Map<DynamicList<label>> mpf(meshPoints().size()); + Map<DynamicList<label>> mpf(2*meshPoints().size()); const faceList& ef = enrichedFaces(); @@ -59,28 +60,14 @@ void Foam::enrichedPatch::calcMasterPointFaces() const forAll(masterPatch_, facei) { const face& curFace = ef[facei + slavePatch_.size()]; -// Pout<< "Cur face in pfAddr: " << curFace << endl; - forAll(curFace, pointi) + + for (const label pointi : curFace) { - Map<DynamicList<label>>::iterator mpfIter = - mpf.find(curFace[pointi]); - - if (mpfIter == mpf.end()) - { - // Not found, add new dynamic list - mpf.insert - ( - curFace[pointi], - DynamicList<label>(primitiveMesh::facesPerPoint_) - ); - - // Iterator is invalidated - have to find again - mpf.find(curFace[pointi])().append(facei); - } - else - { - mpfIter().append(facei); - } + DynamicList<label>& dynLst = mpf(pointi); // Get or create + + dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list + + dynLst.append(facei); } } @@ -96,50 +83,27 @@ void Foam::enrichedPatch::calcMasterPointFaces() const && slavePointFaceHits_[pointi].hit() ) { - // Get the index of projected point corresponding to this slave - // point - const label mergedSmp = - pointMergeMap().find(slaveMeshPoints[pointi])(); - - Map<DynamicList<label>>::iterator mpfIter = - mpf.find(mergedSmp); - - if (mpfIter == mpf.end()) - { - // Not found, add new dynamic list - mpf.insert - ( - mergedSmp, - DynamicList<label>(primitiveMesh::facesPerPoint_) - ); - - // Iterator is invalidated - have to find again - mpf.find(mergedSmp)().append - ( - slavePointFaceHits_[pointi].hitObject() - ); - } - else - { - mpfIter().append(slavePointFaceHits_[pointi].hitObject()); - } + // Index of projected point corresponding to this slave point + const label mergedPointi = pointMergeMap()[slaveMeshPoints[pointi]]; + + DynamicList<label>& dynLst = mpf(mergedPointi); // Get or create + + dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list + + dynLst.append(slavePointFaceHits_[pointi].hitObject()); } } // Re-pack dynamic lists into normal lists - const labelList mpfToc = mpf.toc(); - masterPointFacesPtr_ = new Map<labelList>(2*mpfToc.size()); - Map<labelList>& masterPointFaceAddr = *masterPointFacesPtr_; + masterPointFacesPtr_ = new Map<labelList>(2*mpf.size()); + Map<labelList>& masterPointFaceMap = *masterPointFacesPtr_; - forAll(mpfToc, mpfTocI) + forAllIters(mpf, mpfIter) { - labelList l; - l.transfer(mpf.find(mpfToc[mpfTocI])()); - - masterPointFaceAddr.insert(mpfToc[mpfTocI], l); + masterPointFaceMap(mpfIter.key()).transfer(mpfIter.object()); } - // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl; + // Pout<< "masterPointFaceMap: " << masterPointFaceMap << endl; } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C index bab79f69266..632578586ed 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C @@ -40,8 +40,8 @@ void Foam::enrichedPatch::completePointMap() const const Map<label>& pmm = pointMergeMap(); - // Get the mesh points for both patches. If the point has not been - // merged away, add it to the map + // Get the mesh points for both patches. + // If the point has not been merged away, add it to the map // Do master patch const labelList& masterMeshPoints = masterPatch_.meshPoints(); @@ -77,29 +77,4 @@ void Foam::enrichedPatch::completePointMap() const } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() -{ - if (!pointMapComplete_) - { - completePointMap(); - } - - return pointMap_; -} - - -const Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() const -{ - if (!pointMapComplete_) - { - completePointMap(); - } - - return pointMap_; -} - - // ************************************************************************* // diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C index 7a04712c027..0bd562692a2 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C @@ -27,9 +27,6 @@ License #include "primitiveMesh.H" #include "DynamicList.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::enrichedPatch::calcPointPoints() const @@ -52,16 +49,14 @@ void Foam::enrichedPatch::calcPointPoints() const bool found = false; - forAll(lf, facei) + for (const face& curFace : lf) { - const face& curFace = lf[facei]; - forAll(curFace, pointi) { DynamicList<label>& curPp = pp[curFace[pointi]]; // Do next label - label next = curFace.nextLabel(pointi); + const label next = curFace.nextLabel(pointi); found = false; @@ -80,7 +75,7 @@ void Foam::enrichedPatch::calcPointPoints() const } // Do previous label - label prev = curFace.prevLabel(pointi); + const label prev = curFace.prevLabel(pointi); found = false; forAll(curPp, i) diff --git a/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C b/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C index 34504028ce5..305db3f376d 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C +++ b/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,7 +34,7 @@ void Foam::slidingInterface::calcAttachedAddressing() const { if (debug) { - Pout<< "void Foam::slidingInterface::calcAttachedAddressing() const " + Pout<< FUNCTION_NAME << " for object " << name() << " : " << "Calculating zone face-cell addressing." << endl; @@ -140,64 +140,85 @@ void Foam::slidingInterface::calcAttachedAddressing() const // Calculate stick-out faces const labelListList& pointFaces = mesh.pointFaces(); - // Master side - labelHashSet masterStickOutFaceMap + labelHashSet stickOutFaceMap ( - primitiveMesh::facesPerCell_*(masterPatch.size()) + primitiveMesh::facesPerCell_ + * max(masterPatch.size(), slavePatch.size()) ); + // Master side const labelList& masterMeshPoints = masterPatch.meshPoints(); - forAll(masterMeshPoints, pointi) - { - const labelList& curFaces = pointFaces[masterMeshPoints[pointi]]; + stickOutFaceMap.clear(); - forAll(curFaces, facei) + for (const label pointi : masterMeshPoints) + { + for (const label facei : pointFaces[pointi]) { - // Check if the face belongs to the master face zone; - // if not add it + const label zoneIdx = faceZones.whichZone(facei); + + // Add if face not already part of master or slave face zone + // This handles partially attached faces. if ( - faceZones.whichZone(curFaces[facei]) - != masterFaceZoneID_.index() + zoneIdx != masterFaceZoneID_.index() + && zoneIdx != slaveFaceZoneID_.index() ) { - masterStickOutFaceMap.insert(curFaces[facei]); + stickOutFaceMap.insert(facei); } } } - masterStickOutFacesPtr_ = new labelList(masterStickOutFaceMap.toc()); + // Sort in debug mode for easier diagnostics + if (debug) + { + masterStickOutFacesPtr_ = + new labelList(std::move(stickOutFaceMap.sortedToc())); + } + else + { + masterStickOutFacesPtr_ = + new labelList(std::move(stickOutFaceMap.toc())); + } // Slave side - labelHashSet slaveStickOutFaceMap - ( - primitiveMesh::facesPerCell_*(slavePatch.size()) - ); - const labelList& slaveMeshPoints = slavePatch.meshPoints(); - forAll(slaveMeshPoints, pointi) - { - const labelList& curFaces = pointFaces[slaveMeshPoints[pointi]]; + stickOutFaceMap.clear(); - forAll(curFaces, facei) + for (const label pointi : slaveMeshPoints) + { + for (const label facei : pointFaces[pointi]) { - // Check if the face belongs to the slave face zone; - // if not add it + const label zoneIdx = faceZones.whichZone(facei); + + // Add if face not already part of master or slave face zone + // This handles partially attached faces. if ( - faceZones.whichZone(curFaces[facei]) - != slaveFaceZoneID_.index() + zoneIdx != masterFaceZoneID_.index() + && zoneIdx != slaveFaceZoneID_.index() ) { - slaveStickOutFaceMap.insert(curFaces[facei]); + stickOutFaceMap.insert(facei); } } } - slaveStickOutFacesPtr_ = new labelList(slaveStickOutFaceMap.toc()); + // Sort in debug mode for easier diagnostics + if (debug) + { + slaveStickOutFacesPtr_ = + new labelList(std::move(stickOutFaceMap.sortedToc())); + } + else + { + slaveStickOutFacesPtr_ = + new labelList(std::move(stickOutFaceMap.toc())); + } + stickOutFaceMap.clear(); // Retired point addressing does not exist at this stage. // It will be filled when the interface is coupled. @@ -208,7 +229,6 @@ void Foam::slidingInterface::calcAttachedAddressing() const ); // Ditto for cut point edge map. This is a rough guess of its size - // cutPointEdgePairMapPtr_ = new Map<Pair<edge>> ( @@ -224,7 +244,7 @@ void Foam::slidingInterface::calcAttachedAddressing() const if (debug) { - Pout<< "void Foam::slidingInterface::calcAttachedAddressing() const " + Pout<< FUNCTION_NAME << " for object " << name() << " : " << "Finished calculating zone face-cell addressing." << endl; diff --git a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C index 7a0cfe1a088..9e52c5f1037 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C +++ b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,8 +58,8 @@ bool Foam::slidingInterface::projectPoints() const { if (debug) { - Pout<< "bool slidingInterface::projectPoints() : " - << " for object " << name() << " : " + Pout<< FUNCTION_NAME << nl + << ": for object " << name() << " : " << "Projecting slave points onto master surface." << endl; } @@ -126,12 +126,11 @@ bool Foam::slidingInterface::projectPoints() const scalarField minMasterPointLength(masterLocalPoints.size(), GREAT); scalarField minMasterFaceLength(masterPatch.size(), GREAT); - forAll(masterEdges, edgeI) + forAll(masterEdges, edgei) { - const edge& curEdge = masterEdges[edgeI]; + const edge& curEdge = masterEdges[edgei]; - const scalar curLength = - masterEdges[edgeI].mag(masterLocalPoints); + const scalar curLength = curEdge.mag(masterLocalPoints); // Do points minMasterPointLength[curEdge.start()] = @@ -149,14 +148,14 @@ bool Foam::slidingInterface::projectPoints() const ); // Do faces - const labelList& curFaces = masterEdgeFaces[edgeI]; + const labelList& curFaces = masterEdgeFaces[edgei]; - forAll(curFaces, facei) + for (const label facei : curFaces) { - minMasterFaceLength[curFaces[facei]] = + minMasterFaceLength[facei] = min ( - minMasterFaceLength[curFaces[facei]], + minMasterFaceLength[facei], curLength ); } @@ -169,12 +168,11 @@ bool Foam::slidingInterface::projectPoints() const scalarField minSlavePointLength(slaveLocalPoints.size(), GREAT); scalarField minSlaveFaceLength(slavePatch.size(), GREAT); - forAll(slaveEdges, edgeI) + forAll(slaveEdges, edgei) { - const edge& curEdge = slaveEdges[edgeI]; + const edge& curEdge = slaveEdges[edgei]; - const scalar curLength = - slaveEdges[edgeI].mag(slaveLocalPoints); + const scalar curLength = curEdge.mag(slaveLocalPoints); // Do points minSlavePointLength[curEdge.start()] = @@ -192,14 +190,14 @@ bool Foam::slidingInterface::projectPoints() const ); // Do faces - const labelList& curFaces = slaveEdgeFaces[edgeI]; + const labelList& curFaces = slaveEdgeFaces[edgei]; - forAll(curFaces, facei) + for (const label facei : curFaces) { - minSlaveFaceLength[curFaces[facei]] = + minSlaveFaceLength[facei] = min ( - minSlaveFaceLength[curFaces[facei]], + minSlaveFaceLength[facei], curLength ); } @@ -219,25 +217,15 @@ bool Foam::slidingInterface::projectPoints() const projectionAlgo_ ); -// Pout<< "USING N-SQUARED!!!" << endl; -// List<objectHit> slavePointFaceHits = -// projectPointsNSquared<face, List, const pointField&> -// ( -// slavePatch, -// masterPatch, -// slavePointNormals, -// projectionAlgo_ -// ); - if (debug) { label nHits = 0; - forAll(slavePointFaceHits, pointi) + for (const auto& hit : slavePointFaceHits) { - if (slavePointFaceHits[pointi].hit()) + if (hit.hit()) { - nHits++; + ++nHits; } } @@ -247,8 +235,7 @@ bool Foam::slidingInterface::projectPoints() const } // Projected slave points are stored for mesh motion correction - if (projectedSlavePointsPtr_) delete projectedSlavePointsPtr_; - + deleteDemandDrivenData(projectedSlavePointsPtr_); projectedSlavePointsPtr_ = new pointField(slavePointFaceHits.size(), Zero); pointField& projectedSlavePoints = *projectedSlavePointsPtr_; @@ -380,29 +367,27 @@ bool Foam::slidingInterface::projectPoints() const // Check for zero-length edges in slave projection scalar minEdgeLength = GREAT; - scalar el = 0; label nShortEdges = 0; - forAll(slaveEdges, edgeI) + for (const edge& e : slaveEdges) { - el = slaveEdges[edgeI].mag(projectedSlavePoints); + const scalar len = e.mag(projectedSlavePoints); + minEdgeLength = min(minEdgeLength, len); - if (el < SMALL) + if (len < SMALL) { Pout<< "Point projection problems for edge: " - << slaveEdges[edgeI] << ". Length = " << el + << e << ". Length = " << len << endl; nShortEdges++; } - - minEdgeLength = min(minEdgeLength, el); } if (nShortEdges > 0) { FatalErrorInFunction - << " short projected edges " + << nShortEdges << " short projected edges " << "after adjustment for object " << name() << abort(FatalError); } @@ -439,10 +424,10 @@ bool Foam::slidingInterface::projectPoints() const { if (slavePointFaceHits[pointi].hit()) { - // Taking a non-const reference so the point can be adjusted + // Use non-const reference so the point can be adjusted point& curPoint = projectedSlavePoints[pointi]; - // Get the hit face + // Get the hit face (on master) const face& hitFace = masterLocalFaces[slavePointFaceHits[pointi].hitObject()]; @@ -450,10 +435,10 @@ bool Foam::slidingInterface::projectPoints() const scalar mergeDist = GREAT; // Try all point before deciding on best fit. - forAll(hitFace, hitPointi) + for (const label hitPointi : hitFace) { - scalar dist = - mag(masterLocalPoints[hitFace[hitPointi]] - curPoint); + const scalar dist = + mag(masterLocalPoints[hitPointi] - curPoint); // Calculate the tolerance const scalar mergeTol = @@ -461,12 +446,12 @@ bool Foam::slidingInterface::projectPoints() const min ( minSlavePointLength[pointi], - minMasterPointLength[hitFace[hitPointi]] + minMasterPointLength[hitPointi] ); if (dist < mergeTol && dist < mergeDist) { - mergePoint = hitFace[hitPointi]; + mergePoint = hitPointi; mergeDist = dist; // Pout<< "Merging slave point " @@ -481,12 +466,17 @@ bool Foam::slidingInterface::projectPoints() const if (mergePoint > -1) { - // Point is to be merged with master point + // Slave point is to be merged with master point. + // This may also include a false positive when the two points + // already point to the same global point, but this will need + // to be addressed by the caller. nMergedPoints++; slavePointPointHits[pointi] = mergePoint; - curPoint = masterLocalPoints[mergePoint]; masterPointPointHits[mergePoint] = pointi; + + // Adjust (snap) slave point + curPoint = masterLocalPoints[mergePoint]; } } } @@ -498,20 +488,18 @@ bool Foam::slidingInterface::projectPoints() const { // Check for zero-length edges in slave projection scalar minEdgeLength = GREAT; - scalar el = 0; - forAll(slaveEdges, edgeI) + for (const edge& e : slaveEdges) { - el = slaveEdges[edgeI].mag(projectedSlavePoints); + const scalar len = e.mag(projectedSlavePoints); + minEdgeLength = min(minEdgeLength, len); - if (el < SMALL) + if (len < SMALL) { Pout<< "Point projection problems for edge: " - << slaveEdges[edgeI] << ". Length = " << el + << e << ". Length = " << len << endl; } - - minEdgeLength = min(minEdgeLength, el); } if (minEdgeLength < SMALL) @@ -556,16 +544,16 @@ bool Foam::slidingInterface::projectPoints() const scalar minDistance = GREAT; - forAll(hitFaceEdges, edgeI) + for (const label edgei : hitFaceEdges) { - const edge& curEdge = masterEdges[hitFaceEdges[edgeI]]; + const edge& curEdge = masterEdges[edgei]; pointHit edgeHit = curEdge.line(masterLocalPoints).nearestDist(curPoint); if (edgeHit.hit()) { - scalar dist = + const scalar dist = mag(edgeHit.hitPoint() - projectedSlavePoints[pointi]); if (dist < mergeTol && dist < minDistance) @@ -573,7 +561,7 @@ bool Foam::slidingInterface::projectPoints() const // Point is to be moved onto master edge nMovedPoints++; - slavePointEdgeHits[pointi] = hitFaceEdges[edgeI]; + slavePointEdgeHits[pointi] = edgei; projectedSlavePoints[pointi] = edgeHit.hitPoint(); minDistance = dist; @@ -582,7 +570,7 @@ bool Foam::slidingInterface::projectPoints() const // << slavePatch.meshPoints()[pointi] // << " (" << pointi // << ") at " << slaveLocalPoints[pointi] -// << " onto master edge " << hitFaceEdges[edgeI] +// << " onto master edge " << edgei // << " or (" // << masterLocalPoints[curEdge.start()] // << masterLocalPoints[curEdge.end()] @@ -607,7 +595,7 @@ bool Foam::slidingInterface::projectPoints() const forAll(hitMasterEdge, hmeI) { - scalar hmeDist = + const scalar hmeDist = mag(masterLocalPoints[hitMasterEdge[hmeI]] - curPoint); // Calculate the tolerance @@ -660,27 +648,25 @@ bool Foam::slidingInterface::projectPoints() const // Check for zero-length edges in slave projection scalar minEdgeLength = GREAT; - scalar el = 0; - forAll(slaveEdges, edgeI) + for (const edge& e : slaveEdges) { - el = slaveEdges[edgeI].mag(projectedSlavePoints); + const scalar len = e.mag(projectedSlavePoints); + minEdgeLength = min(minEdgeLength, len); - if (el < SMALL) + if (len < SMALL) { Pout<< "Point projection problems for edge: " - << slaveEdges[edgeI] << ". Length = " << el + << e << ". Length = " << len << endl; } - - minEdgeLength = min(minEdgeLength, el); } if (minEdgeLength < SMALL) { FatalErrorInFunction - << " after correction for object " << name() - << abort(FatalError); + << " after correction for object " << name() + << abort(FatalError); } } @@ -747,25 +733,19 @@ bool Foam::slidingInterface::projectPoints() const labelHashSet addedFaces(2*primitiveMesh::edgesPerFace_); - forAll(slaveEdges, edgeI) + forAll(slaveEdges, edgei) { - const edge& curEdge = slaveEdges[edgeI]; + const edge& curEdge = slaveEdges[edgei]; { - // Clear the maps - curFaceMap.clear(); - addedFaces.clear(); - // Grab the faces for start and end points const label startFace = slavePointFaceHits[curEdge.start()].hitObject(); - const label endFace = slavePointFaceHits[curEdge.end()].hitObject(); - // Insert the start face into the list - curFaceMap.insert(startFace); - addedFaces.insert(startFace); + const label endFace = + slavePointFaceHits[curEdge.end()].hitObject(); - // Pout<< "Doing edge " << edgeI + // Pout<< "Doing edge " << edgei // << " or " << curEdge // << " start: " // << slavePointFaceHits[curEdge.start()].hitObject() @@ -774,46 +754,59 @@ bool Foam::slidingInterface::projectPoints() const // << endl; // If the end face is on the list, the face collection is finished - label nSweeps = 0; bool completed = false; - while (nSweeps < edgeFaceEscapeLimit_) + if (!completed) { - nSweeps++; + // Forward sweep - if (addedFaces.found(endFace)) - { - completed = true; - } - - // Add all face neighbours of face in the map - const labelList cf = addedFaces.toc(); + // Clear the maps + curFaceMap.clear(); addedFaces.clear(); - forAll(cf, cfI) + // Insert the start face into the list + curFaceMap.insert(startFace); + addedFaces.insert(startFace); + + for + ( + label nSweeps = 0; + nSweeps < edgeFaceEscapeLimit_; + ++nSweeps + ) { - const labelList& curNbrs = masterFaceFaces[cf[cfI]]; + completed = addedFaces.found(endFace); + + // Add all face neighbours of face in the map + const labelList cf(std::move(addedFaces.toc())); + addedFaces.clear(); - forAll(curNbrs, nbrI) + for (const label cfi : cf) { - if (!curFaceMap.found(curNbrs[nbrI])) + const labelList& curNbrs = masterFaceFaces[cfi]; + + for (const label nbri : curNbrs) { - curFaceMap.insert(curNbrs[nbrI]); - addedFaces.insert(curNbrs[nbrI]); + if (curFaceMap.insert(nbri)) + { + addedFaces.insert(nbri); + } } } - } - if (completed) break; + if (completed) break; - if (debug) - { - Pout<< "."; + if (debug) + { + Pout<< "."; + } } } if (!completed) { + // Reverse sweep + if (debug) { Pout<< "x"; @@ -822,35 +815,32 @@ bool Foam::slidingInterface::projectPoints() const // It is impossible to reach the end from the start, probably // due to disconnected domain. Do search in opposite direction - label nReverseSweeps = 0; - addedFaces.clear(); curFaceMap.insert(endFace); addedFaces.insert(endFace); - while (nReverseSweeps < edgeFaceEscapeLimit_) + for + ( + label nSweeps = 0; + nSweeps < edgeFaceEscapeLimit_; + ++nSweeps + ) { - nReverseSweeps++; - - if (addedFaces.found(startFace)) - { - completed = true; - } + completed = addedFaces.found(startFace); // Add all face neighbours of face in the map - const labelList cf = addedFaces.toc(); + const labelList cf(std::move(addedFaces.toc())); addedFaces.clear(); - forAll(cf, cfI) + for (const label cfi : cf) { - const labelList& curNbrs = masterFaceFaces[cf[cfI]]; + const labelList& curNbrs = masterFaceFaces[cfi]; - forAll(curNbrs, nbrI) + for (const label nbri : curNbrs) { - if (!curFaceMap.found(curNbrs[nbrI])) + if (curFaceMap.insert(nbri)) { - curFaceMap.insert(curNbrs[nbrI]); - addedFaces.insert(curNbrs[nbrI]); + addedFaces.insert(nbri); } } } @@ -887,16 +877,11 @@ bool Foam::slidingInterface::projectPoints() const nFacesPerSlaveEdge_*primitiveMesh::pointsPerFace_ ); - const labelList curFaces = curFaceMap.toc(); -// Pout<< "curFaces: " << curFaces << endl; - forAll(curFaces, facei) + for (const label facei : curFaceMap) { - const face& f = masterLocalFaces[curFaces[facei]]; + const face& f = masterLocalFaces[facei]; - forAll(f, pointi) - { - curPointMap.insert(f[pointi]); - } + curPointMap.insert(f); // Insert all face points } const labelList curMasterPoints = curPointMap.toc(); @@ -912,7 +897,7 @@ bool Foam::slidingInterface::projectPoints() const // is used to reject master points out of reach. // Calculated as a combination of travel distance in projection and // edge length - scalar slaveCatchDist = + const scalar slaveCatchDist = edgeMasterCatchFraction_*edgeMag + 0.5* ( @@ -945,10 +930,8 @@ bool Foam::slidingInterface::projectPoints() const edgeNormalInPlane /= mag(edgeNormalInPlane); - forAll(curMasterPoints, pointi) + for (const label cmp : curMasterPoints) { - const label cmp = curMasterPoints[pointi]; - // Skip the current point if the edge start or end has // been adjusted onto in if @@ -974,11 +957,11 @@ bool Foam::slidingInterface::projectPoints() const // Strict checking of slave cut to avoid capturing // end points. - scalar cutOnSlave = + const scalar cutOnSlave = ((edgeLineHit.hitPoint() - edgeLine.start()) & edgeVec) /sqr(edgeMag); - scalar distInEdgePlane = + const scalar distInEdgePlane = min ( edgeLineHit.distance(), @@ -1032,14 +1015,14 @@ bool Foam::slidingInterface::projectPoints() const } // Snap to point onto edge - masterPointEdgeHits[cmp] = edgeI; + masterPointEdgeHits[cmp] = edgei; masterPointEdgeDist[cmp] = edgeLineHit.distance(); // Pout<< "Inserting master point " // << masterPatch.meshPoints()[cmp] // << " (" << cmp // << ") at " << masterLocalPoints[cmp] -// << " into slave edge " << edgeI +// << " into slave edge " << edgei // << " " << curEdge // << " cutOnSlave: " << cutOnSlave // << " distInEdgePlane: " << distInEdgePlane @@ -1096,16 +1079,20 @@ bool Foam::slidingInterface::projectPoints() const // Store the addressing arrays and projected points deleteDemandDrivenData(slavePointPointHitsPtr_); - slavePointPointHitsPtr_ = new labelList(slavePointPointHits); + slavePointPointHitsPtr_ = new labelList(); + slavePointPointHitsPtr_->transfer(slavePointPointHits); deleteDemandDrivenData(slavePointEdgeHitsPtr_); - slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits); + slavePointEdgeHitsPtr_ = new labelList(); + slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits); deleteDemandDrivenData(slavePointFaceHitsPtr_); - slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits); + slavePointFaceHitsPtr_ = new List<objectHit>(); + slavePointFaceHitsPtr_->transfer(slavePointFaceHits); deleteDemandDrivenData(masterPointEdgeHitsPtr_); - masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits); + masterPointEdgeHitsPtr_ = new labelList(); + masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits); if (debug) { @@ -1128,16 +1115,20 @@ bool Foam::slidingInterface::projectPoints() const { // Must be restart. Force topological change. deleteDemandDrivenData(slavePointPointHitsPtr_); - slavePointPointHitsPtr_ = new labelList(slavePointPointHits); + slavePointPointHitsPtr_ = new labelList(); + slavePointPointHitsPtr_->transfer(slavePointPointHits); deleteDemandDrivenData(slavePointEdgeHitsPtr_); - slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits); + slavePointEdgeHitsPtr_ = new labelList(); + slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits); deleteDemandDrivenData(slavePointFaceHitsPtr_); - slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits); + slavePointFaceHitsPtr_ = new List<objectHit>(); + slavePointFaceHitsPtr_->transfer(slavePointFaceHits); deleteDemandDrivenData(masterPointEdgeHitsPtr_); - masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits); + masterPointEdgeHitsPtr_ = new labelList(); + masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits); if (debug) { @@ -1218,16 +1209,20 @@ bool Foam::slidingInterface::projectPoints() const { // Grab new data deleteDemandDrivenData(slavePointPointHitsPtr_); - slavePointPointHitsPtr_ = new labelList(slavePointPointHits); + slavePointPointHitsPtr_ = new labelList(); + slavePointPointHitsPtr_->transfer(slavePointPointHits); deleteDemandDrivenData(slavePointEdgeHitsPtr_); - slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits); + slavePointEdgeHitsPtr_ = new labelList(); + slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits); deleteDemandDrivenData(slavePointFaceHitsPtr_); - slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits); + slavePointFaceHitsPtr_ = new List<objectHit>(); + slavePointFaceHitsPtr_->transfer(slavePointFaceHits); deleteDemandDrivenData(masterPointEdgeHitsPtr_); - masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits); + masterPointEdgeHitsPtr_ = new labelList(); + masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits); if (debug) { diff --git a/tutorials/mesh/stitchMesh/simple-cube1/Allclean b/tutorials/mesh/stitchMesh/simple-cube1/Allclean new file mode 100755 index 00000000000..d6d329b5ff7 --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/Allclean @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 +rmdir constant 2> /dev/null + +# ----------------------------------------------------------------------------- diff --git a/tutorials/mesh/stitchMesh/simple-cube1/Allmesh b/tutorials/mesh/stitchMesh/simple-cube1/Allmesh new file mode 100755 index 00000000000..a3e4e0da153 --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/Allmesh @@ -0,0 +1,19 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +runApplication blockMesh +runApplication topoSet + +runApplication subsetMesh final -patch outer -resultTime 0 + +# Avoid any inconsistencies +rm -f constant/polyMesh/{cellZones,faceZones,pointZones} + +runApplication -s patches topoSet -dict system/topoSetDict.patches + +runApplication createPatch -overwrite + +# rm -f 0/polyMesh/{cellZones,faceZones,pointZones} + +# ----------------------------------------------------------------------------- diff --git a/tutorials/mesh/stitchMesh/simple-cube1/Allrun b/tutorials/mesh/stitchMesh/simple-cube1/Allrun new file mode 100755 index 00000000000..1f37298922d --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/Allrun @@ -0,0 +1,12 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +runApplication ./Allmesh + +for dir in x y z +do + runApplication -s dir-$dir stitchMesh -partial outer$dir inner$dir +done + +# ----------------------------------------------------------------------------- diff --git a/tutorials/mesh/stitchMesh/simple-cube1/scripts/stitch b/tutorials/mesh/stitchMesh/simple-cube1/scripts/stitch new file mode 100755 index 00000000000..fd63d6d6827 --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/scripts/stitch @@ -0,0 +1,50 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +[ "$#" -gt 0 ] || { + echo "provide x, y, z or -all directions" + exit 1 +} + +unset optAll +for dir +do + case "$dir" in + -x | x) rm -rf 1 2 3 ;; + -y | y) rm -rf 2 3 ;; + -z | z) rm -rf 3 ;; + -all | all) + optAll=true + rm -rf 1 2 3 + ;; + *) + echo "provide x, y, z or -all directions" + exit 1 + ;; + esac +done + +if [ "$optAll" = true ] +then + set -- x y z +fi + +stitch() +{ + local dir=$1 + stitchMesh -partial outer$dir inner$dir | tee log.stitch-$dir +} + + +for dir +do + case "$dir" in + -x | x) [ -d 1 ] || stitch x;; + -y | y) [ -d 2 ] || stitch y;; + -z | z) [ -d 3 ] || stitch z;; + esac +done + + +# ----------------------------------------------------------------------------- diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/blockMeshDict b/tutorials/mesh/stitchMesh/simple-cube1/system/blockMeshDict new file mode 100644 index 00000000000..5c029923695 --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/blockMeshDict @@ -0,0 +1,132 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +// Dimensions for outer box +lo 0; // outer lower corner +uo 1; // outer upper corner + +// Dimensions for inner box +li -0.1; // inner lower corner + +ui 0.497; // inner upper corner +// ^^^^^ very poorly handled gaps + +ui 0.498; // inner upper corner +// ^^^^^ slave patch probably does not project onto master + +ui 0.499; // inner upper corner +// ^^^^^ OK + + +vertices +( + ( $lo $lo $lo ) + ( $uo $lo $lo ) + ( $uo $uo $lo ) + ( $lo $uo $lo ) + ( $lo $lo $uo ) + ( $uo $lo $uo ) + ( $uo $uo $uo ) + ( $lo $uo $uo ) + + ( $li $li $li ) + ( $ui $li $li ) + ( $ui $ui $li ) + ( $li $ui $li ) + ( $li $li $ui ) + ( $ui $li $ui ) + ( $ui $ui $ui ) + ( $li $ui $ui ) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (6 6 6) simpleGrading (1 1 1) + hex (8 9 10 11 12 13 14 15) (10 10 10) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + wallso + { + type patch; + faces + ( + // Walls of the outside block + (0 4 7 3) + (1 2 6 5) + (0 1 5 4) + (3 7 6 2) + (0 3 2 1) + (4 5 6 7) + ); + } + wallsi + { + type patch; + faces + ( + // Walls of the inside block + (8 12 15 11) + (8 9 13 12) + (8 11 10 9) + ); + } + + // Outer faces populated by subsetMesh + outer + { + type patch; + faces (); + } + + innerx + { + type patch; + inGroups (inner); + faces + ( + (9 10 14 13) + ); + } + innery + { + type patch; + inGroups (inner); + faces + ( + (11 15 14 10) + ); + } + innerz + { + type patch; + inGroups (inner); + faces + ( + (12 13 14 15) + ); + } + +); + +// ************************************************************************* // diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/controlDict b/tutorials/mesh/stitchMesh/simple-cube1/system/controlDict new file mode 100644 index 00000000000..b0f6027eadd --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/controlDict @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application simpleFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 10; + +deltaT 1; + +writeControl runTime; + +writeInterval 1; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/createPatchDict b/tutorials/mesh/stitchMesh/simple-cube1/system/createPatchDict new file mode 100644 index 00000000000..deae7b1a60c --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/createPatchDict @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object createPatchDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +pointSync false; + +outerSet +{ + patchInfo + { + type patch; + inGroups (outer); + } + + constructFrom set; +} + + +// Patches to create. +patches +( + { + name outerx; + set outerx; + $outerSet; + } + + { + name outery; + set outery; + $outerSet; + } + + { + name outerz; + set outerz; + $outerSet; + } +); + +// ************************************************************************* // diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/fvSchemes b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSchemes new file mode 100644 index 00000000000..9c127712e79 --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSchemes @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss cubic; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p ; +} + + +// ************************************************************************* // diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/fvSolution b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSolution new file mode 100644 index 00000000000..fce1b29ce9e --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSolution @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0; + } + + U + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-05; + relTol 0; + } +} + +PISO +{ + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict new file mode 100644 index 00000000000..9602c4e1475 --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict @@ -0,0 +1,106 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +actions +( + // Outer cube + { + name outer; + type cellSet; + action new; + source regionToCell; + sourceInfo + { + insidePoints + ( + (0.99 0.99 0.99) + ); + } + } + + { + name corner; + type cellSet; + action new; + source boxToCell; + sourceInfo + { + box (-1 -1 -1)(0.5 0.5 0.5); + } + } + + { + name inner; + type cellSet; + action new; + source cellToCell; + sourceInfo + { + set corner; + } + } + + { + name inner; + type cellSet; + action delete; + source cellToCell; + sourceInfo + { + set outer; + } + } + + { + name outer; + type cellSet; + action delete; + source cellToCell; + sourceInfo + { + set corner; + } + } + + { + name corner; + type cellSet; + action clear; + } + + { + name final; + type cellSet; + action new; + source cellToCell; + sourceInfo + { + set outer; + } + } + { + name final; + type cellSet; + action add; + source cellToCell; + sourceInfo + { + set inner; + } + } +); + +// ************************************************************************* // diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches new file mode 100644 index 00000000000..36a415b66be --- /dev/null +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches @@ -0,0 +1,88 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +newFromPatch +{ + type faceSet; + action new; + source patchToFace; + sourceInfo + { + name outer; + } +} + +subsetNormal +{ + type faceSet; + action subset; + source normalToFace; + sourceInfo + { + cos 0.1; + } +} + +actions +( + // outerx + { + name outerx; + $newFromPatch + } + + { + name outerx; + $subsetNormal; + sourceInfo + { + normal (-1 0 0); + } + } + + // outery + { + name outery; + $newFromPatch + } + + { + name outery; + $subsetNormal; + sourceInfo + { + normal (0 -1 0); + } + } + + // outerz + { + name outerz; + $newFromPatch + } + + { + name outerz; + $subsetNormal; + sourceInfo + { + normal (0 0 -1); + } + } + +); + +// ************************************************************************* // -- GitLab From f76552f7f93f3299d19ac70d495ebc0f8fb6c887 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 6 Oct 2017 20:10:49 +0200 Subject: [PATCH 024/126] STYLE: rebase edge on labelPair, additional methods in Pair - use FixedList first/last in Pair first/second - consistent first/second access for line --- .../automatic/automatic.C | 2 +- .../foamyHexMeshBackgroundMesh.C | 2 +- .../surface/surfaceCheck/surfaceCheck.C | 2 +- .../surfaceFeatureExtract.C | 2 +- src/OpenFOAM/meshes/meshShapes/edge/edge.H | 83 ++++--- src/OpenFOAM/meshes/meshShapes/edge/edgeI.H | 223 +++++++----------- src/OpenFOAM/meshes/meshShapes/face/face.C | 12 +- src/OpenFOAM/meshes/meshShapes/face/face.H | 33 ++- src/OpenFOAM/meshes/meshShapes/face/faceI.H | 18 +- .../meshes/meshShapes/triFace/triFace.H | 6 +- .../meshes/meshShapes/triFace/triFaceI.H | 32 +-- .../meshes/primitiveShapes/line/line.H | 78 +++--- .../meshes/primitiveShapes/line/lineI.H | 24 +- src/OpenFOAM/primitives/Pair/Pair.H | 164 ++++++------- src/OpenFOAM/primitives/Pair/PairI.H | 165 +++++++++++++ src/OpenFOAM/primitives/Tuple2/Tuple2.H | 2 +- src/surfMesh/triSurface/triSurface.C | 2 +- 17 files changed, 490 insertions(+), 360 deletions(-) create mode 100644 src/OpenFOAM/primitives/Pair/PairI.H diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C index d9bf097d1d6..302bd61b553 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C @@ -282,7 +282,7 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load() forAll(surface_, fI) { - faces[fI] = surface_.triSurface::operator[](fI).triFaceFace(); + faces[fI] = surface_.triSurface::operator[](fI); } vtkSurfaceWriter().write diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index 410182e01c2..ac840a07f74 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -721,7 +721,7 @@ int main(int argc, char *argv[]) isoFaces.setSize(iso.size()); forAll(isoFaces, i) { - isoFaces[i] = iso[i].triFaceFace(); + isoFaces[i] = iso[i]; } isoPoints = iso.points(); } diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index 09765e2d938..43812170e1f 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -150,7 +150,7 @@ void writeZoning faceList faces(surf.size()); forAll(surf, i) { - faces[i] = surf[i].triFaceFace(); + faces[i] = surf[i]; } vtkSurfaceWriter().write diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index ca7cba62cc6..eb7103faf1e 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -368,7 +368,7 @@ int main(int argc, char *argv[]) faces.setSize(surf.size()); forAll(surf, fi) { - faces[fi] = surf[fi].triFaceFace(); + faces[fi] = surf[fi]; } } diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H index aecb9a9c2e4..dabdc197efa 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H @@ -28,7 +28,7 @@ Description An edge is a list of two point labels. The functionality it provides supports the discretisation on a 2-D flat mesh. - The edge is implemented as a FixedList of labels. + The edge is implemented as a Pair/FixedList of labels. As well as geometrically relevant methods, it also provides methods similar to HashSet for additional convenience. Valid point labels are always non-negative (since they correspond to @@ -37,6 +37,7 @@ Description can be filled with a HashSet-like functionality. SourceFiles + edge.C edgeI.H \*---------------------------------------------------------------------------*/ @@ -44,10 +45,9 @@ SourceFiles #ifndef edge_H #define edge_H -#include "FixedList.H" #include "labelPair.H" -#include "pointField.H" #include "linePointRef.H" +#include "pointField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,7 +60,7 @@ namespace Foam class edge : - public FixedList<label, 2> + public labelPair { // Private Member Functions @@ -93,19 +93,19 @@ public: //- Construct null with invalid point labels (-1) inline edge(); - //- Construct from components + //- Construct from two point labels inline edge(const label from, const label to); - //- Construct, optionally sorted with start less-than end - inline edge(const label from, const label to, const bool doSort); - - //- Construct from two labels + //- Construct from pair of labels inline edge(const labelPair& pair); - //- Construct from FixedList + //- Construct from list inline edge(const FixedList<label, 2>& lst); - //- Construct, optionally sorted with start less-than end + //- Construct from two point labels, sorted with first less-than second + inline edge(const label from, const label to, const bool doSort); + + //- Construct from list, sorted with first less-than second inline edge(const FixedList<label, 2>& lst, const bool doSort); //- Construct from Istream @@ -116,16 +116,26 @@ public: // Access - //- Return start vertex label + //- Return first vertex label + using labelPair::first; + + //- Return last (second) vertex label + using labelPair::last; + + //- Return second (last) vertex label + using labelPair::second; + + + //- Return start (first) vertex label inline label start() const; - //- Return start vertex label + //- Return start (first) vertex label inline label& start(); - //- Return end vertex label + //- Return end (last/second) vertex label inline label end() const; - //- Return end vertex label + //- Return end (last/second) vertex label inline label& end(); //- Return reverse edge as copy. @@ -143,10 +153,6 @@ public: // No special handling of negative point labels. inline label maxVertex() const; - //- True if start() is less-than end() - // No special handling of negative point labels. - inline bool sorted() const; - //- Return true if point label is found in edge. // Always false for a negative label. inline bool found(const label pointLabel) const; @@ -175,14 +181,6 @@ public: // Return the effective size after collapsing. inline label collapse(); - //- Flip the edge in-place. - // No special handling of negative point labels. - inline void flip(); - - //- Sort so that start() is less-than end() - // No special handling of negative point labels. - inline void sort(); - // Hash-like functions @@ -211,8 +209,8 @@ public: // Returns true on success. Negative labels never insert. // Return the number of slots filled. // Similar to a HashTable::insert(). - template<unsigned AnySize> - inline label insert(const FixedList<label, AnySize>& lst); + template<unsigned Size> + inline label insert(const FixedList<label, Size>& lst); //- Fill open slots with the indices if they did not previously exist. // Returns true on success. Negative labels never insert. @@ -231,8 +229,8 @@ public: //- Remove existing indices from the edge and set locations to '-1'. // Returns the number of changes. - template<unsigned AnySize> - inline label erase(const FixedList<label, AnySize>& lst); + template<unsigned Size> + inline label erase(const FixedList<label, Size>& lst); //- Remove existing indices from the edge and set locations to '-1'. // Returns the number of changes. @@ -265,7 +263,7 @@ public: // Comparison //- Compare edges - // Returns: + // \return // - 0: different // - +1: identical values and order used // - -1: identical values, but in different order @@ -274,7 +272,14 @@ public: }; -// Global Operators +// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * // + +//- Return reverse of an edge +inline edge reverse(const edge& e) +{ + return edge(e.second(), e.first()); +} + //- Compare edges for equal content, ignoring orientation inline bool operator==(const edge& a, const edge& b); @@ -290,15 +295,15 @@ inline unsigned Hash<edge>::operator()(const edge& e, unsigned seed) const { unsigned val = seed; - if (e[0] < e[1]) + if (e.first() < e.second()) { - val = Hash<label>()(e[0], val); - val = Hash<label>()(e[1], val); + val = Hash<label>()(e.first(), val); + val = Hash<label>()(e.second(), val); } else { - val = Hash<label>()(e[1], val); - val = Hash<label>()(e[0], val); + val = Hash<label>()(e.second(), val); + val = Hash<label>()(e.first(), val); } return val; @@ -313,7 +318,7 @@ inline unsigned Hash<edge>::operator()(const edge& e) const return Hash<edge>()(e, 0); } - +// Edges are a pair of labels - thus contiguous template<> inline bool contiguous<edge>() {return true;} diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H index e4ca81e9386..db939da2aac 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H @@ -24,24 +24,12 @@ License \*---------------------------------------------------------------------------*/ #include "IOstreams.H" -#include "Swap.H" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // inline int Foam::edge::compare(const edge& a, const edge& b) { - if (a[0] == b[0] && a[1] == b[1]) - { - return 1; - } - else if (a[0] == b[1] && a[1] == b[0]) - { - return -1; - } - else - { - return 0; - } + return labelPair::compare(a, b); } @@ -56,7 +44,7 @@ inline Foam::label Foam::edge::insertMultiple { // Available slots. // Don't use count() since it has special treatment for duplicates - const int maxChange = (start() < 0 ? 1 : 0) + (end() < 0 ? 1 : 0); + const int maxChange = (first() < 0 ? 1 : 0) + (second() < 0 ? 1 : 0); int changed = 0; if (maxChange) @@ -86,7 +74,7 @@ inline Foam::label Foam::edge::eraseMultiple { // Occupied slots. // Don't use count() since it has special treatment for duplicates - const int maxChange = (start() >= 0 ? 1 : 0) + (end() >= 0 ? 1 : 0); + const int maxChange = (first() >= 0 ? 1 : 0) + (second() >= 0 ? 1 : 0); int changed = 0; if (maxChange) @@ -109,64 +97,43 @@ inline Foam::label Foam::edge::eraseMultiple inline Foam::edge::edge() : - FixedList<label, 2>(-1) + labelPair(-1, -1) {} inline Foam::edge::edge(const label from, const label to) -{ - start() = from; - end() = to; -} - - -inline Foam::edge::edge(const label from, const label to, const bool doSort) -{ - if (doSort && from > to) - { - start() = to; - end() = from; - } - else - { - start() = from; - end() = to; - } -} +: + labelPair(from, to) +{} inline Foam::edge::edge(const labelPair& pair) -{ - start() = pair.first(); - end() = pair.second(); -} +: + labelPair(pair.first(), pair.second()) +{} inline Foam::edge::edge(const FixedList<label, 2>& lst) -{ - start() = lst[0]; - end() = lst[1]; -} +: + labelPair(lst.first(), lst.last()) +{} + + +inline Foam::edge::edge(const label from, const label to, const bool doSort) +: + labelPair(from, to, doSort) +{} inline Foam::edge::edge(const FixedList<label, 2>& lst, const bool doSort) -{ - if (doSort && lst[0] > lst[1]) - { - start() = lst[1]; - end() = lst[0]; - } - else - { - start() = lst[0]; - end() = lst[1]; - } -} +: + labelPair(lst, doSort) +{} inline Foam::edge::edge(Istream& is) : - FixedList<label, 2>(is) + labelPair(is) {} @@ -174,42 +141,47 @@ inline Foam::edge::edge(Istream& is) inline Foam::label Foam::edge::start() const { - return operator[](0); + return first(); } inline Foam::label& Foam::edge::start() { - return operator[](0); + return first(); } inline Foam::label Foam::edge::end() const { - return operator[](1); + return second(); } + inline Foam::label& Foam::edge::end() { - return operator[](1); + return second(); } inline Foam::label Foam::edge::minVertex() const { - return (start() < end() ? start() : end()); + return (first() < second() ? first() : second()); } inline Foam::label Foam::edge::maxVertex() const { - return (start() > end() ? start() : end()); + return (first() > second() ? first() : second()); } inline bool Foam::edge::found(const label pointLabel) const { // -1: always false - return (pointLabel >= 0 && (pointLabel == start() || pointLabel == end())); + return + ( + pointLabel >= 0 + && (pointLabel == first() || pointLabel == second()) + ); } @@ -218,11 +190,11 @@ inline Foam::label Foam::edge::which(const label pointLabel) const // -1: always false if (pointLabel >= 0) { - if (pointLabel == start()) + if (pointLabel == first()) { return 0; } - if (pointLabel == end()) + if (pointLabel == second()) { return 1; } @@ -233,43 +205,39 @@ inline Foam::label Foam::edge::which(const label pointLabel) const inline bool Foam::edge::connects(const edge& other) const { - return (other.found(start()) || other.found(end())); + return (other.found(first()) || other.found(second())); } inline Foam::label Foam::edge::commonVertex(const edge& other) const { - if (other.found(start())) - { - return start(); - } - else if (other.found(end())) + if (other.found(first())) { - return end(); + return first(); } - else + if (other.found(second())) { - // No shared vertex. - return -1; + return second(); } + + // No shared vertex. + return -1; } inline Foam::label Foam::edge::otherVertex(const label index) const { - if (index == start()) - { - return end(); - } - else if (index == end()) + if (index == first()) { - return start(); + return second(); } - else + if (index == second()) { - // The given vertex is not on the edge in the first place. - return -1; + return first(); } + + // The given vertex is not on the edge in the first place. + return -1; } @@ -280,12 +248,12 @@ inline Foam::label Foam::edge::collapse() // catch any '-1' (eg, if called multiple times) label n = 2; - if (start() == end() || end() < 0) + if (first() == second() || second() < 0) { - end() = -1; + second() = -1; --n; } - if (start() < 0) + if (first() < 0) { --n; } @@ -294,48 +262,27 @@ inline Foam::label Foam::edge::collapse() } -inline bool Foam::edge::sorted() const -{ - return (start() < end()); -} - - -inline void Foam::edge::sort() -{ - if (start() > end()) - { - flip(); - } -} - - -inline void Foam::edge::flip() -{ - Swap(operator[](0), operator[](1)); -} - - inline Foam::edge Foam::edge::reverseEdge() const { - return edge(end(), start()); + return edge(second(), first()); } inline void Foam::edge::clear() { - start() = -1; - end() = -1; + first() = -1; + second() = -1; } inline Foam::label Foam::edge::count() const { label n = 2; - if (start() == end() || end() < 0) + if (first() == second() || second() < 0) { --n; } - if (start() < 0) + if (first() < 0) { --n; } @@ -346,7 +293,7 @@ inline Foam::label Foam::edge::count() const inline bool Foam::edge::empty() const { - return (start() < 0 && end() < 0); + return (first() < 0 && second() < 0); } @@ -358,21 +305,21 @@ inline bool Foam::edge::insert(const label index) return false; } - if (start() < 0) + if (first() < 0) { - // Store at [0], if not duplicate of [1] - if (index != end()) + // Store at first, if not duplicate of second + if (index != second()) { - start() = index; + first() = index; return true; } } - else if (end() < 0) + else if (second() < 0) { - // Store at [1], if not duplicate of [0] - if (index != start()) + // Store at second, if not duplicate of first + if (index != first()) { - end() = index; + second() = index; return true; } } @@ -387,8 +334,8 @@ inline Foam::label Foam::edge::insert(const UList<label>& lst) } -template<unsigned AnySize> -inline Foam::label Foam::edge::insert(const FixedList<label, AnySize>& lst) +template<unsigned Size> +inline Foam::label Foam::edge::insert(const FixedList<label, Size>& lst) { return insertMultiple(lst.begin(), lst.end()); } @@ -409,16 +356,16 @@ inline Foam::label Foam::edge::erase(const label index) } label n = 0; - if (index == start()) + if (index == first()) { - start() = -1; + first() = -1; ++n; } // Automatically handle duplicates, which should not have been there anyhow - if (index == end()) + if (index == second()) { - end() = -1; + second() = -1; ++n; } @@ -432,8 +379,8 @@ inline Foam::label Foam::edge::erase(const UList<label>& lst) } -template<unsigned AnySize> -inline Foam::label Foam::edge::erase(const FixedList<label, AnySize>& lst) +template<unsigned Size> +inline Foam::label Foam::edge::erase(const FixedList<label, Size>& lst) { return eraseMultiple(lst.begin(), lst.end()); } @@ -450,7 +397,7 @@ inline Foam::label Foam::edge::erase(std::initializer_list<label> lst) inline Foam::point Foam::edge::centre(const UList<point>& pts) const { #ifdef FULLDEBUG - if (start() < 0 || end() < 0) + if (first() < 0 || second() < 0) { FatalErrorInFunction << "negative point index on edge " << *this @@ -458,14 +405,14 @@ inline Foam::point Foam::edge::centre(const UList<point>& pts) const } #endif - return 0.5*(pts[start()] + pts[end()]); + return 0.5*(pts[first()] + pts[second()]); } inline Foam::vector Foam::edge::vec(const UList<point>& pts) const { #ifdef FULLDEBUG - if (start() < 0 || end() < 0) + if (first() < 0 || second() < 0) { FatalErrorInFunction << "negative point index on edge " << *this @@ -473,14 +420,14 @@ inline Foam::vector Foam::edge::vec(const UList<point>& pts) const } #endif - return pts[end()] - pts[start()]; + return pts[second()] - pts[first()]; } inline Foam::vector Foam::edge::unitVec(const UList<point>& pts) const { #ifdef FULLDEBUG - if (start() < 0 || end() < 0) + if (first() < 0 || second() < 0) { FatalErrorInFunction << "negative point index on edge " << *this @@ -488,7 +435,7 @@ inline Foam::vector Foam::edge::unitVec(const UList<point>& pts) const } #endif - Foam::vector v = pts[end()] - pts[start()]; + Foam::vector v = pts[second()] - pts[first()]; v /= ::Foam::mag(v) + VSMALL; return v; @@ -504,7 +451,7 @@ inline Foam::scalar Foam::edge::mag(const UList<point>& pts) const inline Foam::linePointRef Foam::edge::line(const UList<point>& pts) const { #ifdef FULLDEBUG - if (start() < 0 || end() < 0) + if (first() < 0 || second() < 0) { FatalErrorInFunction << "negative point index on edge " << *this @@ -512,7 +459,7 @@ inline Foam::linePointRef Foam::edge::line(const UList<point>& pts) const } #endif - return linePointRef(pts[start()], pts[end()]); + return linePointRef(pts[first()], pts[second()]); } diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index 9900b4e6f3a..6f44cb0314a 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -773,14 +773,14 @@ int Foam::face::edgeDirection(const edge& e) const { forAll(*this, i) { - if (operator[](i) == e.start()) + if (operator[](i) == e.first()) { - if (operator[](rcIndex(i)) == e.end()) + if (operator[](rcIndex(i)) == e.second()) { // Reverse direction return -1; } - else if (operator[](fcIndex(i)) == e.end()) + else if (operator[](fcIndex(i)) == e.second()) { // Forward direction return 1; @@ -789,14 +789,14 @@ int Foam::face::edgeDirection(const edge& e) const // No match return 0; } - else if (operator[](i) == e.end()) + else if (operator[](i) == e.second()) { - if (operator[](rcIndex(i)) == e.start()) + if (operator[](rcIndex(i)) == e.first()) { // Forward direction return 1; } - else if (operator[](fcIndex(i)) == e.start()) + else if (operator[](fcIndex(i)) == e.first()) { // Reverse direction return -1; diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 2c640ce5236..0866a7eead9 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -50,6 +50,7 @@ SourceFiles #include "faceListFwd.H" #include "intersection.H" #include "pointHit.H" +#include "FixedList.H" #include "ListListOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -106,15 +107,15 @@ class face //- Enumeration listing the modes for split() enum splitMode { - COUNTTRIANGLE, // count if split into triangles - COUNTQUAD, // count if split into triangles&quads - SPLITTRIANGLE, // split into triangles - SPLITQUAD // split into triangles&quads + COUNTTRIANGLE, //!< count if split into triangles + COUNTQUAD, //!< count if split into triangles and quads + SPLITTRIANGLE, //!< split into triangles + SPLITQUAD //!< split into triangles and quads }; - //- Split face into triangles or triangles&quads. + //- Split face into triangles or triangles and quads. // Stores results quadFaces[quadI], triFaces[triI] - // Returns number of new faces created + // \return number of new faces created label split ( const splitMode mode, @@ -152,12 +153,19 @@ public: //- Construct from list of labels explicit inline face(const labelUList& lst); + //- Construct from list of labels + template<unsigned Size> + explicit inline face(const FixedList<label, Size>& lst); + //- Construct from an initializer list of labels explicit inline face(std::initializer_list<label> lst); - //- Construct by transferring the parameter contents + //- Transfer (move) construct explicit inline face(const Xfer<labelList>& lst); + //- Move construct + explicit inline face(labelList&& lst); + //- Copy construct from triFace face(const triFace& f); @@ -311,8 +319,8 @@ public: //- Return n-th face edge inline edge faceEdge(const label n) const; - //- Return the edge direction on the face - // Returns: + //- The edge direction on the face + // \return // - 0: edge not found on the face // - +1: forward (counter-clockwise) on the face // - -1: reverse (clockwise) on the face @@ -373,9 +381,10 @@ public: ) const; //- Compare faces - // 0: different - // +1: identical - // -1: same face, but different orientation + // \return + // - 0: different + // - +1: identical + // - -1: same face, but different orientation static int compare(const face& a, const face& b); //- Return true if the faces have the same vertices diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H index 17b58b83bd2..0ec413433d5 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H @@ -57,6 +57,13 @@ inline Foam::face::face(const labelUList& lst) {} +template<unsigned Size> +inline Foam::face::face(const FixedList<label, Size>& lst) +: + labelList(lst) +{} + + inline Foam::face::face(std::initializer_list<label> lst) : labelList(lst) @@ -69,6 +76,12 @@ inline Foam::face::face(const Xfer<labelList>& lst) {} +inline Foam::face::face(labelList&& lst) +: + labelList(std::move(lst)) +{} + + inline Foam::face::face(Istream& is) { is >> *this; @@ -87,9 +100,10 @@ inline Foam::pointField Foam::face::points // For each point in list, set it to the point in 'pnts' addressed // by 'labs' - forAll(p, i) + label i = 0; + for (const label pointi : *this) { - p[i] = meshPoints[operator[](i)]; + p[i++] = meshPoints[pointi]; } // Return list diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index 301b845d112..ea18b760194 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -86,7 +86,7 @@ public: const label c ); - //- Construct from a list of 3 labels. + //- Copy construct from a list of 3 labels. explicit inline triFace(const labelUList& lst); //- Construct from an initializer list of 3 labels @@ -223,14 +223,14 @@ public: inline edge faceEdge(const label n) const; //- Return the edge direction on the face - // Returns: + // \return // - +1: forward (counter-clockwise) on the face // - -1: reverse (clockwise) on the face // - 0: edge not found on the face inline int edgeDirection(const edge& e) const; //- Compare triFaces - // Returns: + // \return: // - 0: different // - +1: identical // - -1: same face, but different orientation diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H index ae2545a7aa2..bc99e45518c 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H @@ -147,13 +147,7 @@ inline Foam::pointField Foam::triFace::points(const UList<point>& points) const inline Foam::face Foam::triFace::triFaceFace() const { - Foam::face f(3); - - f[0] = operator[](0); - f[1] = operator[](1); - f[2] = operator[](2); - - return f; + return Foam::face(*this); } @@ -342,14 +336,14 @@ inline Foam::edgeList Foam::triFace::edges() const { edgeList e(3); - e[0].start() = operator[](0); - e[0].end() = operator[](1); + e[0].first() = operator[](0); + e[0].second() = operator[](1); - e[1].start() = operator[](1); - e[1].end() = operator[](2); + e[1].first() = operator[](1); + e[1].second() = operator[](2); - e[2].start() = operator[](2); - e[2].end() = operator[](0); + e[2].first() = operator[](2); + e[2].second() = operator[](0); return e; } @@ -369,18 +363,18 @@ inline int Foam::triFace::edgeDirection(const edge& e) const { if ( - (operator[](0) == e.start() && operator[](1) == e.end()) - || (operator[](1) == e.start() && operator[](2) == e.end()) - || (operator[](2) == e.start() && operator[](0) == e.end()) + (operator[](0) == e.first() && operator[](1) == e.second()) + || (operator[](1) == e.first() && operator[](2) == e.second()) + || (operator[](2) == e.first() && operator[](0) == e.second()) ) { return 1; } else if ( - (operator[](0) == e.end() && operator[](1) == e.start()) - || (operator[](1) == e.end() && operator[](2) == e.start()) - || (operator[](2) == e.end() && operator[](0) == e.start()) + (operator[](0) == e.second() && operator[](1) == e.first()) + || (operator[](1) == e.second() && operator[](2) == e.first()) + || (operator[](2) == e.second() && operator[](0) == e.first()) ) { return -1; diff --git a/src/OpenFOAM/meshes/primitiveShapes/line/line.H b/src/OpenFOAM/meshes/primitiveShapes/line/line.H index 778a843ba75..a3ccc2319f2 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/line/line.H +++ b/src/OpenFOAM/meshes/primitiveShapes/line/line.H @@ -57,10 +57,10 @@ class Ostream; template<class Point, class PointRef> class line; template<class Point, class PointRef> -inline Istream& operator>>(Istream&, line<Point, PointRef>&); +inline Istream& operator>>(Istream& is, line<Point, PointRef>& l); template<class Point, class PointRef> -inline Ostream& operator<<(Ostream&, const line<Point, PointRef>&); +inline Ostream& operator<<(Ostream& os, const line<Point, PointRef>& l); /*---------------------------------------------------------------------------*\ @@ -72,7 +72,11 @@ class line { // Private data - PointRef a_, b_; + //- First point + PointRef a_; + + //- Second point + PointRef b_; public: @@ -86,7 +90,7 @@ public: // The indices could be from edge etc. inline line ( - const UList<Point>&, + const UList<Point>& points, const FixedList<label, 2>& indices ); @@ -96,56 +100,62 @@ public: // Member functions - // Access + // Access + + //- Return first point + inline PointRef first() const; - //- Return first point - inline PointRef start() const; + //- Return second point + inline PointRef second() const; - //- Return second point - inline PointRef end() const; + //- Return first point + inline PointRef start() const; + //- Return second point + inline PointRef end() const; - // Properties - //- Return centre (centroid) - inline Point centre() const; + // Properties - //- Return scalar magnitude - inline scalar mag() const; + //- Return centre (centroid) + inline Point centre() const; - //- Return start-to-end vector - inline Point vec() const; + //- Return scalar magnitude + inline scalar mag() const; - //- Return the unit vector (start-to-end) - inline Point unitVec() const; + //- Return start-to-end vector + inline Point vec() const; - //- Return nearest distance to line from a given point - // If the nearest point is on the line, return a hit - PointHit<Point> nearestDist(const Point& p) const; + //- Return the unit vector (start-to-end) + inline Point unitVec() const; - //- Return nearest distance from line to line. Returns distance - // and sets both points (one on *this, one on the provided - // linePointRef. - scalar nearestDist - ( - const line<Point, const Point&>& edge, - Point& thisPoint, - Point& edgePoint - ) const; + //- Return nearest distance to line from a given point + // If the nearest point is on the line, return a hit + PointHit<Point> nearestDist(const Point& p) const; + + //- Return nearest distance from line to line. Returns distance + // and sets both points (one on *this, one on the provided + // linePointRef. + scalar nearestDist + ( + const line<Point, const Point&>& edge, + Point& thisPoint, + Point& edgePoint + ) const; // Ostream operator friend Istream& operator>> <Point, PointRef> ( - Istream&, - line& + Istream& is, + line& l ); friend Ostream& operator<< <Point, PointRef> ( - Ostream&, - const line& + Ostream& os, + const line& l ); }; diff --git a/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H b/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H index 034f8687803..b2ee4d40ea1 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H @@ -57,18 +57,32 @@ inline Foam::line<Point, PointRef>::line(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Point, class PointRef> -inline PointRef Foam::line<Point, PointRef>::start() const +inline PointRef Foam::line<Point, PointRef>::first() const { return a_; } + template<class Point, class PointRef> -inline PointRef Foam::line<Point, PointRef>::end() const +inline PointRef Foam::line<Point, PointRef>::second() const { return b_; } +template<class Point, class PointRef> +inline PointRef Foam::line<Point, PointRef>::start() const +{ + return first(); +} + +template<class Point, class PointRef> +inline PointRef Foam::line<Point, PointRef>::end() const +{ + return second(); +} + + template<class Point, class PointRef> inline Point Foam::line<Point, PointRef>::centre() const { @@ -110,21 +124,21 @@ Foam::PointHit<Point> Foam::line<Point, PointRef>::nearestDist Point w(p - a_); - scalar c1 = v & w; + const scalar c1 = v & w; if (c1 <= 0) { return PointHit<Point>(false, a_, Foam::mag(p - a_), true); } - scalar c2 = v & v; + const scalar c2 = v & v; if (c2 <= c1) { return PointHit<Point>(false, b_, Foam::mag(p - b_), true); } - scalar b = c1/c2; + const scalar b = c1/c2; Point pb(a_ + b*v); diff --git a/src/OpenFOAM/primitives/Pair/Pair.H b/src/OpenFOAM/primitives/Pair/Pair.H index 73b99e5c15d..3209f4d9421 100644 --- a/src/OpenFOAM/primitives/Pair/Pair.H +++ b/src/OpenFOAM/primitives/Pair/Pair.H @@ -28,6 +28,9 @@ Description An ordered pair of two objects of type \<T\> with first() and second() elements. +SourceFiles + PairI.H + See also Foam::Tuple2 for storing two objects of dissimilar types. @@ -48,10 +51,10 @@ namespace Foam Class Pair Declaration \*---------------------------------------------------------------------------*/ -template<class Type> +template<class T> class Pair : - public FixedList<Type, 2> + public FixedList<T, 2> { public: @@ -59,131 +62,96 @@ public: // Constructors //- Null constructor - inline Pair() - {} + inline Pair(); //- Construct from components - inline Pair(const Type& f, const Type& s) - { - first() = f; - second() = s; - } + inline Pair(const T& f, const T& s); //- Construct from FixedList - inline Pair(const FixedList<Type, 2>& lst) - : - FixedList<Type, 2>(lst) - {} + inline Pair(const FixedList<T, 2>& lst); + + //- Construct, optionally sorted with first less-than second + inline Pair(const T& f, const T& s, const bool doSort); + + //- Construct, optionally sorted with first less-than second + inline Pair(const FixedList<T, 2>& lst, const bool doSort); //- Construct from Istream - inline Pair(Istream& is) - : - FixedList<Type, 2>(is) - {} + inline Pair(Istream& is); // Member Functions - //- Return first - inline const Type& first() const - { - return this->operator[](0); - } - - //- Return first - inline Type& first() - { - return this->operator[](0); - } - - //- Return second - inline const Type& second() const - { - return this->operator[](1); - } - - //- Return second - inline Type& second() - { - return this->operator[](1); - } - - //- Return other - inline const Type& other(const Type& a) const - { - if (first() == second()) - { - FatalErrorInFunction - << "Call to other only valid for Pair with differing" - << " elements:" << *this << abort(FatalError); - } - else if (first() == a) - { - return second(); - } - else - { - if (second() != a) - { - FatalErrorInFunction - << "Pair " << *this - << " does not contain " << a << abort(FatalError); - } - return first(); - } - } + // Access + + //- Return first element + using FixedList<T, 2>::first; + + //- Return last element + using FixedList<T, 2>::last; + + //- Return second element, which is also the last element + inline const T& second() const; + + //- Return second element, which is also the last element + inline T& second(); + + //- Return other element + inline const T& other(const T& a) const; + + + // Queries + + //- True if first() is less-than second() + inline bool sorted() const; + + + // Editing + + //- Flip the Pair in-place. + inline void flip(); + + //- Sort so that first() is less-than second() + inline void sort(); // Comparison //- Compare Pairs - // Returns: + // \return // - 0: different // - +1: identical values and order used // - -1: identical values, but in reversed order - static inline int compare(const Pair<Type>& a, const Pair<Type>& b) - { - if (a[0] == b[0] && a[1] == b[1]) - { - return 1; - } - else if (a[0] == b[1] && a[1] == b[0]) - { - return -1; - } - else - { - return 0; - } - } + static inline int compare(const Pair<T>& a, const Pair<T>& b); }; // * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * // -template<class Type> -Pair<Type> reverse(const Pair<Type>& p) +//- Return reverse of a Pair +template<class T> +Pair<T> reverse(const Pair<T>& p) { - return Pair<Type>(p.second(), p.first()); + return Pair<T>(p.second(), p.first()); } -template<class Type> -bool operator==(const Pair<Type>& a, const Pair<Type>& b) +template<class T> +bool operator==(const Pair<T>& a, const Pair<T>& b) { return (a.first() == b.first() && a.second() == b.second()); } -template<class Type> -bool operator!=(const Pair<Type>& a, const Pair<Type>& b) +template<class T> +bool operator!=(const Pair<T>& a, const Pair<T>& b) { return !(a == b); } -template<class Type> -bool operator<(const Pair<Type>& a, const Pair<Type>& b) +template<class T> +bool operator<(const Pair<T>& a, const Pair<T>& b) { return ( @@ -197,22 +165,22 @@ bool operator<(const Pair<Type>& a, const Pair<Type>& b) } -template<class Type> -bool operator<=(const Pair<Type>& a, const Pair<Type>& b) +template<class T> +bool operator<=(const Pair<T>& a, const Pair<T>& b) { return !(b < a); } -template<class Type> -bool operator>(const Pair<Type>& a, const Pair<Type>& b) +template<class T> +bool operator>(const Pair<T>& a, const Pair<T>& b) { return (b < a); } -template<class Type> -bool operator>=(const Pair<Type>& a, const Pair<Type>& b) +template<class T> +bool operator>=(const Pair<T>& a, const Pair<T>& b) { return !(a < b); } @@ -224,6 +192,10 @@ bool operator>=(const Pair<Type>& a, const Pair<Type>& b) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "PairI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Pair/PairI.H b/src/OpenFOAM/primitives/Pair/PairI.H new file mode 100644 index 00000000000..2f489a03804 --- /dev/null +++ b/src/OpenFOAM/primitives/Pair/PairI.H @@ -0,0 +1,165 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "Swap.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +template<class T> +inline int Foam::Pair<T>::compare(const Pair<T>& a, const Pair<T>& b) +{ + if (a.first() == b.first() && a.second() == b.second()) + { + return 1; + } + if (a.first() == b.second() && a.second() == b.first()) + { + return -1; + } + + return 0; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class T> +inline Foam::Pair<T>::Pair() +{} + + +template<class T> +inline Foam::Pair<T>::Pair(const T& f, const T& s) +{ + first() = f; + second() = s; +} + + +template<class T> +inline Foam::Pair<T>::Pair(const FixedList<T, 2>& lst) +: + FixedList<T, 2>(lst) +{} + + +template<class T> +inline Foam::Pair<T>::Pair(const T& f, const T& s, const bool doSort) +{ + if (doSort && f < s) + { + first() = s; + second() = f; + } + else + { + first() = f; + second() = s; + } +} + + +template<class T> +inline Foam::Pair<T>::Pair(const FixedList<T, 2>& lst, const bool doSort) +: + Pair<T>(lst.first(), lst.last(), doSort) +{} + + + +template<class T> +inline Foam::Pair<T>::Pair(Istream& is) +: + FixedList<T, 2>(is) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class T> +inline const T& Foam::Pair<T>::second() const +{ + return last(); +} + + +template<class T> +inline T& Foam::Pair<T>::second() +{ + return last(); +} + + +template<class T> +inline const T& Foam::Pair<T>::other(const T& a) const +{ + if (first() == second()) + { + FatalErrorInFunction + << "Call to other only valid for Pair with differing" + << " elements:" << *this << abort(FatalError); + } + else if (a == first()) + { + return second(); + } + else + { + if (a != second()) + { + FatalErrorInFunction + << "Pair " << *this + << " does not contain " << a << abort(FatalError); + } + return first(); + } +} + + +template<class T> +inline bool Foam::Pair<T>::sorted() const +{ + return (first() < second()); +} + + +template<class T> +inline void Foam::Pair<T>::flip() +{ + Foam::Swap(first(), second()); +} + + +template<class T> +inline void Foam::Pair<T>::sort() +{ + if (second() < first()) + { + flip(); + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Tuple2/Tuple2.H b/src/OpenFOAM/primitives/Tuple2/Tuple2.H index bf911ebc56b..195f74044ce 100644 --- a/src/OpenFOAM/primitives/Tuple2/Tuple2.H +++ b/src/OpenFOAM/primitives/Tuple2/Tuple2.H @@ -144,7 +144,7 @@ public: }; -//- Return reverse of a tuple2 +//- Return reverse of a Tuple2 template<class Type1, class Type2> inline Tuple2<Type2, Type1> reverse(const Tuple2<Type1, Type2>& t) { diff --git a/src/surfMesh/triSurface/triSurface.C b/src/surfMesh/triSurface/triSurface.C index b67da2ec63f..6a7b60da3f7 100644 --- a/src/surfMesh/triSurface/triSurface.C +++ b/src/surfMesh/triSurface/triSurface.C @@ -937,7 +937,7 @@ void Foam::triSurface::triFaceFaces(List<face>& plainFaces) const forAll(*this, facei) { - plainFaces[facei] = operator[](facei).triFaceFace(); + plainFaces[facei] = this->operator[](facei); } } -- GitLab From 4ba48996609eb40e83b075474223c20207074f33 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 7 Oct 2017 16:10:35 +0200 Subject: [PATCH 025/126] ENH: minor update of PackedList methods - additional convenience constructors --- .../test/PackedList/Test-PackedList.C | 2 +- .../Lists/PackedList/PackedBoolList.C | 61 +++++++------- .../Lists/PackedList/PackedBoolList.H | 18 ++++- .../Lists/PackedList/PackedBoolListI.H | 41 ++++++++-- .../containers/Lists/PackedList/PackedList.H | 21 ++--- .../containers/Lists/PackedList/PackedListI.H | 81 ++++++++----------- 6 files changed, 131 insertions(+), 93 deletions(-) diff --git a/applications/test/PackedList/Test-PackedList.C b/applications/test/PackedList/Test-PackedList.C index 90ed8ac7408..45d5ab00b6e 100644 --- a/applications/test/PackedList/Test-PackedList.C +++ b/applications/test/PackedList/Test-PackedList.C @@ -41,7 +41,7 @@ using namespace Foam; template<unsigned nBits> inline void reportInfo() { - unsigned offset = PackedList<nBits>::packing(); + const unsigned offset = PackedList<nBits>::packing(); unsigned useSHL = ((1u << (nBits * offset)) - 1); unsigned useSHR = (~0u >> (sizeof(unsigned)*CHAR_BIT - nBits * offset)); diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C index 4b01a43dd61..543c5b85584 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C @@ -92,13 +92,15 @@ bool Foam::PackedBoolList::bitorPrepare template<class LabelListType> Foam::label Foam::PackedBoolList::setIndices(const LabelListType& indices) { - // no better information, just guess something about the size - reserve(indices.size()); + const label len = indices.size(); + + // No better information, just guess something from the size + reserve(len); label cnt = 0; - forAll(indices, elemI) + for (label i = 0; i < len; ++i) { - if (set(indices[elemI])) + if (set(indices[i])) { ++cnt; } @@ -112,9 +114,10 @@ template<class LabelListType> Foam::label Foam::PackedBoolList::unsetIndices(const LabelListType& indices) { label cnt = 0; - forAll(indices, elemI) + const label len = indices.size(); + for (label i = 0; i < len; ++i) { - if (unset(indices[elemI])) + if (unset(indices[i])) { ++cnt; } @@ -127,29 +130,30 @@ Foam::label Foam::PackedBoolList::unsetIndices(const LabelListType& indices) template<class LabelListType> Foam::label Foam::PackedBoolList::subsetIndices(const LabelListType& indices) { - // handle trivial case - if (empty() || indices.empty()) + const label len = indices.size(); + + // Handle trivial case + if (empty() || !len) { clear(); return 0; } - // normal case - PackedBoolList anded; - anded.reserve(size()); + PackedBoolList result; + result.reserve(size()); label cnt = 0; - forAll(indices, elemI) + for (label i = 0; i < len; ++i) { - const label& index = indices[elemI]; - if (operator[](index)) + const label index = indices[i]; + if (get(index)) { - anded.set(index); + result.set(index); ++cnt; } } - transfer(anded); + transfer(result); return cnt; } @@ -176,7 +180,7 @@ void Foam::PackedBoolList::set(const PackedList<1>& lst) StorageList& lhs = this->storage(); const StorageList& rhs = lst.storage(); - for (label i=0; i < len; ++i) + for (label i = 0; i < len; ++i) { lhs[i] |= rhs[i]; } @@ -209,7 +213,7 @@ void Foam::PackedBoolList::unset(const PackedList<1>& lst) // overlapping storage size const label len = min(this->packedLength(), lst.packedLength()); - for (label i=0; i < len; ++i) + for (label i = 0; i < len; ++i) { lhs[i] &= ~rhs[i]; } @@ -242,7 +246,7 @@ void Foam::PackedBoolList::subset(const PackedList<1>& lst) const label len = this->packedLength(); - for (label i=0; i < len; ++i) + for (label i = 0; i < len; ++i) { lhs[i] &= rhs[i]; } @@ -288,12 +292,13 @@ Foam::Xfer<Foam::labelList> Foam::PackedBoolList::used() const void Foam::PackedBoolList::operator=(const UList<bool>& lst) { - this->setSize(lst.size()); + const label len = lst.size(); + this->setSize(len); - // overwrite with new true/false values - forAll(*this, elemI) + // Overwrite with new true/false values + for (label i = 0; i < len; ++i) { - set(elemI, lst[elemI]); + set(i, lst[i]); } } @@ -301,15 +306,15 @@ void Foam::PackedBoolList::operator=(const UList<bool>& lst) Foam::PackedBoolList& Foam::PackedBoolList::operator^=(const PackedList<1>& lst) { - // extend addressable area if needed, return maximum size possible + // Extend addressable area if needed, return maximum size possible label len = 0; const bool needTrim = bitorPrepare(lst, len); - // operate directly with the underlying storage + // Operate directly with the underlying storage StorageList& lhs = this->storage(); const StorageList& rhs = lst.storage(); - for (label i=0; i < len; ++i) + for (label i = 0; i < len; ++i) { lhs[i] ^= rhs[i]; } @@ -334,7 +339,7 @@ Foam::PackedBoolList Foam::operator& PackedBoolList result(lst1); result &= lst2; - // trim to bits actually used + // Trim to bits actually used result.trim(); return result; @@ -350,7 +355,7 @@ Foam::PackedBoolList Foam::operator^ PackedBoolList result(lst1); result ^= lst2; - // trim to bits actually used + // Trim to bits actually used result.trim(); return result; diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H index f98545a9bd6..a667e8aecf1 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -96,7 +96,7 @@ public: //- Construct from Istream PackedBoolList(Istream& is); - //- Construct with given size, initializes list to 0 + //- Construct with given size, initializes list to 0 (false) explicit inline PackedBoolList(const label size); //- Construct with given size and value for all elements @@ -114,6 +114,20 @@ public: //- Construct by transferring the parameter contents inline PackedBoolList(const Xfer<PackedList<1>>& lst); + //- Construct with given size and list of labels to set as true. + inline PackedBoolList + ( + const label size, + const labelUList& indices + ); + + //- Construct with given size and list of labels to set as true. + inline PackedBoolList + ( + const label size, + const UIndirectList<label>& indices + ); + //- Construct from a list of bools explicit inline PackedBoolList(const UList<bool>& lst); diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H index a0702f9a30e..4c713dc005d 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,23 +75,52 @@ inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedList<1>>& lst) inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst) : - PackedList<1>() + PackedList<1>(lst.size()) { - operator=(lst); + // Set according to indices that are true + const label len = lst.size(); + + for (label i = 0; i < len; ++i) + { + if (lst[i]) + { + this->set(i, 1u); + } + } } inline Foam::PackedBoolList::PackedBoolList(const labelUList& indices) : - PackedList<1>(indices.size(), 0u) + PackedBoolList(indices.size(), indices) +{} + + +inline Foam::PackedBoolList::PackedBoolList(const UIndirectList<label>& indices) +: + PackedBoolList(indices.size(), indices) +{} + + +inline Foam::PackedBoolList::PackedBoolList +( + const label size, + const labelUList& indices +) +: + PackedList<1>(size) { set(indices); } -inline Foam::PackedBoolList::PackedBoolList(const UIndirectList<label>& indices) +inline Foam::PackedBoolList::PackedBoolList +( + const label size, + const UIndirectList<label>& indices +) : - PackedList<1>(indices.size(), 0u) + PackedList<1>(size) { set(indices); } diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index 18720fc2ae9..ee03e4ad27a 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -48,8 +48,9 @@ Note list[1] = list[5] = list[6]; // propagates value \endcode - Using get() or the '[]' operator are similarly fast. Looping and reading - via an iterator is approx. 15% slower, but can be more flexible. + Reading via the get() or the '[]' operator are identical. + Looping and reading via an iterator is approx. 15% slower, + but can be more flexible. Using the set() operator (and the '[]' operator) are marginally slower (approx. 5%) than using an iterator, but the set() method has the @@ -157,7 +158,7 @@ protected: // Protected Member Functions //- Calculate the list length when packed - inline static label packedLength(const label); + inline static label packedLength(const label nElem); //- Read a list entry (allows for specialization) inline static unsigned int readValue(Istream& is); @@ -200,14 +201,14 @@ public: //- The max. number of bits that can be templated. // Might someday be useful for a template assert. - inline static unsigned int max_bits(); + inline static constexpr unsigned int max_bits(); //- The max. value for an entry, which simultaneously the bit-mask // eg, ((1 << 2) - 1) yields 0b0011 - inline static unsigned int max_value(); + inline static constexpr unsigned int max_value(); //- The number of entries per packed storage element - inline static unsigned int packing(); + inline static constexpr unsigned int packing(); //- Masking for all bits below the offset inline static unsigned int maskLower(unsigned offset); @@ -393,11 +394,11 @@ public: //- Remove and return the last element inline unsigned int remove(); - //- Get value at index I + //- Identical to get() - get value at index. // Never auto-vivify entries. inline unsigned int operator[](const label i) const; - //- Set value at index I. + //- Non-const access to value at index. // Returns iterator to perform the actual operation. // Does not auto-vivify entries, but will when assigned to. inline iteratorBase operator[](const label i); @@ -496,11 +497,11 @@ public: //- Disallow copy constructor from const_iterator // This would violate const-ness! - iterator(const const_iterator& iter); + iterator(const const_iterator& iter) = delete; //- Disallow assignment from const_iterator // This would violate const-ness! - void operator=(const const_iterator& iter); + void operator=(const const_iterator& iter) = delete; public: diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H index ad136b903fa..4f9c58644ad 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,24 +25,24 @@ License #include <climits> -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // template<unsigned nBits> -inline unsigned int Foam::PackedList<nBits>::max_bits() +inline constexpr unsigned int Foam::PackedList<nBits>::max_bits() { return sizeof(StorageType)*CHAR_BIT - 1; } template<unsigned nBits> -inline unsigned int Foam::PackedList<nBits>::max_value() +inline constexpr unsigned int Foam::PackedList<nBits>::max_value() { return (1u << nBits) - 1; } template<unsigned nBits> -inline unsigned int Foam::PackedList<nBits>::packing() +inline constexpr unsigned int Foam::PackedList<nBits>::packing() { return sizeof(StorageType)*CHAR_BIT / nBits; } @@ -65,6 +65,8 @@ inline Foam::label Foam::PackedList<nBits>::packedLength(const label nElem) } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + namespace Foam { // Template specialization for bool entries @@ -88,13 +90,10 @@ namespace Foam if (this->get()) { os << index_; - return true; } - else - { - return false; - } + + return false; } } @@ -119,12 +118,12 @@ inline unsigned int Foam::PackedList<nBits>::readValue(Istream& is) template<unsigned nBits> inline void Foam::PackedList<nBits>::setPair(Istream& is) { - is.readBegin("Tuple2<label, unsigned int>"); + is.readBegin("Tuple2<label,unsigned int>"); const label ind = readLabel(is); const unsigned int val = readLabel(is); - is.readEnd("Tuple2<label, unsigned int>"); + is.readEnd("Tuple2<label,unsigned int>"); if (val > max_value()) { @@ -154,10 +153,8 @@ inline bool Foam::PackedList<nBits>::iteratorBase::writeIfSet(Ostream& os) const return true; } - else - { - return false; - } + + return false; } @@ -233,7 +230,8 @@ inline Foam::PackedList<nBits>::PackedList(const labelUList& lst) StorageList(packedLength(lst.size()), 0u), size_(lst.size()) { - forAll(lst, i) + const label len = lst.size(); + for (label i = 0; i < len; ++i) { set(i, lst[i]); } @@ -247,7 +245,8 @@ inline Foam::PackedList<nBits>::PackedList(const UIndirectList<label>& lst) StorageList(packedLength(lst.size()), 0u), size_(lst.size()) { - forAll(lst, i) + const label len = lst.size(); + for (label i = 0; i < len; ++i) { set(i, lst[i]); } @@ -862,16 +861,16 @@ inline void Foam::PackedList<nBits>::reserve(const label nElem) { const label len = packedLength(nElem); - // Need more capacity? + // Allocate more capacity if necessary if (len > StorageList::size()) { - // Like DynamicList with SizeInc=0, SizeMult=2, SizeDiv=1 StorageList::setSize ( max ( len, - StorageList::size()*2 + // SizeInc=0, SizeMult=2, SizeDiv=1 + 2 * StorageList::size() ), 0u ); @@ -964,27 +963,17 @@ inline unsigned int Foam::PackedList<nBits>::get(const label i) const // Lazy evaluation - return 0 for out-of-range if (i < 0 || i >= size_) { - return 0; - } - else - { - return iteratorBase(this, i).get(); + return 0u; } + + return iteratorBase(this, i).get(); } template<unsigned nBits> inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const { - // Lazy evaluation - return 0 for out-of-range - if (i < 0 || i >= size_) - { - return 0; - } - else - { - return iteratorBase(this, i).get(); - } + return get(i); } @@ -1024,10 +1013,8 @@ inline bool Foam::PackedList<nBits>::unset(const label i) { return false; } - else - { - return iteratorBase(this, i).set(0u); - } + + return iteratorBase(this, i).set(0u); } @@ -1035,11 +1022,11 @@ template<unsigned nBits> inline Foam::PackedList<nBits>& Foam::PackedList<nBits>::append(const unsigned int val) { - const label elemI = size_; - reserve(elemI + 1); + const label idx = size_; + reserve(idx + 1); size_++; - iteratorBase(this, elemI).set(val); + iteratorBase(this, idx).set(val); return *this; } @@ -1047,15 +1034,17 @@ Foam::PackedList<nBits>::append(const unsigned int val) template<unsigned nBits> inline unsigned int Foam::PackedList<nBits>::remove() { - if (!size_) + // Location of last element and simultaneously the new size + const label idx = size_ - 1; + + if (idx < 0) { FatalErrorInFunction << "List is empty" << abort(FatalError); } - label elemI = size_ - 1; - const unsigned int val = iteratorBase(this, elemI).get(); - resize(elemI); + const unsigned int val = iteratorBase(this, idx).get(); + resize(idx); return val; } -- GitLab From 1a3a57f73d9a008a8948e2841de79ec3501b4a44 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 9 Oct 2017 09:55:35 +0100 Subject: [PATCH 026/126] STYLE: CodedSource: remove space from description. Fixes #612. --- src/fvOptions/sources/general/codedSource/CodedSource.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fvOptions/sources/general/codedSource/CodedSource.C b/src/fvOptions/sources/general/codedSource/CodedSource.C index 4611cd23174..2ea05cf09a8 100644 --- a/src/fvOptions/sources/general/codedSource/CodedSource.C +++ b/src/fvOptions/sources/general/codedSource/CodedSource.C @@ -90,7 +90,7 @@ Foam::dlLibraryTable& Foam::fv::CodedSource<Type>::libs() const template<class Type> Foam::string Foam::fv::CodedSource<Type>::description() const { - return "fvOption:: " + name_; + return "fvOption::" + name_; } -- GitLab From 37c612733892fa74e56b2615e8ba519dd13ae22a Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 9 Oct 2017 12:47:56 +0100 Subject: [PATCH 027/126] COMP: Pstream: dummy version misses dependency of pthread (needed in OSspecific). Fixes #614. --- src/Pstream/dummy/Make/options | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Pstream/dummy/Make/options b/src/Pstream/dummy/Make/options index e69de29bb2d..e4319f9dfc1 100644 --- a/src/Pstream/dummy/Make/options +++ b/src/Pstream/dummy/Make/options @@ -0,0 +1 @@ +LIB_LIBS = -lpthread -- GitLab From caf497126144fc82513f9ffebeca74bf250dcb1b Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 9 Oct 2017 14:15:39 +0100 Subject: [PATCH 028/126] BUG: rhoCentralFoam: correct/clean up oriented handling. Fixes #615. --- .../rhoCentralDyMFoam/rhoCentralDyMFoam.C | 24 +++++++++++-------- .../rhoCentralFoam/rhoCentralFoam.C | 17 +++++++------ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C index b24f21fe8df..5d76f3deabf 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C @@ -113,6 +113,9 @@ int main(int argc, char *argv[]) phiv_pos -= mesh.phi(); phiv_neg -= mesh.phi(); } + // Note: extracted out the orientation so becomes unoriented + phiv_pos.setOriented(false); + phiv_neg.setOriented(false); volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi)); surfaceScalarField cSf_pos @@ -120,14 +123,11 @@ int main(int argc, char *argv[]) "cSf_pos", interpolate(c, pos, T.name())*mesh.magSf() ); - cSf_pos.setOriented(); - surfaceScalarField cSf_neg ( "cSf_neg", interpolate(c, neg, T.name())*mesh.magSf() ); - cSf_neg.setOriented(); surfaceScalarField ap ( @@ -168,11 +168,12 @@ int main(int argc, char *argv[]) phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg; - surfaceVectorField phiUp - ( - (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg) - + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf() - ); + surfaceVectorField phiU(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg); + // Note: reassembled orientation from the pos and neg parts so becomes + // oriented + phiU.setOriented(true); + + surfaceVectorField phiUp(phiU + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf()); surfaceScalarField phiEp ( @@ -185,7 +186,10 @@ int main(int argc, char *argv[]) // Make flux for pressure-work absolute if (mesh.moving()) { - phiEp += mesh.phi()*(a_pos*p_pos + a_neg*p_neg); + surfaceScalarField phia(a_pos*p_pos + a_neg*p_neg); + phia.setOriented(true); + + phiEp += mesh.phi()*phia; } volScalarField muEff("muEff", turbulence->muEff()); @@ -222,7 +226,7 @@ int main(int argc, char *argv[]) fvc::interpolate(muEff)*mesh.magSf()*fvc::snGrad(U) + fvc::dotInterpolate(mesh.Sf(), tauMC) ) - & (a_pos*U_pos + a_neg*U_neg) + & (a_pos*U_pos + a_neg*U_neg) ); solve diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C index 6550d62b28c..a9752759258 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C @@ -93,7 +93,10 @@ int main(int argc, char *argv[]) surfaceScalarField p_neg("p_neg", rho_neg*rPsi_neg); surfaceScalarField phiv_pos("phiv_pos", U_pos & mesh.Sf()); + // Note: extracted out the orientation so becomes unoriented + phiv_pos.setOriented(false); surfaceScalarField phiv_neg("phiv_neg", U_neg & mesh.Sf()); + phiv_neg.setOriented(false); volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi)); surfaceScalarField cSf_pos @@ -101,20 +104,19 @@ int main(int argc, char *argv[]) "cSf_pos", interpolate(c, pos, T.name())*mesh.magSf() ); - cSf_pos.setOriented(); surfaceScalarField cSf_neg ( "cSf_neg", interpolate(c, neg, T.name())*mesh.magSf() ); - cSf_neg.setOriented(); surfaceScalarField ap ( "ap", max(max(phiv_pos + cSf_pos, phiv_neg + cSf_neg), v_zero) ); + surfaceScalarField am ( "am", @@ -163,11 +165,12 @@ int main(int argc, char *argv[]) phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg; - surfaceVectorField phiUp - ( - (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg) - + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf() - ); + surfaceVectorField phiU(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg); + // Note: reassembled orientation from the pos and neg parts so becomes + // oriented + phiU.setOriented(true); + + surfaceVectorField phiUp(phiU + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf()); surfaceScalarField phiEp ( -- GitLab From 051d1d661f5c5a5621c5557fa4fe20d9a6c9227e Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 9 Oct 2017 15:34:10 +0100 Subject: [PATCH 029/126] ENH: surfaceFeatures: survive zero length edge. Fixes #616. --- .../triSurface/surfaceFeatures/surfaceFeatures.C | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index 8da032518b1..7877bdfc2d2 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -243,12 +243,16 @@ void Foam::surfaceFeatures::calcFeatPoints if (edgeStat[edgeI] != NONE) { - edgeVecs.append(edges[edgeI].vec(localPoints)); - edgeVecs.last() /= mag(edgeVecs.last()); + vector vec = edges[edgeI].vec(localPoints); + scalar magVec = mag(vec); + if (magVec > SMALL) + { + edgeVecs.append(vec/magVec); + } } } - if (mag(edgeVecs[0] & edgeVecs[1]) < minCos) + if (edgeVecs.size() == 2 && mag(edgeVecs[0] & edgeVecs[1]) < minCos) { featurePoints.append(pointi); } -- GitLab From e9254eee58d43c467b3e89f4bd92e3adda7354c4 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 9 Oct 2017 21:00:34 +0200 Subject: [PATCH 030/126] ENH: support KaHIP decomposition - refactor some common metis-like elements into the metisLikeDecomp abstract class. --- .../test/checkDecomposePar/Make/files | 3 + .../test/checkDecomposePar/Make/options | 10 + .../Test-checkDecomposePar.C | 193 +++++++++ applications/test/decomposePar/Make/files | 3 + applications/test/decomposePar/Make/options | 12 + .../test/decomposePar/Test-decomposePar.C | 278 +++++++++++++ applications/test/foamToMetisGraph/Make/files | 3 + .../test/foamToMetisGraph/Make/options | 3 + .../test/foamToMetisGraph/foamToMetisGraph.C | 86 ++++ .../manipulation/renumberMesh/Make/options | 2 +- .../decomposePar/Make/options | 3 +- etc/config.sh/kahip | 59 +++ etc/config.sh/unset | 1 + src/dummyThirdParty/Allwmake | 1 + src/dummyThirdParty/kahipDecomp/Make/files | 3 + src/dummyThirdParty/kahipDecomp/Make/options | 5 + .../kahipDecomp/dummyKahipDecomp.C | 83 ++++ .../kahipDecomp/kaHIP_interface.h | 37 ++ .../metisDecomp/dummyMetisDecomp.C | 60 +-- .../ptscotchDecomp/dummyPtscotchDecomp.C | 15 +- .../scotchDecomp/dummyScotchDecomp.C | 18 +- src/parallel/decompose/Allwclean | 3 +- src/parallel/decompose/Allwmake | 53 +++ src/parallel/decompose/decompose/Make/files | 1 + .../decompose/decompositionInformation.C | 236 +++++++++++ .../decompose/decompositionInformation.H | 149 +++++++ .../decompose/decompositionMethods/Make/files | 1 + .../decompositionMethod/decompositionMethod.C | 42 +- .../decompositionMethod/decompositionMethod.H | 2 +- .../metisLikeDecomp/metisLikeDecomp.C | 264 +++++++++++++ .../metisLikeDecomp/metisLikeDecomp.H | 151 +++++++ src/parallel/decompose/kahipDecomp/Make/files | 3 + .../decompose/kahipDecomp/Make/options | 13 + .../decompose/kahipDecomp/kahipDecomp.C | 329 +++++++++++++++ .../decompose/kahipDecomp/kahipDecomp.H | 143 +++++++ .../decompose/metisDecomp/metisDecomp.C | 159 ++------ .../decompose/metisDecomp/metisDecomp.H | 90 ++--- .../decompose/ptscotchDecomp/ptscotchDecomp.C | 89 ++--- .../decompose/ptscotchDecomp/ptscotchDecomp.H | 23 +- .../decompose/scotchDecomp/scotchDecomp.C | 373 ++++-------------- .../decompose/scotchDecomp/scotchDecomp.H | 62 ++- 41 files changed, 2390 insertions(+), 674 deletions(-) create mode 100644 applications/test/checkDecomposePar/Make/files create mode 100644 applications/test/checkDecomposePar/Make/options create mode 100644 applications/test/checkDecomposePar/Test-checkDecomposePar.C create mode 100644 applications/test/decomposePar/Make/files create mode 100644 applications/test/decomposePar/Make/options create mode 100644 applications/test/decomposePar/Test-decomposePar.C create mode 100644 applications/test/foamToMetisGraph/Make/files create mode 100644 applications/test/foamToMetisGraph/Make/options create mode 100644 applications/test/foamToMetisGraph/foamToMetisGraph.C create mode 100644 etc/config.sh/kahip create mode 100644 src/dummyThirdParty/kahipDecomp/Make/files create mode 100644 src/dummyThirdParty/kahipDecomp/Make/options create mode 100644 src/dummyThirdParty/kahipDecomp/dummyKahipDecomp.C create mode 100644 src/dummyThirdParty/kahipDecomp/kaHIP_interface.h create mode 100644 src/parallel/decompose/decompose/decompositionInformation.C create mode 100644 src/parallel/decompose/decompose/decompositionInformation.H create mode 100644 src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C create mode 100644 src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.H create mode 100644 src/parallel/decompose/kahipDecomp/Make/files create mode 100644 src/parallel/decompose/kahipDecomp/Make/options create mode 100644 src/parallel/decompose/kahipDecomp/kahipDecomp.C create mode 100644 src/parallel/decompose/kahipDecomp/kahipDecomp.H diff --git a/applications/test/checkDecomposePar/Make/files b/applications/test/checkDecomposePar/Make/files new file mode 100644 index 00000000000..512f2b17360 --- /dev/null +++ b/applications/test/checkDecomposePar/Make/files @@ -0,0 +1,3 @@ +Test-checkDecomposePar.C + +EXE = $(FOAM_APPBIN)/Test-checkDecomposePar diff --git a/applications/test/checkDecomposePar/Make/options b/applications/test/checkDecomposePar/Make/options new file mode 100644 index 00000000000..74501c5fddb --- /dev/null +++ b/applications/test/checkDecomposePar/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude + +EXE_LIBS = \ + -ldecompositionMethods \ + -lregionModels diff --git a/applications/test/checkDecomposePar/Test-checkDecomposePar.C b/applications/test/checkDecomposePar/Test-checkDecomposePar.C new file mode 100644 index 00000000000..fc6aa405da2 --- /dev/null +++ b/applications/test/checkDecomposePar/Test-checkDecomposePar.C @@ -0,0 +1,193 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + checkDecomposePar + +Group + grpParallelUtilities + +Description + Check decomposition from kaffpa (KaHIP) output. + foamToMetisGraph was likely used for producing the kaffpa input. + +\*---------------------------------------------------------------------------*/ + +#include "OSspecific.H" +#include "fvCFD.H" +#include "cpuTime.H" +#include "IFstream.H" +#include "regionProperties.H" +#include "decompositionInformation.H" +#include "decompositionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Check decomposition from kaffpa (KaHIP) output" + ); + + argList::noParallel(); + argList::noBanner(); + + #include "addRegionOption.H" + argList::addBoolOption + ( + "allRegions", + "operate on all regions in regionProperties" + ); + argList::addBoolOption + ( + "verbose", + "more information about decomposition" + ); + + argList::validArgs.append("kaffpa-output-file"); + + // Include explicit constant options, have zero from time range + timeSelector::addOptions(true, false); + + #include "setRootCase.H" + + const fileName decompFile = args[1]; + + const bool region = args.optionFound("region"); + const bool allRegions = args.optionFound("allRegions"); + const bool verbose = args.optionFound("verbose"); + + // Set time from database + #include "createTime.H" + // Allow override of time + instantList times = timeSelector::selectIfPresent(runTime, args); + + // Allow override of decomposeParDict location + fileName decompDictFile; + args.optionReadIfPresent("decomposeParDict", decompDictFile); + + wordList regionNames; + wordList regionDirs; + if (allRegions) + { + Info<< "Decomposing all regions in regionProperties" << nl << endl; + regionProperties rp(runTime); + forAllConstIters(rp, iter) + { + const wordList& regions = iter(); + forAll(regions, i) + { + if (findIndex(regionNames, regions[i]) == -1) + { + regionNames.append(regions[i]); + } + } + } + regionDirs = regionNames; + } + else + { + word regionName; + if (args.optionReadIfPresent("region", regionName)) + { + regionNames = wordList(1, regionName); + regionDirs = regionNames; + } + else + { + regionNames = wordList(1, fvMesh::defaultRegion); + regionDirs = wordList(1, word::null); + } + } + + labelList cellToProc; + + forAll(regionNames, regioni) + { + const word& regionName = regionNames[regioni]; + const word& regionDir = regionDirs[regioni]; + + Info<< "\n\nDecomposing mesh " << regionName << nl << endl; + Info<< "Create mesh..." << flush; + + fvMesh mesh + ( + IOobject + ( + regionName, + runTime.timeName(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + Info<< " nCells = " << mesh.nCells() << endl; + + // Expected format is a simple ASCII list + cellToProc.setSize(mesh.nCells()); + { + IFstream is(decompFile); + + forAll(cellToProc, celli) + { + cellToProc[celli] = readLabel(is); + } + } + + const label nDomains = max(cellToProc) + 1; + + CompactListList<label> cellCells; + decompositionMethod::calcCellCells + ( + mesh, + identity(mesh.nCells()), + mesh.nCells(), + false, + cellCells + ); + + decompositionInformation info + ( + cellCells, + cellToProc, + nDomains + ); + + if (verbose) + { + info.printDetails(Info); + Info<< nl; + } + info.printSummary(Info); + } + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/decomposePar/Make/files b/applications/test/decomposePar/Make/files new file mode 100644 index 00000000000..d9ed6fcd8bf --- /dev/null +++ b/applications/test/decomposePar/Make/files @@ -0,0 +1,3 @@ +Test-decomposePar.C + +EXE = $(FOAM_APPBIN)/Test-decomposePar diff --git a/applications/test/decomposePar/Make/options b/applications/test/decomposePar/Make/options new file mode 100644 index 00000000000..1f62e3ffa8a --- /dev/null +++ b/applications/test/decomposePar/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude + +EXE_LIBS = \ + -ldecompose \ + -ldecompositionMethods \ + -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp -lkahipDecomp \ + -lregionModels diff --git a/applications/test/decomposePar/Test-decomposePar.C b/applications/test/decomposePar/Test-decomposePar.C new file mode 100644 index 00000000000..7ad717f7421 --- /dev/null +++ b/applications/test/decomposePar/Test-decomposePar.C @@ -0,0 +1,278 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + decomposePar + +Group + grpParallelUtilities + +Description + Automatically decomposes a mesh and fields of a case for parallel + execution of OpenFOAM. + +Usage + \b decomposePar [OPTION] + + Options: + - \par -region \<regionName\> + Decompose named region. Does not check for existence of processor*. + + - \par -allRegions + Decompose all regions in regionProperties. Does not check for + existence of processor*. + + - \par -constant + + - \par -time xxx:yyy + Override controlDict settings and decompose selected times. Does not + re-decompose the mesh i.e. does not handle moving mesh or changing + mesh cases. + +\*---------------------------------------------------------------------------*/ + +#include "OSspecific.H" +#include "fvCFD.H" +#include "cpuTime.H" +#include "IOobjectList.H" +#include "regionProperties.H" +#include "decompositionInformation.H" +#include "decompositionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "decompose a mesh and fields of a case for parallel execution" + ); + + argList::noParallel(); + argList::addOption + ( + "decomposeParDict", + "file", + "read decomposePar dictionary from specified location" + ); + #include "addRegionOption.H" + argList::addBoolOption + ( + "allRegions", + "operate on all regions in regionProperties" + ); + argList::addBoolOption + ( + "verbose", + "more information about decomposition" + ); + argList::addOption + ( + "domains", + "N" + "override numberOfSubdomains" + ); + + argList::addOption + ( + "method", + "name" + "override method" + ); + + // Include explicit constant options, have zero from time range + timeSelector::addOptions(true, false); + + #include "setRootCase.H" + + const bool region = args.optionFound("region"); + const bool allRegions = args.optionFound("allRegions"); + const bool verbose = args.optionFound("verbose"); + + const label numSubdomains = + args.optionLookupOrDefault<label>("domains", 0); + + const word methodName = + args.optionLookupOrDefault<word>("method", word::null); + + + // Set time from database + #include "createTime.H" + // Allow override of time + instantList times = timeSelector::selectIfPresent(runTime, args); + + // Allow override of decomposeParDict location + fileName decompDictFile; + args.optionReadIfPresent("decomposeParDict", decompDictFile); + + wordList regionNames; + wordList regionDirs; + if (allRegions) + { + Info<< "Decomposing all regions in regionProperties" << nl << endl; + regionProperties rp(runTime); + forAllConstIters(rp, iter) + { + const wordList& regions = iter(); + forAll(regions, i) + { + if (findIndex(regionNames, regions[i]) == -1) + { + regionNames.append(regions[i]); + } + } + } + regionDirs = regionNames; + } + else + { + word regionName; + if (args.optionReadIfPresent("region", regionName)) + { + regionNames = wordList(1, regionName); + regionDirs = regionNames; + } + else + { + regionNames = wordList(1, fvMesh::defaultRegion); + regionDirs = wordList(1, word::null); + } + } + + + forAll(regionNames, regioni) + { + const word& regionName = regionNames[regioni]; + const word& regionDir = regionDirs[regioni]; + + Info<< "\n\nDecomposing mesh " << regionName << nl << endl; + Info<< "Create mesh..." << flush; + + fvMesh mesh + ( + IOobject + ( + regionName, + runTime.timeName(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + Info<< " nCells = " << mesh.nCells() << endl; + + Info<< "\nCalculating distribution of cells" << endl; + cpuTime decompositionTime; + + const decompositionModel& model = decompositionModel::New + ( + mesh, + decompDictFile + ); + + // Allow command-line override for quick testing + + dictionary& modelDict = const_cast<decompositionModel&>(model); + + if (numSubdomains) + { + modelDict.add + ( + word("numberOfSubdomains"), + numSubdomains, + true + ); + } + + if (!methodName.empty()) + { + modelDict.add + ( + word("method"), + methodName, + true + ); + } + + scalarField cellWeights; + word weightName; + if (model.readIfPresent("weightField", weightName)) + { + volScalarField weights + ( + IOobject + ( + weightName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh + ); + cellWeights = weights.primitiveField(); + } + + decompositionMethod& method = model.decomposer(); + + CompactListList<label> cellCells; + decompositionMethod::calcCellCells + ( + mesh, + identity(mesh.nCells()), + mesh.nCells(), + false, + cellCells + ); + + labelList cellToProc = method.decompose(mesh, cellWeights); + + Info<< "\nFinished decomposition into " + << method.nDomains() << " domains in " + << decompositionTime.elapsedCpuTime() + << " s" << nl << endl; + + decompositionInformation info + ( + cellCells, + cellToProc, + method.nDomains() + ); + + if (verbose) + { + info.printDetails(Info); + Info<< nl; + } + info.printSummary(Info); + } + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/foamToMetisGraph/Make/files b/applications/test/foamToMetisGraph/Make/files new file mode 100644 index 00000000000..6c63ebbc7ff --- /dev/null +++ b/applications/test/foamToMetisGraph/Make/files @@ -0,0 +1,3 @@ +foamToMetisGraph.C + +EXE = $(FOAM_USER_APPBIN)/foamToMetisGraph diff --git a/applications/test/foamToMetisGraph/Make/options b/applications/test/foamToMetisGraph/Make/options new file mode 100644 index 00000000000..4c3dd783cb4 --- /dev/null +++ b/applications/test/foamToMetisGraph/Make/options @@ -0,0 +1,3 @@ +EXE_INC = + +EXE_LIBS = diff --git a/applications/test/foamToMetisGraph/foamToMetisGraph.C b/applications/test/foamToMetisGraph/foamToMetisGraph.C new file mode 100644 index 00000000000..d4019842d48 --- /dev/null +++ b/applications/test/foamToMetisGraph/foamToMetisGraph.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + Create a metis graph file representation of an OpenFOAM mesh + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "polyMesh.H" +#include "OFstream.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noParallel(); + argList::noFunctionObjects(); + argList::addNote + ( + "Create a metis graph file representation for an OpenFOAM mesh" + ); + + #include "setRootCase.H" + #include "createTime.H" + #include "createPolyMesh.H" + + const labelListList& cellCells = mesh.cellCells(); + + // No. of Nodes = nCells + // No. of Edges connecting Nodes = nInternalFaces + + OFstream os(args.caseName() + ".graph", IOstream::ASCII); + + os << "%% metis graph file, of an OpenFOAM mesh %%" << nl + << "%% nCells=" << mesh.nCells() + << " nFaces=" << mesh.nFaces() + << " nInternalFaces=" << mesh.nInternalFaces() << nl; + + os << cellCells.size() << " " << mesh.nInternalFaces() << nl; + + for (const auto& edges : cellCells) + { + forAll(edges, i) + { + if (i) os << " "; + os << edges[i] + 1; // index starts at 1. + } + os << nl; + } + + Info<<"Wrote graph with " + << mesh.nCells() << " nodes and " + << mesh.nInternalFaces() << " edges to " + << os.name() << nl; + + Info<< nl << "End\n" << endl; + + return 0; +} + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options index f073a1c4140..5803e893aac 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options +++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options @@ -18,4 +18,4 @@ EXE_LIBS = \ -lreconstruct \ $(LINK_FLAGS) \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp + -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp -lkahipDecomp diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index cec9adc663b..34f3e5de333 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -11,7 +11,8 @@ EXE_LIBS = \ -ldynamicMesh \ -ldecompose \ -lgenericPatchFields \ - -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp \ + -ldecompositionMethods \ + -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp -lkahipDecomp \ -llagrangian \ -ldynamicMesh \ -lregionModels diff --git a/etc/config.sh/kahip b/etc/config.sh/kahip new file mode 100644 index 00000000000..9212e7a80a3 --- /dev/null +++ b/etc/config.sh/kahip @@ -0,0 +1,59 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# This file is part of OpenFOAM, licensed under the GNU General Public License +# <http://www.gnu.org/licenses/>. +# +# File +# etc/config.sh/kahip +# +# Description +# Setup for kahip include/libraries. +# Sourced during wmake process only. +# +# Normally used to specify the kahip version and location for a +# ThirdParty installation. +# +# If using system-wide installations, use the following setting: +# +# KAHIP_VERSION=kahip-system +# +# If the system kahip is unusable (eg, too old) and you don't +# have or want a ThirdParty installation: +# +# KAHIP_VERSION=kahip-none +# +# If using a central installation, but not located under ThirdParty: +# - specify kahip-system +# - provide full path for KAHIP_ARCH_PATH +# +# Note +# A csh version is not needed, since the values here are only sourced +# during the wmake process. +# +# KaHIP can also be entirely disabled, by either renaming this file or +# by creating an empty one with the same name at a user or site location. +# +# KaHIP is 32-bit precision only. +# An Int64 OpenFOAM version can use it, but the mesh size is limited +# accordingly. +# +# If KaHIP was compiled with openmp, you may need to add in additional +# compile or link flags in KAHIP_COMP_FLAGS KAHIP_LINK_FLAGS +# +#------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade + +KAHIP_VERSION=kahip-2.00 +export KAHIP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$KAHIP_VERSION + +# Adjust as required +# export KAHIP_COMP_FLAGS="-fopenmp" +# export KAHIP_LINK_FLAGS="-lgomp" + +# END OF (NORMAL) USER EDITABLE PART +#------------------------------------------------------------------------------ diff --git a/etc/config.sh/unset b/etc/config.sh/unset index fe8b8f18e10..31710db372c 100644 --- a/etc/config.sh/unset +++ b/etc/config.sh/unset @@ -134,6 +134,7 @@ unset GPERFTOOLS_ARCH_PATH unset GMP_ARCH_PATH unset MPFR_ARCH_PATH unset MESA_ARCH_PATH +unset KAHIP_ARCH_PATH unset METIS_ARCH_PATH unset SCOTCH_ARCH_PATH diff --git a/src/dummyThirdParty/Allwmake b/src/dummyThirdParty/Allwmake index 3dac95f4106..a1628e356fb 100755 --- a/src/dummyThirdParty/Allwmake +++ b/src/dummyThirdParty/Allwmake @@ -7,6 +7,7 @@ cd ${0%/*} || exit 1 # Run from this directory wmake $targetType scotchDecomp wmake $targetType ptscotchDecomp wmake $targetType metisDecomp +wmake $targetType kahipDecomp wmake $targetType MGridGen #------------------------------------------------------------------------------ diff --git a/src/dummyThirdParty/kahipDecomp/Make/files b/src/dummyThirdParty/kahipDecomp/Make/files new file mode 100644 index 00000000000..1a022756767 --- /dev/null +++ b/src/dummyThirdParty/kahipDecomp/Make/files @@ -0,0 +1,3 @@ +dummyKahipDecomp.C + +LIB = $(FOAM_LIBBIN)/dummy/libkahipDecomp diff --git a/src/dummyThirdParty/kahipDecomp/Make/options b/src/dummyThirdParty/kahipDecomp/Make/options new file mode 100644 index 00000000000..0aad6a146fa --- /dev/null +++ b/src/dummyThirdParty/kahipDecomp/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/kahipDecomp/lnInclude + +LIB_LIBS = diff --git a/src/dummyThirdParty/kahipDecomp/dummyKahipDecomp.C b/src/dummyThirdParty/kahipDecomp/dummyKahipDecomp.C new file mode 100644 index 00000000000..d3844087e44 --- /dev/null +++ b/src/dummyThirdParty/kahipDecomp/dummyKahipDecomp.C @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "kahipDecomp.H" +#include "addToRunTimeSelectionTable.H" +#include "Time.H" + +static const char* notImplementedMessage = +"You are trying to use kahip but do not have the kahipDecomp library loaded." +"\nThis message is from the dummy kahipDecomp stub library instead.\n" +"\n" +"Please install kahip and make sure that libkahip.so is in your " +"LD_LIBRARY_PATH.\n" +"The kahipDecomp library can then be built from " +"src/parallel/decompose/kahipDecomp and dynamically loading or linking" +" this library will add kahip as a decomposition method.\n"; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(kahipDecomp, 0); + + addToRunTimeSelectionTable + ( + decompositionMethod, + kahipDecomp, + dictionary + ); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::label Foam::kahipDecomp::decomposeSerial +( + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cellWeights, + List<label>& decomp +) +{ + FatalErrorInFunction + << notImplementedMessage << exit(FatalError); + + return -1; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::kahipDecomp::kahipDecomp +( + const dictionary& decompositionDict +) +: + metisLikeDecomp(decompositionDict) +{} + + +// ************************************************************************* // diff --git a/src/dummyThirdParty/kahipDecomp/kaHIP_interface.h b/src/dummyThirdParty/kahipDecomp/kaHIP_interface.h new file mode 100644 index 00000000000..90bf1afc23b --- /dev/null +++ b/src/dummyThirdParty/kahipDecomp/kaHIP_interface.h @@ -0,0 +1,37 @@ +#ifndef KAHIP_H +#define KAHIP_H + +/* *** DUMMY VERSION of kaHIP_interface.h - this file should not be included if you have KaHIP + * installed in the correct position in $WM_THIRD_PARTY_DIR - see + * decompositionMethods/kahipDecomp/Make/options + */ + +#warning "Dummy kahip.h - included since it cannot find KaHIP installation." + +#ifdef __cplusplus +extern "C" { +#endif + +void kaffpa +( + // [inputs] + int* n, + int* vwgt, + int* xadj, + int* adjcwgt, + int* adjncy, + int* nparts, + double* imbalance, + bool suppress_output, + int seed, + int mode, + // [outputs] + int* edgecut, + int* part +); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C b/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C index ea3ee98863f..aabfa95fee9 100644 --- a/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C +++ b/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C @@ -35,8 +35,7 @@ static const char* notImplementedMessage = "LD_LIBRARY_PATH.\n" "The metisDecomp library can then be built from " "src/parallel/decompose/metisDecomp and dynamically loading or linking" -" this library will add metis as a decomposition method.\n" -"Please be aware that there are license restrictions on using Metis."; +" this library will add metis as a decomposition method.\n"; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,12 +54,12 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::label Foam::metisDecomp::decompose +Foam::label Foam::metisDecomp::decomposeSerial ( - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cellWeights, - List<label>& finalDecomp + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cellWeights, + List<label>& decomp ) { FatalErrorInFunction @@ -77,53 +76,8 @@ Foam::metisDecomp::metisDecomp const dictionary& decompositionDict ) : - decompositionMethod(decompositionDict) + metisLikeDecomp(decompositionDict) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::metisDecomp::decompose -( - const polyMesh& mesh, - const pointField& points, - const scalarField& pointWeights -) -{ - FatalErrorInFunction - << notImplementedMessage << exit(FatalError); - - return labelList(); -} - - -Foam::labelList Foam::metisDecomp::decompose -( - const polyMesh& mesh, - const labelList& agglom, - const pointField& agglomPoints, - const scalarField& agglomWeights -) -{ - FatalErrorInFunction - << notImplementedMessage << exit(FatalError); - - return labelList(); -} - - -Foam::labelList Foam::metisDecomp::decompose -( - const labelListList& globalCellCells, - const pointField& cellCentres, - const scalarField& cellWeights -) -{ - FatalErrorInFunction - << notImplementedMessage << exit(FatalError); - - return labelList(); -} - - // ************************************************************************* // diff --git a/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C b/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C index 25287d72bef..d924b711b64 100644 --- a/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C +++ b/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C @@ -54,17 +54,19 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::ptscotchDecomp::graphPath(const polyMesh& unused) +{} + + void Foam::ptscotchDecomp::check(const int retVal, const char* str) {} Foam::label Foam::ptscotchDecomp::decompose ( - const fileName& meshPath, - const List<label>& initxadj, - const List<label>& initadjncy, - const scalarField& initcWeights, - + const UList<label>& initxadj, + const UList<label>& initadjncy, + const UList<scalar>& initcWeights, List<label>& finalDecomp ) const { @@ -77,12 +79,11 @@ Foam::label Foam::ptscotchDecomp::decompose Foam::label Foam::ptscotchDecomp::decompose ( - const fileName& meshPath, const label adjncySize, const label adjncy[], const label xadjSize, const label xadj[], - const scalarField& cWeights, + const UList<scalar>& cWeights, List<label>& finalDecomp ) const { diff --git a/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C b/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C index f1088d487bc..e5102774b5e 100644 --- a/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C +++ b/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C @@ -53,18 +53,20 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::scotchDecomp::graphPath(const polyMesh& unused) +{} + + void Foam::scotchDecomp::check(const int retVal, const char* str) {} -Foam::label Foam::scotchDecomp::decompose +Foam::label Foam::scotchDecomp::decomposeSerial ( - const fileName& meshPath, - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, - - List<label>& finalDecomp + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, + List<label>& decomp ) { FatalErrorInFunction @@ -81,7 +83,7 @@ Foam::scotchDecomp::scotchDecomp const dictionary& decompositionDict ) : - decompositionMethod(decompositionDict) + metisLikeDecomp(decompositionDict) {} diff --git a/src/parallel/decompose/Allwclean b/src/parallel/decompose/Allwclean index 88c606b523c..5fd3b3d4991 100755 --- a/src/parallel/decompose/Allwclean +++ b/src/parallel/decompose/Allwclean @@ -17,8 +17,9 @@ wcleanMpiLib() } -wclean scotchDecomp wclean metisDecomp +wclean kahipDecomp +wclean scotchDecomp wclean decompositionMethods wclean decompose wcleanMpiLib ptscotchDecomp diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index a90f705601b..19dced9e316 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -25,6 +25,54 @@ findFirstFile() } +# Test for kahip. +# - return 0 and export KAHIP_ARCH_PATH on success +hasKahip() +{ + local warning="==> skip kahip" + local header label settings + + unset KAHIP_ARCH_PATH KAHIP_VERSION + unset KAHIP_COMP_FLAGS KAHIP_LINK_FLAGS + settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip) || { + echo "$warning (no config.sh/kahip settings)" + return 1 + } + + . $settings + if [ -z "$KAHIP_ARCH_PATH" -o "${KAHIP_ARCH_PATH##*-}" = none ] + then + echo "$warning (not available)" + return 1 + fi + + # Header + header=$(findFirstFile \ + $KAHIP_ARCH_PATH/include/kaHIP_interface.h \ + /usr/include/kaHIP_interface.h \ + ) || { + echo "$warning (no header)" + return 2 # file not found + } + + # Library + [ "${KAHIP_ARCH_PATH##*-}" = system ] || \ + findFirstFile \ + $KAHIP_ARCH_PATH/lib/libkahip.a \ + $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libkahip.a \ + > /dev/null || { + echo "$warning (missing library)" + return 2 + } + + # kahip itself is 32-bit int, but our interface itself handles some + # 64-bit conversion (mesh size). + + export KAHIP_ARCH_PATH + echo "kahip (label=32) - $KAHIP_ARCH_PATH" +} + + # Test for metis. # - return 0 and export METIS_ARCH_PATH on success hasMetis() @@ -208,6 +256,11 @@ then wmake $targetType metisDecomp fi +if hasKahip +then + wmake $targetType kahipDecomp +fi + wmake $targetType decompositionMethods wmake $targetType decompose diff --git a/src/parallel/decompose/decompose/Make/files b/src/parallel/decompose/decompose/Make/files index 5fabd38ccef..225a27dfad8 100644 --- a/src/parallel/decompose/decompose/Make/files +++ b/src/parallel/decompose/decompose/Make/files @@ -1,3 +1,4 @@ +decompositionInformation.C decompositionModel.C fvFieldDecomposer.C diff --git a/src/parallel/decompose/decompose/decompositionInformation.C b/src/parallel/decompose/decompose/decompositionInformation.C new file mode 100644 index 00000000000..08f80d2cad7 --- /dev/null +++ b/src/parallel/decompose/decompose/decompositionInformation.C @@ -0,0 +1,236 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "decompositionInformation.H" +#include "ListOps.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::decompositionInformation::populate +( + const labelUList& adjncy, + const labelUList& xadj, + const labelUList& decomp, + const label nDomain +) +{ + nDomains_ = nDomain; + + distrib_.clear(); + distrib_.setSize(nDomain); + + for (labelList& subdist : distrib_) + { + subdist.clear(); + subdist.setSize(nDomain, Zero); + } + + const label nCells = xadj.size()-1; + for (label celli = 0; celli < nCells; ++celli) + { + const label ownProc = decomp[celli]; + + labelList& subdist = distrib_[ownProc]; + + // Number of cells + ++subdist[ownProc]; + + for (label i = xadj[celli]; i < xadj[celli+1]; ++i) + { + const label neiProc = decomp[adjncy[i]]; + + if (neiProc != ownProc) + { + // Number of processor faces + ++subdist[neiProc]; + } + } + } + + // Build summary + + labelList cellsCount(nDomains_, Zero); + labelList neighCount(nDomains_, Zero); + labelList facesCount(nDomains_, Zero); + + forAll(distrib_, ownProc) + { + const labelList& subdist = distrib_[ownProc]; + + cellsCount[ownProc] = subdist[ownProc]; + + forAll(subdist, neiProc) + { + const label n = subdist[neiProc]; + + if (n && ownProc != neiProc) + { + ++neighCount[ownProc]; + facesCount[ownProc] += n; + } + } + } + + const label n2 = (nDomains_ / 2); + + sort(cellsCount); + cellsInfo_.min = cellsCount.first(); + cellsInfo_.max = cellsCount.last(); + cellsInfo_.median = cellsCount[n2]; + + sort(neighCount); + neighInfo_.min = neighCount.first(); + neighInfo_.max = neighCount.last(); + neighInfo_.median = neighCount[n2]; + + sort(facesCount); + facesInfo_.min = facesCount.first(); + facesInfo_.max = facesCount.last(); + facesInfo_.median = facesCount[n2]; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::decompositionInformation::decompositionInformation +( + const labelUList& adjncy, + const labelUList& xadj, + const labelUList& decomp, + const label nDomains +) +: + distrib_(), + nDomains_(0) +{ + populate(adjncy, xadj, decomp, nDomains); +} + + +Foam::decompositionInformation::decompositionInformation +( + const CompactListList<label>& cellCells, + const labelUList& decomp, + const label nDomains +) +: + distrib_(), + nDomains_(0) +{ + populate(cellCells.m(), cellCells.offsets(), decomp, nDomains); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::decompositionInformation::clear() +{ + distrib_.clear(); + cellsInfo_.clear(); + neighInfo_.clear(); + facesInfo_.clear(); +} + + +void Foam::decompositionInformation::printSummary(Ostream& os) const +{ + os << "Cells "; cellsInfo_.print(os) << nl; + os << "Neigh "; neighInfo_.print(os)<< nl; + os << "Faces "; facesInfo_.print(os)<< nl; +} + + +void Foam::decompositionInformation::printDetails(Ostream& os) const +{ + forAll(distrib_, ownProc) + { + const labelList& subdist = distrib_[ownProc]; + + // First pass: + label neighCount = 0; + label facesCount = 0; + + forAll(subdist, neiProc) + { + const label n = subdist[neiProc]; + + if (n && ownProc != neiProc) + { + ++neighCount; + facesCount += n; + } + } + + os << "Part[" << ownProc << "] cells:" << subdist[ownProc] + << " neigh:" << neighCount + << " faces:" << facesCount; + + // Second pass with details: + if (facesCount) + { + Info<< " "; + + forAll(subdist, neiProc) + { + const label n = subdist[neiProc]; + + if (n && ownProc != neiProc) + { + os << " (" << neiProc << " " << n << ")"; + } + } + } + + os << nl; + } +} + + +void Foam::decompositionInformation::printAll(Ostream& os) const +{ + printDetails(os); + printSummary(os); +} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + + +Foam::Ostream& Foam::decompositionInformation::stats::print(Ostream& os) const +{ + os << "max/median/min: " + << this->max << " / " << this->median << " / " << this->min; + + if (this->median) + { + const scalar ratio = scalar(100*this->max)/this->median; + + os << " (" << ratio << "%)"; + } + + return os; +} + +// ************************************************************************* // diff --git a/src/parallel/decompose/decompose/decompositionInformation.H b/src/parallel/decompose/decompose/decompositionInformation.H new file mode 100644 index 00000000000..c0f24bb2cf3 --- /dev/null +++ b/src/parallel/decompose/decompose/decompositionInformation.H @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::decompositionInformation + +Description + Abstract base class for decomposition + +SourceFiles + decompositionInformation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef decompositionInformation_H +#define decompositionInformation_H + +#include "polyMesh.H" +#include "CompactListList.H" +#include "IOstreams.H" + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class decompositionInformation Declaration +\*---------------------------------------------------------------------------*/ + +class decompositionInformation +{ + //- Simple storage for organizing min/max/median quantities + struct stats + { + label min; + label max; + label median; + + stats() : min(0), max(0), median(0) {} + + void clear() + { + min = 0; + max = 0; + median = 0; + } + + Ostream& print(Ostream& os) const; + }; + + // Private data + + labelListList distrib_; + label nDomains_; + + stats cellsInfo_; + stats neighInfo_; + stats facesInfo_; + + + // Private Member Functions + + //- Populate from cell decomposition list + void populate + ( + const labelUList& adjncy, + const labelUList& xadj, + const labelUList& decomp, + const label nDomains + ); + + //- Disallow default bitwise copy construct and assignment + decompositionInformation(const decompositionInformation&) = delete; + void operator=(const decompositionInformation&) = delete; + + +public: + + // Constructors + + //- Construct + decompositionInformation + ( + const labelUList& adjncy, + const labelUList& xadj, + const labelUList& decomp, + const label nDomains + ); + + //- Construct + decompositionInformation + ( + const CompactListList<label>& cellCells, + const labelUList& decomp, + const label nDomains + ); + + + //- Destructor + ~decompositionInformation() + {} + + + // Member Functions + + void clear(); + + label nDomains() const + { + return nDomains_; + } + + + void printSummary(Ostream& os) const; + + void printDetails(Ostream& os) const; + + void printAll(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/parallel/decompose/decompositionMethods/Make/files b/src/parallel/decompose/decompositionMethods/Make/files index 2aef948ff7a..0bae18c40d6 100644 --- a/src/parallel/decompose/decompositionMethods/Make/files +++ b/src/parallel/decompose/decompositionMethods/Make/files @@ -4,6 +4,7 @@ simpleGeomDecomp/simpleGeomDecomp.C hierarchGeomDecomp/hierarchGeomDecomp.C manualDecomp/manualDecomp.C multiLevelDecomp/multiLevelDecomp.C +metisLikeDecomp/metisLikeDecomp.C structuredDecomp/structuredDecomp.C noDecomp/noDecomp.C diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index a66acf8dbd3..f03667084ed 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -21,9 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -InClass - decompositionMethod - \*---------------------------------------------------------------------------*/ #include "decompositionMethod.H" @@ -49,6 +46,7 @@ namespace Foam defineRunTimeSelectionTable(decompositionMethod, dictionary); } + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::decompositionMethod::decompositionMethod @@ -349,8 +347,8 @@ void Foam::decompositionMethod::calcCellCells for (label facei = 0; facei < mesh.nInternalFaces(); facei++) { - label own = agglom[faceOwner[facei]]; - label nei = agglom[faceNeighbour[facei]]; + const label own = agglom[faceOwner[facei]]; + const label nei = agglom[faceNeighbour[facei]]; nFacesPerCell[own]++; nFacesPerCell[nei]++; @@ -367,7 +365,7 @@ void Foam::decompositionMethod::calcCellCells forAll(pp, i) { - label own = agglom[faceOwner[facei]]; + const label own = agglom[faceOwner[facei]]; label globalNei = globalNeighbour[bFacei]; if @@ -399,8 +397,8 @@ void Foam::decompositionMethod::calcCellCells // For internal faces is just offsetted owner and neighbour for (label facei = 0; facei < mesh.nInternalFaces(); facei++) { - label own = agglom[faceOwner[facei]]; - label nei = agglom[faceNeighbour[facei]]; + const label own = agglom[faceOwner[facei]]; + const label nei = agglom[faceNeighbour[facei]]; m[offsets[own] + nFacesPerCell[own]++] = globalAgglom.toGlobal(nei); m[offsets[nei] + nFacesPerCell[nei]++] = globalAgglom.toGlobal(own); @@ -418,9 +416,9 @@ void Foam::decompositionMethod::calcCellCells forAll(pp, i) { - label own = agglom[faceOwner[facei]]; + const label own = agglom[faceOwner[facei]]; - label globalNei = globalNeighbour[bFacei]; + const label globalNei = globalNeighbour[bFacei]; if ( @@ -457,7 +455,7 @@ void Foam::decompositionMethod::calcCellCells nbrCells.clear(); nbrCells.insert(globalAgglom.toGlobal(celli)); - label endIndex = cellCells.offsets()[celli+1]; + const label endIndex = cellCells.offsets()[celli+1]; for (label i = startIndex; i < endIndex; i++) { @@ -555,8 +553,8 @@ void Foam::decompositionMethod::calcCellCells for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) { - label own = agglom[faceOwner[faceI]]; - label nei = agglom[faceNeighbour[faceI]]; + const label own = agglom[faceOwner[faceI]]; + const label nei = agglom[faceNeighbour[faceI]]; nFacesPerCell[own]++; nFacesPerCell[nei]++; @@ -573,9 +571,9 @@ void Foam::decompositionMethod::calcCellCells forAll(pp, i) { - label own = agglom[faceOwner[faceI]]; + const label own = agglom[faceOwner[faceI]]; - label globalNei = globalNeighbour[bFaceI]; + const label globalNei = globalNeighbour[bFaceI]; if ( !globalAgglom.isLocal(globalNei) @@ -607,11 +605,11 @@ void Foam::decompositionMethod::calcCellCells // For internal faces is just offsetted owner and neighbour for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) { - label own = agglom[faceOwner[faceI]]; - label nei = agglom[faceNeighbour[faceI]]; + const label own = agglom[faceOwner[faceI]]; + const label nei = agglom[faceNeighbour[faceI]]; - label ownIndex = offsets[own] + nFacesPerCell[own]++; - label neiIndex = offsets[nei] + nFacesPerCell[nei]++; + const label ownIndex = offsets[own] + nFacesPerCell[own]++; + const label neiIndex = offsets[nei] + nFacesPerCell[nei]++; m[ownIndex] = globalAgglom.toGlobal(nei); w[ownIndex] = mag(mesh.faceAreas()[faceI]); @@ -631,9 +629,9 @@ void Foam::decompositionMethod::calcCellCells forAll(pp, i) { - label own = agglom[faceOwner[faceI]]; + const label own = agglom[faceOwner[faceI]]; - label globalNei = globalNeighbour[bFaceI]; + const label globalNei = globalNeighbour[bFaceI]; if ( @@ -672,7 +670,7 @@ void Foam::decompositionMethod::calcCellCells nbrCells.clear(); nbrCells.insert(globalAgglom.toGlobal(cellI)); - label endIndex = cellCells.offsets()[cellI+1]; + const label endIndex = cellCells.offsets()[cellI+1]; for (label i = startIndex; i < endIndex; i++) { diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H index 9a8a3a1f1ce..75a797e1aee 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. diff --git a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C new file mode 100644 index 00000000000..a5dffec83c0 --- /dev/null +++ b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C @@ -0,0 +1,264 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "metisLikeDecomp.H" +#include "Time.H" +#include "globalIndex.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +Foam::label Foam::metisLikeDecomp::decomposeGeneral +( + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, + List<label>& decomp +) +{ + if (!Pstream::parRun()) + { + return decomposeSerial + ( + adjncy, + xadj, + cWeights, + decomp + ); + } + + if (debug) + { + Info<< type() << "Decomp : running in parallel." + << " Decomposing all of graph on master processor." << endl; + } + globalIndex globalCells(xadj.size()-1); + label nTotalConnections = returnReduce(adjncy.size(), sumOp<label>()); + + // Send all to master. Use scheduled to save some storage. + if (Pstream::master()) + { + List<label> allAdjncy(nTotalConnections); + List<label> allXadj(globalCells.size()+1); + List<scalar> allWeights(globalCells.size()); + + // Insert my own + label nTotalCells = 0; + forAll(cWeights, celli) + { + allXadj[nTotalCells] = xadj[celli]; + allWeights[nTotalCells++] = cWeights[celli]; + } + nTotalConnections = 0; + forAll(adjncy, i) + { + allAdjncy[nTotalConnections++] = adjncy[i]; + } + + for (int slave=1; slave<Pstream::nProcs(); ++slave) + { + IPstream fromSlave(Pstream::commsTypes::scheduled, slave); + List<label> nbrAdjncy(fromSlave); + List<label> nbrXadj(fromSlave); + List<scalar> nbrWeights(fromSlave); + + // Append. + forAll(nbrXadj, celli) + { + allXadj[nTotalCells] = nTotalConnections+nbrXadj[celli]; + allWeights[nTotalCells++] = nbrWeights[celli]; + } + // No need to renumber xadj since already global. + forAll(nbrAdjncy, i) + { + allAdjncy[nTotalConnections++] = nbrAdjncy[i]; + } + } + allXadj[nTotalCells] = nTotalConnections; + + labelList allDecomp; + decomposeSerial + ( + allAdjncy, + allXadj, + allWeights, + allDecomp + ); + + + // Send allFinalDecomp back + for (int slave=1; slave<Pstream::nProcs(); ++slave) + { + OPstream toSlave(Pstream::commsTypes::scheduled, slave); + toSlave << SubList<label> + ( + allDecomp, + globalCells.localSize(slave), + globalCells.offset(slave) + ); + } + + // Get my own part (always first) + decomp = SubList<label>(allDecomp, globalCells.localSize()); + } + else + { + // Send my part of the graph (already in global numbering) + { + OPstream toMaster + ( + Pstream::commsTypes::scheduled, + Pstream::masterNo() + ); + toMaster<< adjncy << SubList<label>(xadj, xadj.size()-1) + << cWeights; + } + + // Receive back decomposition + IPstream fromMaster + ( + Pstream::commsTypes::scheduled, + Pstream::masterNo() + ); + fromMaster >> decomp; + } + + return 0; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::metisLikeDecomp::metisLikeDecomp(const dictionary& decompositionDict) +: + decompositionMethod(decompositionDict) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::labelList Foam::metisLikeDecomp::decompose +( + const polyMesh& mesh, + const pointField& points, + const scalarField& pointWeights +) +{ + if (points.size() != mesh.nCells()) + { + FatalErrorInFunction + << "Can use this decomposition method only for entire mesh" << nl + << "and supply one coordinate (cellCentre) for every cell." << nl + << "The number of coordinates " << points.size() << nl + << "The number of cells in the mesh " << mesh.nCells() + << exit(FatalError); + } + + CompactListList<label> cellCells; + calcCellCells + ( + mesh, + identity(mesh.nCells()), + mesh.nCells(), + false, + cellCells + ); + + // Decompose using default weights + labelList decomp; + decomposeGeneral(cellCells.m(), cellCells.offsets(), pointWeights, decomp); + + return decomp; +} + + +Foam::labelList Foam::metisLikeDecomp::decompose +( + const polyMesh& mesh, + const labelList& agglom, + const pointField& agglomPoints, + const scalarField& agglomWeights +) +{ + if (agglom.size() != mesh.nCells()) + { + FatalErrorInFunction + << "Size of cell-to-coarse map " << agglom.size() + << " differs from number of cells in mesh " << mesh.nCells() + << exit(FatalError); + } + + // Make Metis CSR (Compressed Storage Format) storage + // adjncy : contains neighbours (= edges in graph) + // xadj(celli) : start of information in adjncy for celli + + CompactListList<label> cellCells; + calcCellCells(mesh, agglom, agglomPoints.size(), false, cellCells); + + // Decompose using default weights + labelList decomp; + decomposeGeneral(cellCells.m(), cellCells.offsets(), agglomWeights, decomp); + + + // Rework back into decomposition for original mesh + labelList fineDistribution(agglom.size()); + + forAll(fineDistribution, i) + { + fineDistribution[i] = decomp[agglom[i]]; + } + + return fineDistribution; +} + + +Foam::labelList Foam::metisLikeDecomp::decompose +( + const labelListList& globalCellCells, + const pointField& cellCentres, + const scalarField& cellWeights +) +{ + if (cellCentres.size() != globalCellCells.size()) + { + FatalErrorInFunction + << "Inconsistent number of cells (" << globalCellCells.size() + << ") and number of cell centres (" << cellCentres.size() + << ")." << exit(FatalError); + } + + // Make Metis CSR (Compressed Storage Format) storage + // adjncy : contains neighbours (= edges in graph) + // xadj(celli) : start of information in adjncy for celli + + CompactListList<label> cellCells(globalCellCells); + + // Decompose using default weights + labelList decomp; + decomposeGeneral(cellCells.m(), cellCells.offsets(), cellWeights, decomp); + + return decomp; +} + +// ************************************************************************* // diff --git a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.H b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.H new file mode 100644 index 00000000000..8c8a6c9e87f --- /dev/null +++ b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.H @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::metisLikeDecomp + +Description + Domain decomposition using METIS-like data structures. + + When run in parallel will collect the entire graph on to the master, + decompose and send back. + +SourceFiles + metisLikeDecomp.C + +\*---------------------------------------------------------------------------*/ + +#ifndef metisLikeDecomp_H +#define metisLikeDecomp_H + +#include "decompositionMethod.H" + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class metisLikeDecomp Declaration +\*---------------------------------------------------------------------------*/ + +class metisLikeDecomp +: + public decompositionMethod +{ + // Private Member Functions + + //- Disallow default bitwise copy construct and assignment + void operator=(const metisLikeDecomp&) = delete; + metisLikeDecomp(const metisLikeDecomp&) = delete; + + +protected: + + // Protected Member Functions + + //- Serial and/or collect/distribute for parallel operation + virtual label decomposeGeneral + ( + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cellWeights, + List<label>& decomp + ); + + //- Decomposition with metis-like parameters + virtual label decomposeSerial + ( + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cellWeights, + List<label>& decomp + ) = 0; + +public: + + // Constructors + + //- Construct given the decomposition dictionary + metisLikeDecomp(const dictionary& decompositionDict); + + + //- Destructor + virtual ~metisLikeDecomp() + {} + + + // Member Functions + + //- Inherit decompose from decompositionMethod + using decompositionMethod::decompose; + + //- Return for every coordinate the wanted processor number. + // Uses the mesh connectivity (if needed). + // Weights get normalised so the minimum value is 1 before truncation + // to an integer so the weights should be multiples of the minimum + // value. The overall sum of weights might otherwise overflow. + virtual labelList decompose + ( + const polyMesh& mesh, + const pointField& points, + const scalarField& pointWeights + ); + + //- Return for every coordinate the wanted processor number. + // Gets passed agglomeration map (from fine to coarse cells) and coarse + // cell location. Can be overridden by decomposers that provide this + // functionality natively. + // See note on weights above. + virtual labelList decompose + ( + const polyMesh& mesh, + const labelList& agglom, + const pointField& regionPoints, + const scalarField& regionWeights + ); + + //- Return for every coordinate the wanted processor number. + // Explicitly provided mesh connectivity. + // The connectivity is equal to mesh.cellCells() except for + // - in parallel the cell numbers are global cell numbers (starting + // from 0 at processor0 and then incrementing all through the + // processors) + // - the connections are across coupled patches + // See note on weights above. + virtual labelList decompose + ( + const labelListList& globalCellCells, + const pointField& cellCentres, + const scalarField& cellWeights + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/parallel/decompose/kahipDecomp/Make/files b/src/parallel/decompose/kahipDecomp/Make/files new file mode 100644 index 00000000000..eb01da59a36 --- /dev/null +++ b/src/parallel/decompose/kahipDecomp/Make/files @@ -0,0 +1,3 @@ +kahipDecomp.C + +LIB = $(FOAM_LIBBIN)/libkahipDecomp diff --git a/src/parallel/decompose/kahipDecomp/Make/options b/src/parallel/decompose/kahipDecomp/Make/options new file mode 100644 index 00000000000..9c746b309c7 --- /dev/null +++ b/src/parallel/decompose/kahipDecomp/Make/options @@ -0,0 +1,13 @@ +EXE_INC = \ + -I$(KAHIP_ARCH_PATH)/include \ + -I../decompositionMethods/lnInclude \ + $(KAHIP_COMP_FLAGS) + +/* + * The $(KAHIP_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided + * to support central, non-thirdparty installations + */ +LIB_LIBS = \ + -L$(KAHIP_ARCH_PATH)/lib \ + -L$(KAHIP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -L$(FOAM_EXT_LIBBIN) $(KAHIP_LINK_FLAGS) -lkahip diff --git a/src/parallel/decompose/kahipDecomp/kahipDecomp.C b/src/parallel/decompose/kahipDecomp/kahipDecomp.C new file mode 100644 index 00000000000..180f8783e04 --- /dev/null +++ b/src/parallel/decompose/kahipDecomp/kahipDecomp.C @@ -0,0 +1,329 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "kahipDecomp.H" +#include "addToRunTimeSelectionTable.H" +#include "Time.H" + +#include "kaHIP_interface.h" + +#include <string> +#include <map> +#include <vector> + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(kahipDecomp, 0); + addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary); +} + + +const Foam::Enum +< + Foam::kahipDecomp::configs +> +Foam::kahipDecomp::configNames +{ + { kahipDecomp::configs::FAST, "fast" }, + { kahipDecomp::configs::ECO, "eco" }, + { kahipDecomp::configs::STRONG, "strong" }, + { kahipDecomp::configs::FASTSOCIAL, "fast-social" }, + { kahipDecomp::configs::ECOSOCIAL, "eco-social" }, + { kahipDecomp::configs::STRONGSOCIAL, "strong-social" }, +}; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::label Foam::kahipDecomp::decomposeSerial +( + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, + List<label>& decomp +) +{ + // Default setup + enum configs kahipConfig = configs::FAST; + double imbalance = 0.01; + int seed = 0; + bool verbose = false; + + const dictionary* coeffsDictPtr = + decompositionDict_.subDictPtr("kahipCoeffs"); + + #if WM_LABEL_SIZE == 64 + if (xadj.size()-1 > INT_MAX) + { + FatalErrorInFunction + << "Cannot decompose " << (xadj.size()-1) << " cells," << nl + << "Exceeded integer limit of " << INT_MAX << nl + << exit(FatalError); + } + #endif + + int numCells = xadj.size()-1; + + // Cell weights (so on the vertices of the dual) + List<int> cellWeights; + + // Check for externally provided cellweights and if so initialise weights + const scalar minWeights = gMin(cWeights); + if (!cWeights.empty()) + { + if (minWeights <= 0) + { + WarningInFunction + << "Illegal minimum weight " << minWeights + << endl; + } + + if (cWeights.size() != numCells) + { + FatalErrorInFunction + << "Number of cell weights " << cWeights.size() + << " does not equal number of cells " << numCells + << exit(FatalError); + } + + // Convert to integers. + cellWeights.setSize(cWeights.size()); + forAll(cellWeights, i) + { + cellWeights[i] = int(cWeights[i]/minWeights); + } + } + + // Additional sizing parameters (testing only) + std::map<std::string, std::vector<int>> sizingParams; + + // Check for user supplied weights and decomp options + if (coeffsDictPtr) + { + const dictionary& coeffDict = *coeffsDictPtr; + + //- Find the key in the dictionary and return the corresponding + // enumeration element based on its name. + // Return the default value if the key was not found in the dictionary. + // Fatal if the enumerated name was incorrect. + + kahipConfig = + configNames.lookupOrDefault("config", coeffDict, kahipConfig); + + coeffDict.readIfPresent("imbalance", imbalance); + coeffDict.readIfPresent("verbose", verbose); + + Info<< "kahipDecomp :" + << " config=" << configNames[kahipConfig] + << " imbalance=" << imbalance; + + List<int> labels; + if + ( + coeffDict.readIfPresent("hierarchy", labels) + && !labels.empty() + ) + { + std::vector<int> vec; + vec.reserve(labels.size()+1); + + // Verify sizing + + int n = 1; + for (auto val : labels) + { + n *= val; + vec.push_back(val); + } + + if (n != nProcessors_) + { + // Size mismatch. Try to correct. + + if (nProcessors_ % n) + { + WarningInFunction + << "Mismatch in number of processors and " + << "hierarchy specified" << flatOutput(labels) << endl; + + vec.clear(); + } + else + { + // Evenly divisible, add extra hierarchy level + vec.push_back(nProcessors_ / n); + } + } + + if (!vec.empty()) + { + sizingParams["hierarchy"] = std::move(vec); + + Info<< " hierarchy=" << flatOutput(labels); + } + } + + if + ( + coeffDict.readIfPresent("distance", labels) + && !labels.empty() + ) + { + std::vector<int> vec(labels.size()); + + forAll(labels, i) + { + vec[i] = labels[i]; + } + + sizingParams["distance"] = std::move(vec); + + Info<< " distance=" << flatOutput(labels); + } + + if (coeffDict.readIfPresent("seed", seed)) + { + Info<< " seed=" << seed; + } + + Info<< endl; + } + else + { + Info<< "kahipDecomp :" + << " config=" << configNames[kahipConfig] + << " imbalance=" << imbalance << endl; + } + + // Number of partitions + int nParts = nProcessors_; + + // Output: number of cut edges + int edgeCut = 0; + + #if WM_LABEL_SIZE == 32 + + // Input: + int* xadjPtr = const_cast<UList<int>&>(xadj).begin(); + int* adjncyPtr = const_cast<UList<int>&>(adjncy).begin(); + + // Output: cell -> processor addressing + decomp.setSize(numCells); + int* decompPtr = decomp.begin(); + + #elif WM_LABEL_SIZE == 64 + + // input (copy) + List<int> xadjCopy(xadj.size()); + List<int> adjncyCopy(adjncy.size()); + + forAll(xadj,i) + { + xadjCopy[i] = xadj[i]; + } + forAll(adjncy,i) + { + adjncyCopy[i] = adjncy[i]; + } + + int* xadjPtr = xadjCopy.begin(); + int* adjncyPtr = adjncyCopy.begin(); + + if (decomp.size() != numCells) + { + decomp.clear(); + } + + // Output: cell -> processor addressing + List<int> decompCopy(numCells); + int* decompPtr = decompCopy.begin(); + #endif + +#if 0 // WIP: #ifdef KAFFPA_CPP_INTERFACE + kaffpa_cpp + ( + &numCells, // num vertices in graph + (cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts + xadjPtr, // indexing into adjncy + nullptr, // edge wts + adjncyPtr, // neighbour info + &nParts, // nparts + &imbalance, // amount of imbalance allowed + !verbose, // suppress output + seed, // for random + int(kahipConfig), + &edgeCut, // [output] + decompPtr, // [output] + sizingParams + ); +#else + kaffpa + ( + &numCells, // num vertices in graph + (cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts + xadjPtr, // indexing into adjncy + nullptr, // edge wts + adjncyPtr, // neighbour info + &nParts, // nparts + &imbalance, // amount of imbalance allowed + !verbose, // suppress output + seed, // for random + int(kahipConfig), + &edgeCut, // [output] + decompPtr // [output] + ); +#endif + + #if WM_LABEL_SIZE == 64 + + // Drop input copy + xadjCopy.clear(); + adjncyCopy.clear(); + + // Copy back to List<label> + decomp.setSize(numCells); + forAll(decompCopy, i) + { + decomp[i] = decompCopy[i]; + } + + decompCopy.clear(); + #endif + + return edgeCut; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::kahipDecomp::kahipDecomp(const dictionary& decompositionDict) +: + metisLikeDecomp(decompositionDict) +{} + + +// ************************************************************************* // diff --git a/src/parallel/decompose/kahipDecomp/kahipDecomp.H b/src/parallel/decompose/kahipDecomp/kahipDecomp.H new file mode 100644 index 00000000000..37cd4b574c6 --- /dev/null +++ b/src/parallel/decompose/kahipDecomp/kahipDecomp.H @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::kahipDecomp + +Description + Domain decomposition using KaHIP + http://algo2.iti.kit.edu/documents/kahip/ + + When run in parallel will collect the entire graph on to the master, + decompose and send back. + + \verbatim + numberOfSubdomains N; + method kahip; + + kahipCoeffs + { + config fast; + imbalance 0.01; + } + \endverbatim + + Where the coefficients dictionary is optional, as are all its entries: + \table + Property | Description | Default value + config | fast / eco / strong | fast + imbalance | imbalance on cells between domains | 0.01 + seed | initial value for random number generator | 0 + \endtable + +SourceFiles + kahipDecomp.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kahipDecomp_H +#define kahipDecomp_H + +#include "metisLikeDecomp.H" +#include "Enum.H" + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class kahipDecomp Declaration +\*---------------------------------------------------------------------------*/ + +class kahipDecomp +: + public metisLikeDecomp +{ + + // Private Member Functions + + //- Call kahip with options from dictionary. + virtual label decomposeSerial + ( + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cellWeights, + List<label>& decomp + ); + + //- Disallow default bitwise copy construct and assignment + void operator=(const kahipDecomp&) = delete; + kahipDecomp(const kahipDecomp&) = delete; + + +public: + + //- The predefined KaHIP configuration types + enum class configs + { + FAST = 0, //!< default + ECO = 1, + STRONG = 2, + FASTSOCIAL = 3, + ECOSOCIAL = 4, + STRONGSOCIAL = 5, + }; + + + //- The selection names for predefined KaHIP configurations + static const Enum<configs> configNames; + + + //- Runtime type information + TypeName("kahip"); + + + // Constructors + + //- Construct given the decomposition dictionary + kahipDecomp(const dictionary& decompositionDict); + + + //- Destructor + virtual ~kahipDecomp() + {} + + + // Member Functions + + virtual bool parallelAware() const + { + return true; + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.C b/src/parallel/decompose/metisDecomp/metisDecomp.C index 2cb09cbb77c..cfc896d2518 100644 --- a/src/parallel/decompose/metisDecomp/metisDecomp.C +++ b/src/parallel/decompose/metisDecomp/metisDecomp.C @@ -45,13 +45,12 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::label Foam::metisDecomp::decompose +Foam::label Foam::metisDecomp::decomposeSerial ( - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, - - List<label>& finalDecomp + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, + List<label>& decomp ) { // Method of decomposition @@ -59,6 +58,9 @@ Foam::label Foam::metisDecomp::decompose // k-way: multi-level k-way word method("recursive"); + const dictionary* coeffsDictPtr = + decompositionDict_.subDictPtr("metisCoeffs"); + label numCells = xadj.size()-1; // Decomposition options @@ -77,7 +79,7 @@ Foam::label Foam::metisDecomp::decompose // Check for externally provided cellweights and if so initialise weights - scalar minWeights = gMin(cWeights); + const scalar minWeights = gMin(cWeights); if (cWeights.size() > 0) { if (minWeights <= 0) @@ -105,14 +107,13 @@ Foam::label Foam::metisDecomp::decompose // Check for user supplied weights and decomp options - if (decompositionDict_.found("metisCoeffs")) + if (coeffsDictPtr) { - const dictionary& metisCoeffs = - decompositionDict_.subDict("metisCoeffs"); + const dictionary& coeffDict = *coeffsDictPtr; word weightsFile; - if (metisCoeffs.readIfPresent("method", method)) + if (coeffDict.readIfPresent("method", method)) { if (method != "recursive" && method != "k-way") { @@ -127,7 +128,7 @@ Foam::label Foam::metisDecomp::decompose << nl << endl; } - if (metisCoeffs.readIfPresent("options", options)) + if (coeffDict.readIfPresent("options", options)) { if (options.size() != METIS_NOPTIONS) { @@ -142,7 +143,7 @@ Foam::label Foam::metisDecomp::decompose << nl << endl; } - if (metisCoeffs.readIfPresent("processorWeights", processorWeights)) + if (coeffDict.readIfPresent("processorWeights", processorWeights)) { processorWeights /= sum(processorWeights); @@ -161,7 +162,7 @@ Foam::label Foam::metisDecomp::decompose label nProcs = nProcessors_; // Output: cell -> processor addressing - finalDecomp.setSize(numCells); + decomp.setSize(numCells); // Output: number of cut edges label edgeCut = 0; @@ -172,17 +173,17 @@ Foam::label Foam::metisDecomp::decompose ( &numCells, // num vertices in graph &ncon, // num balancing constraints - const_cast<List<label>&>(xadj).begin(), // indexing into adjncy - const_cast<List<label>&>(adjncy).begin(), // neighbour info - cellWeights.begin(),// vertexweights + const_cast<UList<label>&>(xadj).begin(), // indexing into adjncy + const_cast<UList<label>&>(adjncy).begin(), // neighbour info + cellWeights.begin(),// vertex wts nullptr, // vsize: total communication vol - faceWeights.begin(),// edgeweights + faceWeights.begin(),// edge wts &nProcs, // nParts processorWeights.begin(), // tpwgts nullptr, // ubvec: processor imbalance (default) options.begin(), &edgeCut, - finalDecomp.begin() + decomp.begin() ); } else @@ -191,17 +192,17 @@ Foam::label Foam::metisDecomp::decompose ( &numCells, // num vertices in graph &ncon, // num balancing constraints - const_cast<List<label>&>(xadj).begin(), // indexing into adjncy - const_cast<List<label>&>(adjncy).begin(), // neighbour info - cellWeights.begin(),// vertexweights + const_cast<UList<label>&>(xadj).begin(), // indexing into adjncy + const_cast<UList<label>&>(adjncy).begin(), // neighbour info + cellWeights.begin(),// vertex wts nullptr, // vsize: total communication vol - faceWeights.begin(),// edgeweights + faceWeights.begin(),// edge wts &nProcs, // nParts processorWeights.begin(), // tpwgts nullptr, // ubvec: processor imbalance (default) options.begin(), &edgeCut, - finalDecomp.begin() + decomp.begin() ); } @@ -213,116 +214,8 @@ Foam::label Foam::metisDecomp::decompose Foam::metisDecomp::metisDecomp(const dictionary& decompositionDict) : - decompositionMethod(decompositionDict) + metisLikeDecomp(decompositionDict) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::metisDecomp::decompose -( - const polyMesh& mesh, - const pointField& points, - const scalarField& pointWeights -) -{ - if (points.size() != mesh.nCells()) - { - FatalErrorInFunction - << "Can use this decomposition method only for the whole mesh" - << endl - << "and supply one coordinate (cellCentre) for every cell." << endl - << "The number of coordinates " << points.size() << endl - << "The number of cells in the mesh " << mesh.nCells() - << exit(FatalError); - } - - CompactListList<label> cellCells; - calcCellCells - ( - mesh, - identity(mesh.nCells()), - mesh.nCells(), - false, - cellCells - ); - - // Decompose using default weights - labelList decomp; - decompose(cellCells.m(), cellCells.offsets(), pointWeights, decomp); - - return decomp; -} - - -Foam::labelList Foam::metisDecomp::decompose -( - const polyMesh& mesh, - const labelList& agglom, - const pointField& agglomPoints, - const scalarField& agglomWeights -) -{ - if (agglom.size() != mesh.nCells()) - { - FatalErrorInFunction - << "Size of cell-to-coarse map " << agglom.size() - << " differs from number of cells in mesh " << mesh.nCells() - << exit(FatalError); - } - - // Make Metis CSR (Compressed Storage Format) storage - // adjncy : contains neighbours (= edges in graph) - // xadj(celli) : start of information in adjncy for celli - - CompactListList<label> cellCells; - calcCellCells(mesh, agglom, agglomPoints.size(), false, cellCells); - - // Decompose using default weights - labelList finalDecomp; - decompose(cellCells.m(), cellCells.offsets(), agglomWeights, finalDecomp); - - - // Rework back into decomposition for original mesh - labelList fineDistribution(agglom.size()); - - forAll(fineDistribution, i) - { - fineDistribution[i] = finalDecomp[agglom[i]]; - } - - return fineDistribution; -} - - -Foam::labelList Foam::metisDecomp::decompose -( - const labelListList& globalCellCells, - const pointField& cellCentres, - const scalarField& cellWeights -) -{ - if (cellCentres.size() != globalCellCells.size()) - { - FatalErrorInFunction - << "Inconsistent number of cells (" << globalCellCells.size() - << ") and number of cell centres (" << cellCentres.size() - << ")." << exit(FatalError); - } - - - // Make Metis CSR (Compressed Storage Format) storage - // adjncy : contains neighbours (= edges in graph) - // xadj(celli) : start of information in adjncy for celli - - CompactListList<label> cellCells(globalCellCells); - - // Decompose using default weights - labelList decomp; - decompose(cellCells.m(), cellCells.offsets(), cellWeights, decomp); - - return decomp; -} - - // ************************************************************************* // diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.H b/src/parallel/decompose/metisDecomp/metisDecomp.H index 84dc04bd938..a851b0496b5 100644 --- a/src/parallel/decompose/metisDecomp/metisDecomp.H +++ b/src/parallel/decompose/metisDecomp/metisDecomp.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,29 @@ Class Description Metis domain decomposition + When run in parallel will collect the entire graph on to the master, + decompose and send back. + + \verbatim + numberOfSubdomains N; + method metis; + + metisCoeffs + { + method recursive; // k-way + options ( ...); + processorWeights ( ... ); + } + \endverbatim + + Where the coefficients dictionary is optional, as are all its entries: + \table + Property | Description | Default value + method | recursive / k-way | recursive + options | metis options | + processorWeights | list of weighting per partition | + \endtable + SourceFiles metisDecomp.C @@ -35,7 +58,7 @@ SourceFiles #ifndef metisDecomp_H #define metisDecomp_H -#include "decompositionMethod.H" +#include "metisLikeDecomp.H" namespace Foam { @@ -46,23 +69,23 @@ namespace Foam class metisDecomp : - public decompositionMethod + public metisLikeDecomp { // Private Member Functions //- Call Metis with options from dictionary. - label decompose + virtual label decomposeSerial ( - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cellWeights, - List<label>& finalDecomp + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cellWeights, + List<label>& decomp ); //- Disallow default bitwise copy construct and assignment - void operator=(const metisDecomp&); - metisDecomp(const metisDecomp&); + void operator=(const metisDecomp&) = delete; + metisDecomp(const metisDecomp&) = delete; public: @@ -74,7 +97,7 @@ public: // Constructors //- Construct given the decomposition dictionary - metisDecomp(const dictionary&); + metisDecomp(const dictionary& decompositionDict); //- Destructor @@ -86,52 +109,9 @@ public: virtual bool parallelAware() const { - // Metis does not know about proc boundaries - return false; + return true; } - //- Inherit decompose from decompositionMethod - using decompositionMethod::decompose; - - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) - // Weights get normalised so the minimum value is 1 before truncation - // to an integer so the weights should be multiples of the minimum - // value. The overall sum of weights might otherwise overflow. - virtual labelList decompose - ( - const polyMesh& mesh, - const pointField& points, - const scalarField& pointWeights - ); - - //- Return for every coordinate the wanted processor number. Gets - // passed agglomeration map (from fine to coarse cells) and coarse cell - // location. Can be overridden by decomposers that provide this - // functionality natively. - // See note on weights above. - virtual labelList decompose - ( - const polyMesh& mesh, - const labelList& agglom, - const pointField& regionPoints, - const scalarField& regionWeights - ); - - //- Return for every coordinate the wanted processor number. Explicitly - // provided mesh connectivity. - // The connectivity is equal to mesh.cellCells() except for - // - in parallel the cell numbers are global cell numbers (starting - // from 0 at processor0 and then incrementing all through the - // processors) - // - the connections are across coupled patches - // See note on weights above. - virtual labelList decompose - ( - const labelListList& globalCellCells, - const pointField& cc, - const scalarField& cWeights - ); }; diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C index d0035de8d8b..95b8647ee4a 100644 --- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C +++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -228,12 +228,17 @@ License namespace Foam { defineTypeNameAndDebug(ptscotchDecomp, 0); - addToRunTimeSelectionTable(decompositionMethod, ptscotchDecomp, dictionary); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::ptscotchDecomp::graphPath(const polyMesh& mesh) +{ + graphPath_ = mesh.time().path()/mesh.name(); +} + + void Foam::ptscotchDecomp::check(const int retVal, const char* str) { if (retVal) @@ -248,11 +253,9 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str) ////- Does prevention of 0 cell domains and calls ptscotch. //Foam::label Foam::ptscotchDecomp::decomposeZeroDomains //( -// const fileName& meshPath, -// const List<label>& initadjncy, -// const List<label>& initxadj, -// const scalarField& initcWeights, -// +// const UList<label>& initadjncy, +// const UList<label>& initxadj, +// const UList<scalar>& initcWeights, // List<label>& finalDecomp //) const //{ @@ -272,7 +275,6 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str) // { // return decompose // ( -// meshPath, // initadjncy, // initxadj, // initcWeights, @@ -381,7 +383,7 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str) // // // // Do decomposition as normal. Sets finalDecomp. -// label result = decompose(meshPath, adjncy, xadj, cWeights, finalDecomp); +// label result = decompose(adjncy, xadj, cWeights, finalDecomp); // // // if (debug) @@ -437,23 +439,19 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str) //} -// Call scotch with options from dictionary. Foam::label Foam::ptscotchDecomp::decompose ( - const fileName& meshPath, - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, List<label>& finalDecomp ) const { - List<label> dummyAdjncy(1); - List<label> dummyXadj(1); - dummyXadj[0] = 0; + List<label> dummyAdjncy { 0 }; + List<label> dummyXadj { 0 }; return decompose ( - meshPath, adjncy.size(), (adjncy.size() ? adjncy.begin() : dummyAdjncy.begin()), xadj.size(), @@ -464,16 +462,13 @@ Foam::label Foam::ptscotchDecomp::decompose } -// Call scotch with options from dictionary. Foam::label Foam::ptscotchDecomp::decompose ( - const fileName& meshPath, const label adjncySize, const label adjncy[], const label xadjSize, const label xadj[], - const scalarField& cWeights, - + const UList<scalar>& cWeights, List<label>& finalDecomp ) const { @@ -492,7 +487,7 @@ Foam::label Foam::ptscotchDecomp::decompose { OFstream str ( - meshPath + "_" + Foam::name(Pstream::myProcNo()) + ".dgr" + graphPath_ + "_" + Foam::name(Pstream::myProcNo()) + ".dgr" ); Pout<< "Dumping Scotch graph file to " << str.name() << endl @@ -572,8 +567,8 @@ Foam::label Foam::ptscotchDecomp::decompose // Check for externally provided cellweights and if so initialise weights - scalar minWeights = gMin(cWeights); - scalar maxWeights = gMax(cWeights); + const scalar minWeights = gMin(cWeights); + const scalar maxWeights = gMax(cWeights); if (maxWeights > minWeights) { @@ -719,7 +714,10 @@ Foam::label Foam::ptscotchDecomp::decompose } check ( - SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()), + SCOTCH_archCmpltw + ( + &archdat, nProcessors_, processorWeights.begin() + ), "SCOTCH_archCmpltw" ); } @@ -819,6 +817,9 @@ Foam::labelList Foam::ptscotchDecomp::decompose const scalarField& pointWeights ) { + // Where to write graph + graphPath(mesh); + if (points.size() != mesh.nCells()) { FatalErrorInFunction @@ -835,7 +836,6 @@ Foam::labelList Foam::ptscotchDecomp::decompose // adjncy : contains neighbours (= edges in graph) // xadj(celli) : start of information in adjncy for celli - CompactListList<label> cellCells; calcCellCells ( @@ -847,22 +847,15 @@ Foam::labelList Foam::ptscotchDecomp::decompose ); // Decompose using default weights - List<label> finalDecomp; + labelList decomp; decompose ( - mesh.time().path()/mesh.name(), cellCells.m(), cellCells.offsets(), pointWeights, - finalDecomp + decomp ); - // Copy back to labelList - labelList decomp(points.size()); - forAll(decomp, i) - { - decomp[i] = finalDecomp[i]; - } return decomp; } @@ -875,6 +868,9 @@ Foam::labelList Foam::ptscotchDecomp::decompose const scalarField& pointWeights ) { + // Where to write graph + graphPath(mesh); + if (agglom.size() != mesh.nCells()) { FatalErrorInFunction @@ -898,14 +894,13 @@ Foam::labelList Foam::ptscotchDecomp::decompose ); // Decompose using weights - List<label> finalDecomp; + labelList decomp; decompose ( - mesh.time().path()/mesh.name(), cellCells.m(), cellCells.offsets(), pointWeights, - finalDecomp + decomp ); // Rework back into decomposition for original mesh @@ -913,7 +908,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose forAll(fineDistribution, i) { - fineDistribution[i] = finalDecomp[agglom[i]]; + fineDistribution[i] = decomp[agglom[i]]; } return fineDistribution; @@ -927,6 +922,9 @@ Foam::labelList Foam::ptscotchDecomp::decompose const scalarField& cWeights ) { + // Where to write graph + graphPath_ = "ptscotch"; + if (cellCentres.size() != globalCellCells.size()) { FatalErrorInFunction @@ -943,22 +941,15 @@ Foam::labelList Foam::ptscotchDecomp::decompose CompactListList<label> cellCells(globalCellCells); // Decompose using weights - List<label> finalDecomp; + labelList decomp; decompose ( - "ptscotch", cellCells.m(), cellCells.offsets(), cWeights, - finalDecomp + decomp ); - // Copy back to labelList - labelList decomp(cellCentres.size()); - forAll(decomp, i) - { - decomp[i] = finalDecomp[i]; - } return decomp; } diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H index 5ff4d47e847..039dd511d01 100644 --- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H +++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H @@ -64,36 +64,43 @@ class ptscotchDecomp : public decompositionMethod { + // Private data + + //- Output path and name for optional grf file. + fileName graphPath_; + + // Private Member Functions + //- Set graph path and name + void graphPath(const polyMesh& mesh); + //- Check and print error message static void check(const int, const char*); //- Decompose. Handles size 0 arrays label decompose ( - const fileName& meshPath, - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, List<label>& finalDecomp ) const; //- Low level decompose label decompose ( - const fileName& meshPath, const label adjncySize, const label adjncy[], const label xadjSize, const label xadj[], - const scalarField& cWeights, + const UList<scalar>& cWeights, List<label>& finalDecomp ) const; //- Disallow default bitwise copy construct and assignment - void operator=(const ptscotchDecomp&); - ptscotchDecomp(const ptscotchDecomp&); + void operator=(const ptscotchDecomp&) = delete; + ptscotchDecomp(const ptscotchDecomp&) = delete; public: diff --git a/src/parallel/decompose/scotchDecomp/scotchDecomp.C b/src/parallel/decompose/scotchDecomp/scotchDecomp.C index 45af4fa1e64..faea40b8668 100644 --- a/src/parallel/decompose/scotchDecomp/scotchDecomp.C +++ b/src/parallel/decompose/scotchDecomp/scotchDecomp.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -126,8 +126,6 @@ License #include "floatScalar.H" #include "Time.H" #include "OFstream.H" -#include "globalIndex.H" -#include "SubField.H" extern "C" { @@ -161,6 +159,12 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::scotchDecomp::graphPath(const polyMesh& mesh) +{ + graphPath_ = mesh.time().path()/mesh.name() + ".grf"; +} + + void Foam::scotchDecomp::check(const int retVal, const char* str) { if (retVal) @@ -172,186 +176,53 @@ void Foam::scotchDecomp::check(const int retVal, const char* str) } -Foam::label Foam::scotchDecomp::decompose +Foam::label Foam::scotchDecomp::decomposeSerial ( - const fileName& meshPath, - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, - - List<label>& finalDecomp + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, + List<label>& decomp ) { - if (!Pstream::parRun()) - { - decomposeOneProc - ( - meshPath, - adjncy, - xadj, - cWeights, - finalDecomp - ); - } - else - { - if (debug) - { - Info<< "scotchDecomp : running in parallel." - << " Decomposing all of graph on master processor." << endl; - } - globalIndex globalCells(xadj.size()-1); - label nTotalConnections = returnReduce(adjncy.size(), sumOp<label>()); - - // Send all to master. Use scheduled to save some storage. - if (Pstream::master()) - { - Field<label> allAdjncy(nTotalConnections); - Field<label> allXadj(globalCells.size()+1); - scalarField allWeights(globalCells.size()); - - // Insert my own - label nTotalCells = 0; - forAll(cWeights, celli) - { - allXadj[nTotalCells] = xadj[celli]; - allWeights[nTotalCells++] = cWeights[celli]; - } - nTotalConnections = 0; - forAll(adjncy, i) - { - allAdjncy[nTotalConnections++] = adjncy[i]; - } + const dictionary* coeffsDictPtr = + decompositionDict_.subDictPtr("scotchCoeffs"); - for (int slave=1; slave<Pstream::nProcs(); slave++) - { - IPstream fromSlave(Pstream::commsTypes::scheduled, slave); - Field<label> nbrAdjncy(fromSlave); - Field<label> nbrXadj(fromSlave); - scalarField nbrWeights(fromSlave); - - // Append. - //label procStart = nTotalCells; - forAll(nbrXadj, celli) - { - allXadj[nTotalCells] = nTotalConnections+nbrXadj[celli]; - allWeights[nTotalCells++] = nbrWeights[celli]; - } - // No need to renumber xadj since already global. - forAll(nbrAdjncy, i) - { - allAdjncy[nTotalConnections++] = nbrAdjncy[i]; - } - } - allXadj[nTotalCells] = nTotalConnections; + // Dump graph + if (coeffsDictPtr && coeffsDictPtr->lookupOrDefault("writeGraph", false)) + { + OFstream str(graphPath_); + Info<< "Dumping Scotch graph file to " << str.name() << endl + << "Use this in combination with gpart." << endl; - Field<label> allFinalDecomp; - decomposeOneProc - ( - meshPath, - allAdjncy, - allXadj, - allWeights, - allFinalDecomp - ); + const label version = 0; + str << version << nl; + // Numer of vertices + str << xadj.size()-1 << ' ' << adjncy.size() << nl; + // Numbering starts from 0 + const label baseval = 0; + // Has weights? + const label hasEdgeWeights = 0; + const label hasVertexWeights = 0; + const label numericflag = 10*hasEdgeWeights+hasVertexWeights; + str << baseval << ' ' << numericflag << nl; - // Send allFinalDecomp back - for (int slave=1; slave<Pstream::nProcs(); slave++) - { - OPstream toSlave(Pstream::commsTypes::scheduled, slave); - toSlave << SubField<label> - ( - allFinalDecomp, - globalCells.localSize(slave), - globalCells.offset(slave) - ); - } - // Get my own part (always first) - finalDecomp = SubField<label> - ( - allFinalDecomp, - globalCells.localSize() - ); - } - else + for (label celli = 0; celli < xadj.size()-1; ++celli) { - // Send my part of the graph (already in global numbering) - { - OPstream toMaster - ( - Pstream::commsTypes::scheduled, - Pstream::masterNo() - ); - toMaster<< adjncy << SubField<label>(xadj, xadj.size()-1) - << cWeights; - } - - // Receive back decomposition - IPstream fromMaster - ( - Pstream::commsTypes::scheduled, - Pstream::masterNo() - ); - fromMaster >> finalDecomp; - } - } - return 0; -} + const label start = xadj[celli]; + const label end = xadj[celli+1]; + str << end-start; // size -// Call scotch with options from dictionary. -Foam::label Foam::scotchDecomp::decomposeOneProc -( - const fileName& meshPath, - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, - - List<label>& finalDecomp -) -{ - // Dump graph - if (decompositionDict_.found("scotchCoeffs")) - { - const dictionary& scotchCoeffs = - decompositionDict_.subDict("scotchCoeffs"); - - if (scotchCoeffs.lookupOrDefault("writeGraph", false)) - { - OFstream str(meshPath + ".grf"); - - Info<< "Dumping Scotch graph file to " << str.name() << endl - << "Use this in combination with gpart." << endl; - - label version = 0; - str << version << nl; - // Numer of vertices - str << xadj.size()-1 << ' ' << adjncy.size() << nl; - // Numbering starts from 0 - label baseval = 0; - // Has weights? - label hasEdgeWeights = 0; - label hasVertexWeights = 0; - label numericflag = 10*hasEdgeWeights+hasVertexWeights; - str << baseval << ' ' << numericflag << nl; - for (label celli = 0; celli < xadj.size()-1; celli++) + for (label i = start; i < end; ++i) { - label start = xadj[celli]; - label end = xadj[celli+1]; - str << end-start; - - for (label i = start; i < end; i++) - { - str << ' ' << adjncy[i]; - } - str << nl; + str << ' ' << adjncy[i]; } + str << nl; } } - // Strategy // ~~~~~~~~ @@ -359,13 +230,10 @@ Foam::label Foam::scotchDecomp::decomposeOneProc SCOTCH_Strat stradat; check(SCOTCH_stratInit(&stradat), "SCOTCH_stratInit"); - if (decompositionDict_.found("scotchCoeffs")) + if (coeffsDictPtr) { - const dictionary& scotchCoeffs = - decompositionDict_.subDict("scotchCoeffs"); - string strategy; - if (scotchCoeffs.readIfPresent("strategy", strategy)) + if (coeffsDictPtr->readIfPresent("strategy", strategy)) { if (debug) { @@ -384,10 +252,9 @@ Foam::label Foam::scotchDecomp::decomposeOneProc List<label> velotab; - // Check for externally provided cellweights and if so initialise weights // Note: min, not gMin since routine runs on master only. - scalar minWeights = min(cWeights); + const scalar minWeights = min(cWeights); if (!cWeights.empty()) { if (minWeights <= 0) @@ -431,7 +298,6 @@ Foam::label Foam::scotchDecomp::decomposeOneProc } - SCOTCH_Graph grafdat; check(SCOTCH_graphInit(&grafdat), "SCOTCH_graphInit"); check @@ -462,14 +328,12 @@ Foam::label Foam::scotchDecomp::decomposeOneProc check(SCOTCH_archInit(&archdat), "SCOTCH_archInit"); List<label> processorWeights; - if (decompositionDict_.found("scotchCoeffs")) - { - const dictionary& scotchCoeffs = - decompositionDict_.subDict("scotchCoeffs"); - - scotchCoeffs.readIfPresent("processorWeights", processorWeights); - } - if (processorWeights.size()) + if + ( + coeffsDictPtr + && coeffsDictPtr->readIfPresent("processorWeights", processorWeights) + && processorWeights.size() + ) { if (debug) { @@ -478,7 +342,10 @@ Foam::label Foam::scotchDecomp::decomposeOneProc } check ( - SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()), + SCOTCH_archCmpltw + ( + &archdat, nProcessors_, processorWeights.begin() + ), "SCOTCH_archCmpltw" ); } @@ -491,7 +358,7 @@ Foam::label Foam::scotchDecomp::decomposeOneProc ); - //- Hack to test clustering. Note that finalDecomp is non-compact + //- Hack to test clustering. Note that decomp is non-compact // numbers! // ////- Set up variable sizes architecture @@ -542,16 +409,16 @@ Foam::label Foam::scotchDecomp::decomposeOneProc ); #endif - finalDecomp.setSize(xadj.size()-1); - finalDecomp = 0; + decomp.setSize(xadj.size()-1); + decomp = 0; check ( SCOTCH_graphMap ( &grafdat, &archdat, - &stradat, // const SCOTCH_Strat * - finalDecomp.begin() // parttab + &stradat, // const SCOTCH_Strat * + decomp.begin() // parttab ), "SCOTCH_graphMap" ); @@ -560,17 +427,15 @@ Foam::label Foam::scotchDecomp::decomposeOneProc feenableexcept(oldExcepts); #endif - - - //finalDecomp.setSize(xadj.size()-1); + //decomp.setSize(xadj.size()-1); //check //( // SCOTCH_graphPart // ( // &grafdat, - // nProcessors_, // partnbr - // &stradat, // const SCOTCH_Strat * - // finalDecomp.begin() // parttab + // nProcessors_, // partnbr + // &stradat, // const SCOTCH_Strat * + // decomp.begin() // parttab // ), // "SCOTCH_graphPart" //); @@ -590,7 +455,7 @@ Foam::label Foam::scotchDecomp::decomposeOneProc Foam::scotchDecomp::scotchDecomp(const dictionary& decompositionDict) : - decompositionMethod(decompositionDict) + metisLikeDecomp(decompositionDict) {} @@ -603,46 +468,15 @@ Foam::labelList Foam::scotchDecomp::decompose const scalarField& pointWeights ) { - if (points.size() != mesh.nCells()) - { - FatalErrorInFunction - << "Can use this decomposition method only for the whole mesh" - << endl - << "and supply one coordinate (cellCentre) for every cell." << endl - << "The number of coordinates " << points.size() << endl - << "The number of cells in the mesh " << mesh.nCells() - << exit(FatalError); - } + // Where to write graph + graphPath(mesh); - // Calculate local or global (if Pstream::parRun()) connectivity - CompactListList<label> cellCells; - calcCellCells + return metisLikeDecomp::decompose ( mesh, - identity(mesh.nCells()), - mesh.nCells(), - true, - cellCells - ); - - // Decompose using default weights - List<label> finalDecomp; - decompose - ( - mesh.time().path()/mesh.name(), - cellCells.m(), - cellCells.offsets(), - pointWeights, - finalDecomp + points, + pointWeights ); - - // Copy back to labelList - labelList decomp(finalDecomp.size()); - forAll(decomp, i) - { - decomp[i] = finalDecomp[i]; - } - return decomp; } @@ -654,45 +488,16 @@ Foam::labelList Foam::scotchDecomp::decompose const scalarField& pointWeights ) { - if (agglom.size() != mesh.nCells()) - { - FatalErrorInFunction - << "Size of cell-to-coarse map " << agglom.size() - << " differs from number of cells in mesh " << mesh.nCells() - << exit(FatalError); - } + // Where to write graph + graphPath(mesh); - // Calculate local or global (if Pstream::parRun()) connectivity - CompactListList<label> cellCells; - calcCellCells + return metisLikeDecomp::decompose ( mesh, agglom, - agglomPoints.size(), - true, - cellCells + agglomPoints, + pointWeights ); - - // Decompose using weights - List<label> finalDecomp; - decompose - ( - mesh.time().path()/mesh.name(), - cellCells.m(), - cellCells.offsets(), - pointWeights, - finalDecomp - ); - - // Rework back into decomposition for original mesh_ - labelList fineDistribution(agglom.size()); - - forAll(fineDistribution, i) - { - fineDistribution[i] = finalDecomp[agglom[i]]; - } - - return fineDistribution; } @@ -703,39 +508,15 @@ Foam::labelList Foam::scotchDecomp::decompose const scalarField& cWeights ) { - if (cellCentres.size() != globalCellCells.size()) - { - FatalErrorInFunction - << "Inconsistent number of cells (" << globalCellCells.size() - << ") and number of cell centres (" << cellCentres.size() - << ")." << exit(FatalError); - } - + // Where to write graph + graphPath_ = "scotch.grf"; - // Make Metis CSR (Compressed Storage Format) storage - // adjncy : contains neighbours (= edges in graph) - // xadj(celli) : start of information in adjncy for celli - - CompactListList<label> cellCells(globalCellCells); - - // Decompose using weights - List<label> finalDecomp; - decompose + return metisLikeDecomp::decompose ( - "scotch", - cellCells.m(), - cellCells.offsets(), - cWeights, - finalDecomp + globalCellCells, + cellCentres, + cWeights ); - - // Copy back to labelList - labelList decomp(finalDecomp.size()); - forAll(decomp, i) - { - decomp[i] = finalDecomp[i]; - } - return decomp; } diff --git a/src/parallel/decompose/scotchDecomp/scotchDecomp.H b/src/parallel/decompose/scotchDecomp/scotchDecomp.H index a2a2a298ca1..7a44f095f27 100644 --- a/src/parallel/decompose/scotchDecomp/scotchDecomp.H +++ b/src/parallel/decompose/scotchDecomp/scotchDecomp.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -213,7 +213,7 @@ SourceFiles #ifndef scotchDecomp_H #define scotchDecomp_H -#include "decompositionMethod.H" +#include "metisLikeDecomp.H" namespace Foam { @@ -224,35 +224,34 @@ namespace Foam class scotchDecomp : - public decompositionMethod + public metisLikeDecomp { + // Private data + + //- Output path and name for optional grf file. + fileName graphPath_; + + // Private Member Functions + //- Set graph path and name + void graphPath(const polyMesh& mesh); + //- Check and print error message static void check(const int, const char*); - label decompose - ( - const fileName& meshPath, - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, - List<label>& finalDecomp - ); - //- Decompose non-parallel - label decomposeOneProc + virtual label decomposeSerial ( - const fileName& meshPath, - const List<label>& adjncy, - const List<label>& xadj, - const scalarField& cWeights, - List<label>& finalDecomp + const UList<label>& adjncy, + const UList<label>& xadj, + const UList<scalar>& cWeights, + List<label>& decomp ); //- Disallow default bitwise copy construct and assignment - void operator=(const scotchDecomp&); - scotchDecomp(const scotchDecomp&); + void operator=(const scotchDecomp&) = delete; + scotchDecomp(const scotchDecomp&) = delete; public: @@ -280,14 +279,10 @@ public: return true; } - //- Inherit decompose from decompositionMethod + //- Inherit all decompose methods using decompositionMethod::decompose; - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) - // Weights get normalised with minimum weight and truncated to - // convert into integer so e.g. 3.5 is seen as 3. The overall sum - // of weights might otherwise overflow. + //- Return for every coordinate the wanted processor number. virtual labelList decompose ( const polyMesh& mesh, @@ -295,11 +290,7 @@ public: const scalarField& pointWeights ); - //- Return for every coordinate the wanted processor number. Gets - // passed agglomeration map (from fine to coarse cells) and coarse cell - // location. Can be overridden by decomposers that provide this - // functionality natively. - // See note on weights above. + //- Return for every coordinate the wanted processor number. virtual labelList decompose ( const polyMesh& mesh, @@ -308,14 +299,7 @@ public: const scalarField& regionWeights ); - //- Return for every coordinate the wanted processor number. Explicitly - // provided mesh connectivity. - // The connectivity is equal to mesh.cellCells() except for - // - in parallel the cell numbers are global cell numbers (starting - // from 0 at processor0 and then incrementing all through the - // processors) - // - the connections are across coupled patches - // See note on weights above. + //- Return for every coordinate the wanted processor number. virtual labelList decompose ( const labelListList& globalCellCells, -- GitLab From 874452717a6eda37d8a4db6f3c5f229402b8f344 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 10 Oct 2017 12:46:40 +0200 Subject: [PATCH 031/126] ENH: add mergeMeshes -resultTime option (as per subsetMesh) --- .../manipulation/mergeMeshes/mergeMeshes.C | 52 ++++++++++++++----- .../manipulation/mergeMeshes/mergePolyMesh.C | 18 ++----- .../manipulation/mergeMeshes/mergePolyMesh.H | 4 +- .../mesh/manipulation/subsetMesh/subsetMesh.C | 3 -- .../transformPoints/transformPoints.C | 19 ++++--- .../surfaceTransformPoints.C | 15 +++--- 6 files changed, 59 insertions(+), 52 deletions(-) diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.C b/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.C index 67eb9f5c7b7..24c6071423e 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.C +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.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 | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -84,6 +84,12 @@ int main(int argc, char *argv[]) "name", "specify alternative mesh region for the additional mesh" ); + argList::addOption + ( + "resultTime", + "time", + "specify a time for the resulting mesh" + ); argList args(argc, argv); if (!args.check()) @@ -94,20 +100,29 @@ int main(int argc, char *argv[]) const bool overwrite = args.optionFound("overwrite"); fileName masterCase = args[1]; - word masterRegion = polyMesh::defaultRegion; - args.optionReadIfPresent("masterRegion", masterRegion); - fileName addCase = args[2]; - word addRegion = polyMesh::defaultRegion; - args.optionReadIfPresent("addRegion", addRegion); + + const word masterRegion = + args.optionLookupOrDefault<word> + ( + "masterRegion", + polyMesh::defaultRegion + ); + + const word addRegion = + args.optionLookupOrDefault<word> + ( + "masterRegion", + polyMesh::defaultRegion + ); // Since we don't use argList processor directory detection, add it to // the casename ourselves so it triggers the logic inside TimePath. const fileName& cName = args.caseName(); - std::string::size_type pos = cName.find("processor"); + const auto pos = cName.find("processor"); if (pos != string::npos && pos != 0) { - fileName processorName = cName.substr(pos, cName.size()-pos); + fileName processorName = cName.substr(pos); masterCase += '/' + processorName; addCase += '/' + processorName; } @@ -133,11 +148,8 @@ int main(int argc, char *argv[]) runTimeMaster ) ); - const word oldInstance = masterMesh.pointsInstance(); - Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << nl; - Info<< "Create mesh\n" << endl; polyMesh meshToAdd ( @@ -149,7 +161,19 @@ int main(int argc, char *argv[]) ) ); - if (!overwrite) + word meshInstance = masterMesh.pointsInstance(); + + const bool specifiedInstance = + ( + !overwrite + && args.optionReadIfPresent("resultTime", meshInstance) + ); + + if (specifiedInstance) + { + runTimeMaster.setTime(instant(meshInstance), 0); + } + else if (!overwrite) { runTimeMaster++; } @@ -159,9 +183,9 @@ int main(int argc, char *argv[]) masterMesh.addMesh(meshToAdd); masterMesh.merge(); - if (overwrite) + if (overwrite || specifiedInstance) { - masterMesh.setInstance(oldInstance); + masterMesh.setInstance(meshInstance); } masterMesh.write(); diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C index 1a4deffd5fc..72f0a675d54 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C @@ -229,35 +229,23 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io) if (curPointZoneNames.size()) { pointZoneNames_.setCapacity(2*curPointZoneNames.size()); - } - - forAll(curPointZoneNames, zoneI) - { - pointZoneNames_.append(curPointZoneNames[zoneI]); + pointZoneNames_.append(curPointZoneNames); } // Face zones wordList curFaceZoneNames = faceZones().names(); - if (curFaceZoneNames.size()) { faceZoneNames_.setCapacity(2*curFaceZoneNames.size()); - } - forAll(curFaceZoneNames, zoneI) - { - faceZoneNames_.append(curFaceZoneNames[zoneI]); + faceZoneNames_.append(curFaceZoneNames); } // Cell zones wordList curCellZoneNames = cellZones().names(); - if (curCellZoneNames.size()) { cellZoneNames_.setCapacity(2*curCellZoneNames.size()); - } - forAll(curCellZoneNames, zoneI) - { - cellZoneNames_.append(curCellZoneNames[zoneI]); + cellZoneNames_.append(curCellZoneNames); } } diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H index 6ce6f6e4efc..94a934b22bc 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H @@ -77,10 +77,10 @@ class mergePolyMesh // Private Member Functions //- Disallow default bitwise copy construct - mergePolyMesh(const mergePolyMesh&); + mergePolyMesh(const mergePolyMesh&) = delete; //- Disallow default bitwise assignment - void operator=(const mergePolyMesh&); + void operator=(const mergePolyMesh&) = delete; //- Return patch index given a name and type diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index 2947edb02b1..2846045f688 100644 --- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C +++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C @@ -369,9 +369,6 @@ int main(int argc, char *argv[]) #include "createTime.H" runTime.functionObjects().off(); - Foam::word meshRegionName = polyMesh::defaultRegion; - args.optionReadIfPresent("region", meshRegionName); - #include "createNamedMesh.H" const word setName = args[1]; diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index b082bf39c2b..e2cf5571ecd 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -35,7 +35,7 @@ Usage Options are: -translate vector - Translates the points by the given vector, + Translates the points by the given vector before rotations -rotate (vector vector) Rotates the points from the first vector to the second, @@ -145,45 +145,44 @@ int main(int argc, char *argv[]) { argList::addNote ( - "Transform (translate/rotate/scale) mesh points.\n" - "Note: roll=rotation about x, pitch=rotation about y, " - "yaw=rotation about z" + "Transform (translate / rotate / scale) mesh points.\n" + "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z" ); argList::addOption ( "translate", "vector", - "translate by the specified <vector> - eg, '(1 0 0)'" + "Translate by specified <vector> - eg, '(1 0 0)' before rotations" ); argList::addOption ( "rotate", "(vectorA vectorB)", - "transform in terms of a rotation between <vectorA> and <vectorB> " + "Transform as a rotation between <vectorA> and <vectorB> " "- eg, '( (1 0 0) (0 0 1) )'" ); argList::addOption ( "rollPitchYaw", "vector", - "rotate by '(roll pitch yaw)' in degrees" + "Rotate by '(roll pitch yaw)' in degrees" ); argList::addOption ( "yawPitchRoll", "vector", - "rotate by '(yaw pitch roll)' in degrees" + "Rotate by '(yaw pitch roll)' in degrees" ); argList::addBoolOption ( "rotateFields", - "read and transform vector and tensor fields too" + "Read and transform vector and tensor fields too" ); argList::addOption ( "scale", "scalar | vector", - "scale by the specified amount - eg, for a uniform [mm] to [m] scaling " + "Scale by the specified amount - eg, for a uniform [mm] to [m] scaling " "use either (0.001 0.001 0.001)' or simply '0.001'" ); diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index 173bbf2e3a8..79e452685aa 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -60,10 +60,9 @@ int main(int argc, char *argv[]) { argList::addNote ( - "Transform (translate/rotate/scale) a surface. " + "Transform (translate / rotate / scale) surface points.\n" "Like transformPoints but for surfaces.\n" - "Note: roll=rotation about x, pitch=rotation about y, " - "yaw=rotation about z" + "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z" ); argList::noParallel(); argList::validArgs.append("surfaceFile"); @@ -72,33 +71,33 @@ int main(int argc, char *argv[]) ( "translate", "vector", - "translate by the specified <vector> - eg, '(1 0 0)'" + "Translate by specified <vector> - eg, '(1 0 0)' before rotations" ); argList::addOption ( "rotate", "(vectorA vectorB)", - "transform in terms of a rotation between <vectorA> and <vectorB> " + "Transform as a rotation between <vectorA> and <vectorB> " "- eg, '( (1 0 0) (0 0 1) )'" ); argList::addOption ( "scale", "scalar | vector", - "scale by the specified amount - eg, for a uniform [mm] to [m] scaling " + "Scale by the specified amount - eg, for a uniform [mm] to [m] scaling " "use either (0.001 0.001 0.001)' or simply '0.001'" ); argList::addOption ( "rollPitchYaw", "vector", - "rotate by '(roll pitch yaw)' in degrees" + "Rotate by '(roll pitch yaw)' in degrees" ); argList::addOption ( "yawPitchRoll", "vector", - "rotate by '(yaw pitch roll)' in degrees" + "Rotate by '(yaw pitch roll)' in degrees" ); argList args(argc, argv); -- GitLab From e816d5cc8067283e368cef1480123688111f1314 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 10 Oct 2017 18:06:52 +0200 Subject: [PATCH 032/126] BUG: label overflow in multiLevel decomposition (closes #619) - previously when more than two levels were used. Now calculate the required final target domain segment directly. --- .../multiLevelDecomp/multiLevelDecomp.C | 108 ++++++++++++------ .../multiLevelDecomp/multiLevelDecomp.H | 15 +-- 2 files changed, 80 insertions(+), 43 deletions(-) diff --git a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C index 3ab449d3d3f..09070a7dde3 100644 --- a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C +++ b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -99,7 +99,7 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells forAll(cCells, i) { // Get locally-compact cell index of neighbouring cell - label nbrCelli = oldToNew[cCells[i]]; + const label nbrCelli = oldToNew[cCells[i]]; if (nbrCelli == -1) { cutConnections[allDist[cCells[i]]]++; @@ -109,10 +109,10 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells // Reconvert local cell index into global one // Get original neighbour - label celli = set[subCelli]; - label oldNbrCelli = cellCells[celli][i]; + const label celli = set[subCelli]; + const label oldNbrCelli = cellCells[celli][i]; // Get processor from original neighbour - label proci = globalCells.whichProcID(oldNbrCelli); + const label proci = globalCells.whichProcID(oldNbrCelli); // Convert into global compact numbering cCells[newI++] = globalSubCells.toGlobal(proci, nbrCelli); } @@ -127,15 +127,16 @@ void Foam::multiLevelDecomp::decompose const labelListList& pointPoints, const pointField& points, const scalarField& pointWeights, - const labelList& pointMap, // map back to original points - const label levelI, + const labelUList& pointMap, // map back to original points + const label currLevel, + const label leafOffset, - labelField& finalDecomp + labelList& finalDecomp ) { labelList dist ( - methods_[levelI].decompose + methods_[currLevel].decompose ( pointPoints, points, @@ -143,30 +144,62 @@ void Foam::multiLevelDecomp::decompose ) ); + // The next recursion level + const label nextLevel = currLevel+1; + + // Number of domains at this current level + const label nCurrDomains = methods_[currLevel].nDomains(); + + // Calculate the domain remapping. + // The decompose() method delivers a distribution of [0..nDomains-1] + // which we map to the final location according to the decomposition + // leaf we are on. + + labelList domainLookup(nCurrDomains); + { + label sizes = 1; // Cumulative number of domains + for (label i = 0; i <= currLevel; ++i) + { + sizes *= methods_[i].nDomains(); + } + + // Distribution of domains at this level + sizes = this->nDomains() / sizes; + + forAll(domainLookup, i) + { + domainLookup[i] = i * sizes + leafOffset; + } + } + + if (debug) + { + Info<< "Distribute at level " << currLevel + << " to domains" << nl + << flatOutput(domainLookup) << endl; + } + + // Extract processor+local index from point-point addressing forAll(pointMap, i) { - label orig = pointMap[i]; - finalDecomp[orig] += dist[i]; + const label orig = pointMap[i]; + finalDecomp[orig] = domainLookup[dist[i]]; } - if (levelI != methods_.size()-1) + if (nextLevel < methods_.size()) { // Recurse // Determine points per domain - label n = methods_[levelI].nDomains(); - labelListList domainToPoints(invertOneToMany(n, dist)); - - // 'Make space' for new levels of decomposition - finalDecomp *= methods_[levelI+1].nDomains(); + labelListList domainToPoints(invertOneToMany(nCurrDomains, dist)); // Extract processor+local index from point-point addressing if (debug && Pstream::master()) { - Pout<< "Decomposition at level " << levelI << " :" << endl; + Pout<< "Decomposition at level " << currLevel << " :" << endl; } - for (label domainI = 0; domainI < n; domainI++) + for (label domainI = 0; domainI < nCurrDomains; domainI++) { // Extract elements for current domain const labelList domainPoints(findIndices(dist, domainI)); @@ -180,7 +213,7 @@ void Foam::multiLevelDecomp::decompose labelList nOutsideConnections; subsetGlobalCellCells ( - n, + nCurrDomains, domainI, dist, @@ -196,12 +229,12 @@ void Foam::multiLevelDecomp::decompose Pstream::listCombineScatter(nOutsideConnections); label nPatches = 0; label nFaces = 0; - forAll(nOutsideConnections, i) + for (const label nConnect : nOutsideConnections) { - if (nOutsideConnections[i] > 0) + if (nConnect > 0) { - nPatches++; - nFaces += nOutsideConnections[i]; + ++nPatches; + nFaces += nConnect; } } @@ -224,7 +257,8 @@ void Foam::multiLevelDecomp::decompose subPoints, subWeights, subPointMap, - levelI+1, + nextLevel, + domainLookup[domainI], // The offset for this level and leaf finalDecomp ); @@ -238,8 +272,8 @@ void Foam::multiLevelDecomp::decompose if (debug) { // Do straight decompose of two levels - label nNext = methods_[levelI+1].nDomains(); - label nTotal = n*nNext; + const label nNext = methods_[nextLevel].nDomains(); + const label nTotal = nCurrDomains * nNext; // Retrieve original level0 dictionary and modify number of domains dictionary::const_iterator iter = @@ -267,12 +301,12 @@ void Foam::multiLevelDecomp::decompose ) ); - for (label blockI = 0; blockI < n; blockI++) + for (label blockI = 0; blockI < nCurrDomains; blockI++) { // Count the number inbetween blocks of nNext size label nPoints = 0; - labelList nOutsideConnections(n, 0); + labelList nOutsideConnections(nCurrDomains, 0); forAll(pointPoints, pointi) { if ((dist[pointi] / nNext) == blockI) @@ -283,7 +317,7 @@ void Foam::multiLevelDecomp::decompose forAll(pPoints, i) { - label distBlockI = dist[pPoints[i]] / nNext; + const label distBlockI = dist[pPoints[i]] / nNext; if (distBlockI != blockI) { nOutsideConnections[distBlockI]++; @@ -301,12 +335,12 @@ void Foam::multiLevelDecomp::decompose Pstream::listCombineScatter(nOutsideConnections); label nPatches = 0; label nFaces = 0; - forAll(nOutsideConnections, i) + for (const label nConnect : nOutsideConnections) { - if (nOutsideConnections[i] > 0) + if (nConnect > 0) { - nPatches++; - nFaces += nOutsideConnections[i]; + ++nPatches; + nFaces += nConnect; } } @@ -385,7 +419,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose CompactListList<label> cellCells; calcCellCells(mesh, identity(cc.size()), cc.size(), true, cellCells); - labelField finalDecomp(cc.size(), 0); + labelList finalDecomp(cc.size(), 0); labelList cellMap(identity(cc.size())); decompose @@ -395,6 +429,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose cWeights, cellMap, // map back to original cells 0, + 0, finalDecomp ); @@ -410,7 +445,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose const scalarField& pointWeights ) { - labelField finalDecomp(points.size(), 0); + labelList finalDecomp(points.size(), 0); labelList pointMap(identity(points.size())); decompose @@ -420,6 +455,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose pointWeights, pointMap, // map back to original points 0, + 0, finalDecomp ); diff --git a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.H b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.H index dbdd582295c..d11f14280b0 100644 --- a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.H +++ b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,21 +71,22 @@ class multiLevelDecomp labelList& cutConnections ) const; - //- Decompose level methodI without addressing + //- Decompose at 'currLevel' without addressing void decompose ( const labelListList& pointPoints, const pointField& points, const scalarField& pointWeights, - const labelList& pointMap, // map back to original points - const label levelI, + const labelUList& pointMap, // map back to original points + const label currLevel, + const label leafOffset, - labelField& finalDecomp + labelList& finalDecomp ); //- Disallow default bitwise copy construct and assignment - void operator=(const multiLevelDecomp&); - multiLevelDecomp(const multiLevelDecomp&); + void operator=(const multiLevelDecomp&) = delete; + multiLevelDecomp(const multiLevelDecomp&) = delete; public: -- GitLab From 8acd80c54c6231e07040ecfa7df4e776ca8a0b27 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 10 Oct 2017 19:32:53 +0200 Subject: [PATCH 033/126] BUG: multiLevelCoeffs entry not mandatory (closes #620) --- .../multiLevelDecomp/multiLevelDecomp.C | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C index 09070a7dde3..e90406009c9 100644 --- a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C +++ b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C @@ -275,21 +275,27 @@ void Foam::multiLevelDecomp::decompose const label nNext = methods_[nextLevel].nDomains(); const label nTotal = nCurrDomains * nNext; - // Retrieve original level0 dictionary and modify number of domains - dictionary::const_iterator iter = - decompositionDict_.optionalSubDict(typeName + "Coeffs").begin(); - dictionary myDict = iter().dict(); - myDict.set("numberOfSubdomains", nTotal); + // Get original level0 dictionary and modify numberOfSubdomains + dictionary level0Dict; + forAllConstIter(dictionary, methodsDict_, iter) + { + if (iter().isDict()) + { + level0Dict = iter().dict(); + break; + } + } + level0Dict.set("numberOfSubdomains", nTotal); if (debug && Pstream::master()) { - Pout<< "Reference decomposition with " << myDict << " :" + Pout<< "Reference decomposition with " << level0Dict << " :" << endl; } autoPtr<decompositionMethod> method0 = decompositionMethod::New ( - myDict + level0Dict ); labelList dist ( @@ -364,31 +370,37 @@ void Foam::multiLevelDecomp::decompose Foam::multiLevelDecomp::multiLevelDecomp(const dictionary& decompositionDict) : decompositionMethod(decompositionDict), - methodsDict_(decompositionDict_.optionalSubDict(typeName + "Coeffs")) + methodsDict_(decompositionDict_.subDict(typeName + "Coeffs")) { methods_.setSize(methodsDict_.size()); - label i = 0; + label nLevels = 0; forAllConstIter(dictionary, methodsDict_, iter) { - methods_.set(i++, decompositionMethod::New(iter().dict())); + // Ignore primitive entries which may be there for additional control + if (iter().isDict()) + { + methods_.set(nLevels++, decompositionMethod::New(iter().dict())); + } } - label n = 1; + methods_.setSize(nLevels); + + label nTot = 1; Info<< "decompositionMethod " << type() << " :" << endl; forAll(methods_, i) { Info<< " level " << i << " decomposing with " << methods_[i].type() << " into " << methods_[i].nDomains() << " subdomains." << endl; - n *= methods_[i].nDomains(); + nTot *= methods_[i].nDomains(); } - if (n != nDomains()) + if (nTot != nDomains()) { FatalErrorInFunction << "Top level decomposition specifies " << nDomains() << " domains which is not equal to the product of" - << " all sub domains " << n + << " all sub domains " << nTot << exit(FatalError); } } -- GitLab From 27cd94e95488953df0d69cb637759982b581e222 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 11 Oct 2017 09:22:23 +0100 Subject: [PATCH 034/126] ENH: checkMesh: handle label overflow. Fixes #617. --- .../utilities/mesh/manipulation/checkMesh/checkTools.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index b68047b11db..c9b6475f5e1 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,7 +104,7 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) << " internal faces: " << nIntFaces << nl << " cells: " << nCells << nl << " faces per cell: " - << scalar(nFaces + nIntFaces)/max(1, nCells) << nl + << (scalar(nFaces) + scalar(nIntFaces))/max(1, nCells) << nl << " boundary patches: " << mesh.boundaryMesh().size() << nl << " point zones: " << mesh.pointZones().size() << nl << " face zones: " << mesh.faceZones().size() << nl -- GitLab From 5f98600b53a31224d50e1cda24e735d738539628 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 11 Oct 2017 18:41:28 +0200 Subject: [PATCH 035/126] COMP: handle kahip .so version, and openmp dependency --- applications/test/checkDecomposePar/Make/options | 1 + etc/config.sh/kahip | 4 ++-- src/parallel/decompose/Allwmake | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/applications/test/checkDecomposePar/Make/options b/applications/test/checkDecomposePar/Make/options index 74501c5fddb..70323818234 100644 --- a/applications/test/checkDecomposePar/Make/options +++ b/applications/test/checkDecomposePar/Make/options @@ -6,5 +6,6 @@ EXE_INC = \ -I$(LIB_SRC)/regionModels/regionModel/lnInclude EXE_LIBS = \ + -ldecompose \ -ldecompositionMethods \ -lregionModels diff --git a/etc/config.sh/kahip b/etc/config.sh/kahip index 9212e7a80a3..21d7a8a84a5 100644 --- a/etc/config.sh/kahip +++ b/etc/config.sh/kahip @@ -42,7 +42,7 @@ # An Int64 OpenFOAM version can use it, but the mesh size is limited # accordingly. # -# If KaHIP was compiled with openmp, you may need to add in additional +# If KaHIP was compiled with openmp, you may need additional # compile or link flags in KAHIP_COMP_FLAGS KAHIP_LINK_FLAGS # #------------------------------------------------------------------------------ @@ -53,7 +53,7 @@ export KAHIP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$KAHIP # Adjust as required # export KAHIP_COMP_FLAGS="-fopenmp" -# export KAHIP_LINK_FLAGS="-lgomp" +export KAHIP_LINK_FLAGS="-lgomp" # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 19dced9e316..39c8f109a50 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -58,8 +58,11 @@ hasKahip() # Library [ "${KAHIP_ARCH_PATH##*-}" = system ] || \ findFirstFile \ + $FOAM_EXT_LIBBIN/libkahip.so \ $KAHIP_ARCH_PATH/lib/libkahip.a \ + $KAHIP_ARCH_PATH/lib/libkahip.so \ $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libkahip.a \ + $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libkahip.so \ > /dev/null || { echo "$warning (missing library)" return 2 -- GitLab From 9bb8f6aefcc46b1770fe558b2f73560e54f4a299 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 12 Oct 2017 09:49:16 +0200 Subject: [PATCH 036/126] COMP: create lnInclude directory for kahip --- src/parallel/decompose/AllwmakeLnInclude | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parallel/decompose/AllwmakeLnInclude b/src/parallel/decompose/AllwmakeLnInclude index 8aa65506c95..6041217fec0 100755 --- a/src/parallel/decompose/AllwmakeLnInclude +++ b/src/parallel/decompose/AllwmakeLnInclude @@ -2,6 +2,7 @@ cd ${0%/*} || exit 1 # Run from this directory wmakeLnInclude -u decompositionMethods +wmakeLnInclude -u kahipDecomp wmakeLnInclude -u metisDecomp wmakeLnInclude -u scotchDecomp wmakeLnInclude -u ptscotchDecomp -- GitLab From f1162174669f7e220dab5a20def0d9f2c436d914 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 12 Oct 2017 12:15:56 +0200 Subject: [PATCH 037/126] STYLE: remove FULLDEBUG output on readLabel, readScalar - used in various places to test if the input can be parsed as a label/scalar, so warnings tend to flood the output. - be more explicit when encountering range errors --- .../test/primitives/Test-primitives.C | 16 +++++++-- src/OpenFOAM/primitives/Scalar/Scalar.C | 13 +------ src/OpenFOAM/primitives/ints/int/intIO.C | 36 +++++++------------ src/OpenFOAM/primitives/ints/int32/int32IO.C | 36 +++++++------------ src/OpenFOAM/primitives/ints/int64/int64IO.C | 36 +++++++------------ .../primitives/ints/uint32/uint32IO.C | 36 +++++++------------ .../primitives/ints/uint64/uint64IO.C | 36 +++++++------------ .../primitives/strings/parsing/parsing.C | 3 +- .../primitives/strings/parsing/parsing.H | 3 +- .../primitives/strings/parsing/parsingI.H | 2 +- 10 files changed, 79 insertions(+), 138 deletions(-) diff --git a/applications/test/primitives/Test-primitives.C b/applications/test/primitives/Test-primitives.C index 72017bfee9d..219b1ef5ec9 100644 --- a/applications/test/primitives/Test-primitives.C +++ b/applications/test/primitives/Test-primitives.C @@ -55,6 +55,7 @@ unsigned testParsing ) { unsigned nFail = 0; + string errMsg; // Expect some failures const bool prev = FatalIOError.throwExceptions(); @@ -74,6 +75,7 @@ unsigned testParsing catch (Foam::error& err) { parsed = false; + errMsg = err.message(); } if (parsed) @@ -93,12 +95,15 @@ unsigned testParsing if (expected) { ++nFail; - Info<< "(fail) unexpected failure " << str << nl; + Info<< "(fail) unexpected"; } else { - Info<< "(pass) expected failure " << str << nl; + Info<< "(pass) expected"; } + + Info<< " failure " << str + << " >> " << errMsg.c_str() << nl; } } @@ -125,6 +130,7 @@ int main(int argc, char *argv[]) { " 1234E junk", false }, { " 3.14159 ", true }, { " 31.4159E-1 " , true }, + { " 100E1000 " , false }, } ); } @@ -165,6 +171,7 @@ int main(int argc, char *argv[]) &readInt32, { { " 3.14159 ", false }, + { " 31E1 ", false }, { " 31.4159E-1 " , false }, { "100" , true }, { " 2147483644" , true }, @@ -174,13 +181,16 @@ int main(int argc, char *argv[]) } { - Info<< nl << "Test readUint32 (max= " << INT32_MAX << "):" << nl; + Info<< nl << "Test readUint32 (max= " + << unsigned(UINT32_MAX) << "):" << nl; nFail += testParsing ( &readUint32, { { " 2147483644" , true }, { " 2147483700 " , true }, + { " 4294967295 " , true }, + { " 4294968000 " , false }, } ); } diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.C b/src/OpenFOAM/primitives/Scalar/Scalar.C index d8eb7e06fc9..644e9abf12e 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.C +++ b/src/OpenFOAM/primitives/Scalar/Scalar.C @@ -102,18 +102,7 @@ bool readScalar(const char* buf, Scalar& val) val = ScalarConvert(buf, &endptr); - const parsing::errorType err = parsing::checkConversion(buf, endptr); - if (err != parsing::errorType::NONE) - { - #ifdef FULLDEBUG - IOWarningInFunction("unknown") - << parsing::errorNames[err] << " '" << buf << "'" - << endl; - #endif - return false; - } - - return true; + return (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE); } diff --git a/src/OpenFOAM/primitives/ints/int/intIO.C b/src/OpenFOAM/primitives/ints/int/intIO.C index 6a2901aefb0..f9a8e2a58b9 100644 --- a/src/OpenFOAM/primitives/ints/int/intIO.C +++ b/src/OpenFOAM/primitives/ints/int/intIO.C @@ -39,13 +39,13 @@ int Foam::readInt(const char* buf) const int val = int(parsed); - if (parsed < INT_MIN || parsed > INT_MAX) - { - // Range error - errno = ERANGE; - } + const parsing::errorType err = + ( + (parsed < INT_MIN || parsed > INT_MAX) + ? parsing::errorType::RANGE + : parsing::checkConversion(buf, endptr) + ); - const parsing::errorType err = parsing::checkConversion(buf, endptr); if (err != parsing::errorType::NONE) { FatalIOErrorInFunction("unknown") @@ -65,24 +65,12 @@ bool Foam::readInt(const char* buf, int& val) val = int(parsed); - if (parsed < INT_MIN || parsed > INT_MAX) - { - // Range error - errno = ERANGE; - } - - const parsing::errorType err = parsing::checkConversion(buf, endptr); - if (err != parsing::errorType::NONE) - { - #ifdef FULLDEBUG - IOWarningInFunction("unknown") - << parsing::errorNames[err] << " '" << buf << "'" - << endl; - #endif - return false; - } - - return true; + return + ( + (parsed < INT_MIN || parsed > INT_MAX) + ? false + : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE) + ); } diff --git a/src/OpenFOAM/primitives/ints/int32/int32IO.C b/src/OpenFOAM/primitives/ints/int32/int32IO.C index f1b4f23fb05..926421ff2b3 100644 --- a/src/OpenFOAM/primitives/ints/int32/int32IO.C +++ b/src/OpenFOAM/primitives/ints/int32/int32IO.C @@ -39,13 +39,13 @@ int32_t Foam::readInt32(const char* buf) const int32_t val = int32_t(parsed); - if (parsed < INT32_MIN || parsed > INT32_MAX) - { - // Range error - errno = ERANGE; - } + const parsing::errorType err = + ( + (parsed < INT32_MIN || parsed > INT32_MAX) + ? parsing::errorType::RANGE + : parsing::checkConversion(buf, endptr) + ); - const parsing::errorType err = parsing::checkConversion(buf, endptr); if (err != parsing::errorType::NONE) { FatalIOErrorInFunction("unknown") @@ -65,24 +65,12 @@ bool Foam::readInt32(const char* buf, int32_t& val) val = int32_t(parsed); - if (parsed < INT32_MIN || parsed > INT32_MAX) - { - // Range error - errno = ERANGE; - } - - const parsing::errorType err = parsing::checkConversion(buf, endptr); - if (err != parsing::errorType::NONE) - { - #ifdef FULLDEBUG - IOWarningInFunction("unknown") - << parsing::errorNames[err] << " '" << buf << "'" - << endl; - #endif - return false; - } - - return true; + return + ( + (parsed < INT32_MIN || parsed > INT32_MAX) + ? false + : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE) + ); } diff --git a/src/OpenFOAM/primitives/ints/int64/int64IO.C b/src/OpenFOAM/primitives/ints/int64/int64IO.C index d16d979d6f2..1a2ad639e3f 100644 --- a/src/OpenFOAM/primitives/ints/int64/int64IO.C +++ b/src/OpenFOAM/primitives/ints/int64/int64IO.C @@ -39,13 +39,13 @@ int64_t Foam::readInt64(const char* buf) const int64_t val = int64_t(parsed); - if (parsed < INT64_MIN || parsed > INT64_MAX) - { - // Range error - errno = ERANGE; - } + const parsing::errorType err = + ( + (parsed < INT64_MIN || parsed > INT64_MAX) + ? parsing::errorType::RANGE + : parsing::checkConversion(buf, endptr) + ); - const parsing::errorType err = parsing::checkConversion(buf, endptr); if (err != parsing::errorType::NONE) { FatalIOErrorInFunction("unknown") @@ -65,24 +65,12 @@ bool Foam::readInt64(const char* buf, int64_t& val) val = int64_t(parsed); - if (parsed < INT64_MIN || parsed > INT64_MAX) - { - // Range error - errno = ERANGE; - } - - const parsing::errorType err = parsing::checkConversion(buf, endptr); - if (err != parsing::errorType::NONE) - { - #ifdef FULLDEBUG - IOWarningInFunction("unknown") - << parsing::errorNames[err] << " '" << buf << "'" - << endl; - #endif - return false; - } - - return true; + return + ( + (parsed < INT64_MIN || parsed > INT64_MAX) + ? false + : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE) + ); } diff --git a/src/OpenFOAM/primitives/ints/uint32/uint32IO.C b/src/OpenFOAM/primitives/ints/uint32/uint32IO.C index bf4e6fb8a02..96fdc8c85bc 100644 --- a/src/OpenFOAM/primitives/ints/uint32/uint32IO.C +++ b/src/OpenFOAM/primitives/ints/uint32/uint32IO.C @@ -38,13 +38,13 @@ uint32_t Foam::readUint32(const char* buf) const uint32_t val = uint32_t(parsed); - if (parsed > UINT32_MAX) - { - // Range error - errno = ERANGE; - } + const parsing::errorType err = + ( + (parsed > UINT32_MAX) + ? parsing::errorType::RANGE + : parsing::checkConversion(buf, endptr) + ); - const parsing::errorType err = parsing::checkConversion(buf, endptr); if (err != parsing::errorType::NONE) { FatalIOErrorInFunction("unknown") @@ -64,24 +64,12 @@ bool Foam::readUint32(const char* buf, uint32_t& val) val = uint32_t(parsed); - if (parsed > UINT32_MAX) - { - // Range error - errno = ERANGE; - } - - const parsing::errorType err = parsing::checkConversion(buf, endptr); - if (err != parsing::errorType::NONE) - { - #ifdef FULLDEBUG - IOWarningInFunction("unknown") - << parsing::errorNames[err] << " '" << buf << "'" - << endl; - #endif - return false; - } - - return true; + return + ( + (parsed > UINT32_MAX) + ? false + : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE) + ); } diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64IO.C b/src/OpenFOAM/primitives/ints/uint64/uint64IO.C index 2f23b89ddde..b73e90e7714 100644 --- a/src/OpenFOAM/primitives/ints/uint64/uint64IO.C +++ b/src/OpenFOAM/primitives/ints/uint64/uint64IO.C @@ -38,13 +38,13 @@ uint64_t Foam::readUint64(const char* buf) const uint64_t val = uint64_t(parsed); - if (parsed > UINT64_MAX) - { - // Range error - errno = ERANGE; - } + const parsing::errorType err = + ( + (parsed > UINT64_MAX) + ? parsing::errorType::RANGE + : parsing::checkConversion(buf, endptr) + ); - const parsing::errorType err = parsing::checkConversion(buf, endptr); if (err != parsing::errorType::NONE) { FatalIOErrorInFunction("unknown") @@ -64,24 +64,12 @@ bool Foam::readUint64(const char* buf, uint64_t& val) val = uint64_t(parsed); - if (parsed > UINT64_MAX) - { - // Range error - errno = ERANGE; - } - - const parsing::errorType err = parsing::checkConversion(buf, endptr); - if (err != parsing::errorType::NONE) - { - #ifdef FULLDEBUG - IOWarningInFunction("unknown") - << parsing::errorNames[err] << " '" << buf << "'" - << endl; - #endif - return false; - } - - return true; + return + ( + (parsed > UINT64_MAX) + ? false + : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE) + ); } diff --git a/src/OpenFOAM/primitives/strings/parsing/parsing.C b/src/OpenFOAM/primitives/strings/parsing/parsing.C index 2b818295284..bb3a38564b3 100644 --- a/src/OpenFOAM/primitives/strings/parsing/parsing.C +++ b/src/OpenFOAM/primitives/strings/parsing/parsing.C @@ -30,7 +30,8 @@ License const Foam::Enum<Foam::parsing::errorType> Foam::parsing::errorNames { - { errorType::GENERAL, "General error parsing" }, + { errorType::GENERAL, "General error parsing" }, + { errorType::RANGE, "Range error while parsing" }, { errorType::TRAILING, "Trailing content found parsing" }, }; diff --git a/src/OpenFOAM/primitives/strings/parsing/parsing.H b/src/OpenFOAM/primitives/strings/parsing/parsing.H index bef3d34f9c0..925de3ccdba 100644 --- a/src/OpenFOAM/primitives/strings/parsing/parsing.H +++ b/src/OpenFOAM/primitives/strings/parsing/parsing.H @@ -56,7 +56,8 @@ namespace parsing { NONE = 0, //!< No error encountered GENERAL = 1, //!< General parsing error - TRAILING = 2, //!< Trailing content detected + RANGE = 2, //!< Range error + TRAILING = 3, //!< Trailing content detected }; diff --git a/src/OpenFOAM/primitives/strings/parsing/parsingI.H b/src/OpenFOAM/primitives/strings/parsing/parsingI.H index 7f6a4087a17..63e4209ba11 100644 --- a/src/OpenFOAM/primitives/strings/parsing/parsingI.H +++ b/src/OpenFOAM/primitives/strings/parsing/parsingI.H @@ -32,7 +32,7 @@ inline Foam::parsing::errorType Foam::parsing::checkConversion if (errno || endptr == buf) { // Some type of error OR no conversion - return errorType::GENERAL; + return (errno == ERANGE ? errorType::RANGE : errorType::GENERAL); } // Trailing spaces are permitted -- GitLab From 9b2a25516e6a1332fa5ebe5466fb4cd541a95b5b Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 12 Oct 2017 18:43:12 +0200 Subject: [PATCH 038/126] ENH: make creation of streamline seeds demand-driven --- .../field/streamLine/streamLine.C | 2 +- .../field/streamLine/streamLineBase.C | 113 +++++++++++------- .../field/streamLine/streamLineBase.H | 44 ++++--- .../wallBoundedStreamLine.C | 5 +- 4 files changed, 98 insertions(+), 66 deletions(-) diff --git a/src/functionObjects/field/streamLine/streamLine.C b/src/functionObjects/field/streamLine/streamLine.C index 131d3ba025d..46406489c78 100644 --- a/src/functionObjects/field/streamLine/streamLine.C +++ b/src/functionObjects/field/streamLine/streamLine.C @@ -52,7 +52,7 @@ void Foam::functionObjects::streamLine::track() initialParticles ); - const sampledSet& seedPoints = sampledSetPtr_(); + const sampledSet& seedPoints = sampledSetPoints(); forAll(seedPoints, i) { diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index 9eaae07a822..ac4153db68a 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -47,6 +47,38 @@ namespace functionObjects // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +const Foam::word& +Foam::functionObjects::streamLineBase::sampledSetAxis() const +{ + if (sampledSetPtr_.empty()) + { + sampledSetPoints(); + } + + return sampledSetAxis_; +} + + +const Foam::sampledSet& +Foam::functionObjects::streamLineBase::sampledSetPoints() const +{ + if (sampledSetPtr_.empty()) + { + sampledSetPtr_ = sampledSet::New + ( + "seedSampleSet", + mesh_, + meshSearchMeshObject::New(mesh_), + dict_.subDict("seedSampleSet") + ); + + sampledSetAxis_ = sampledSetPtr_->axis(); + } + + return sampledSetPtr_(); +} + + Foam::autoPtr<Foam::indirectPrimitivePatch> Foam::functionObjects::streamLineBase::wallPatch() const { @@ -54,12 +86,12 @@ Foam::functionObjects::streamLineBase::wallPatch() const label nFaces = 0; - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - //if (!polyPatch::constraintType(patches[patchi].type())) - if (isA<wallPolyPatch>(patches[patchi])) + //if (!polyPatch::constraintType(pp.type())) + if (isA<wallPolyPatch>(pp)) { - nFaces += patches[patchi].size(); + nFaces += pp.size(); } } @@ -67,13 +99,11 @@ Foam::functionObjects::streamLineBase::wallPatch() const nFaces = 0; - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - //if (!polyPatch::constraintType(patches[patchi].type())) - if (isA<wallPolyPatch>(patches[patchi])) + //if (!polyPatch::constraintType(pp.type())) + if (isA<wallPolyPatch>(pp)) { - const polyPatch& pp = patches[patchi]; - forAll(pp, i) { addressing[nFaces++] = pp.start()+i; @@ -110,24 +140,24 @@ void Foam::functionObjects::streamLineBase::initInterpolations label nScalar = 0; label nVector = 0; - forAll(fields_, i) + for (const word& fieldName : fields_) { - if (foundObject<volScalarField>(fields_[i])) + if (foundObject<volScalarField>(fieldName)) { nScalar++; } - else if (foundObject<volVectorField>(fields_[i])) + else if (foundObject<volVectorField>(fieldName)) { nVector++; } else { FatalErrorInFunction - << "Cannot find field " << fields_[i] << nl + << "Cannot find field " << fieldName << nl << "Valid scalar fields are:" - << mesh_.names(volScalarField::typeName) << nl + << flatOutput(mesh_.names(volScalarField::typeName)) << nl << "Valid vector fields are:" - << mesh_.names(volVectorField::typeName) + << flatOutput(mesh_.names(volVectorField::typeName)) << exit(FatalError); } } @@ -136,12 +166,11 @@ void Foam::functionObjects::streamLineBase::initInterpolations vvInterp.setSize(nVector); nVector = 0; - forAll(fields_, i) + for (const word& fieldName : fields_) { - if (foundObject<volScalarField>(fields_[i])) + if (foundObject<volScalarField>(fieldName)) { - const volScalarField& f = - lookupObject<volScalarField>(fields_[i]); + const volScalarField& f = lookupObject<volScalarField>(fieldName); vsInterp.set ( nScalar++, @@ -152,10 +181,9 @@ void Foam::functionObjects::streamLineBase::initInterpolations ) ); } - else if (foundObject<volVectorField>(fields_[i])) + else if (foundObject<volVectorField>(fieldName)) { - const volVectorField& f = - lookupObject<volVectorField>(fields_[i]); + const volVectorField& f = lookupObject<volVectorField>(fieldName); if (f.name() == UName_) { @@ -231,7 +259,7 @@ void Foam::functionObjects::streamLineBase::storePoint DynamicList<vectorList>& newVectors ) const { - label sz = newTrack.size(); + const label sz = newTrack.size(); const List<point>& track = allTracks_[tracki]; @@ -274,6 +302,7 @@ void Foam::functionObjects::streamLineBase::trimToBox ) const { const List<point>& track = allTracks_[tracki]; + if (track.size()) { for @@ -287,7 +316,7 @@ void Foam::functionObjects::streamLineBase::trimToBox const point& endPt = track[segmenti]; const vector d(endPt-startPt); - scalar magD = mag(d); + const scalar magD = mag(d); if (magD > ROOTVSMALL) { if (bb.contains(startPt)) @@ -507,6 +536,12 @@ Foam::functionObjects::streamLineBase::~streamLineBase() bool Foam::functionObjects::streamLineBase::read(const dictionary& dict) { + if (&dict_ != &dict) + { + // Update local copy of dictionary: + dict_ = dict; + } + fvMeshFunctionObject::read(dict); Info<< type() << " " << name() << ":" << nl; @@ -536,10 +571,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict) trackLength_ = VGREAT; - if (dict.found("trackLength")) + if (dict.readIfPresent("trackLength", trackLength_)) { - dict.lookup("trackLength") >> trackLength_; - Info<< type() << " : fixed track length specified : " << trackLength_ << nl << endl; } @@ -562,14 +595,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict) cloudName_ = dict.lookupOrDefault<word>("cloud", type()); - sampledSetPtr_ = sampledSet::New - ( - "seedSampleSet", - mesh_, - meshSearchMeshObject::New(mesh_), - dict.subDict("seedSampleSet") - ); - sampledSetAxis_ = sampledSetPtr_->axis(); + sampledSetPtr_.clear(); + sampledSetAxis_.clear(); scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat")); vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat")); @@ -756,7 +783,7 @@ bool Foam::functionObjects::streamLineBase::write() new coordSet ( "track" + Foam::name(nTracks), - sampledSetAxis_ //"xyz" + sampledSetAxis() // "xyz" ) ); oldToNewTrack[tracki] = nTracks; @@ -767,7 +794,7 @@ bool Foam::functionObjects::streamLineBase::write() // Convert scalar values - if (allScalars_.size() > 0 && tracks.size() > 0) + if (!allScalars_.empty() && !tracks.empty()) { List<List<scalarField>> scalarValues(allScalars_.size()); @@ -781,7 +808,7 @@ bool Foam::functionObjects::streamLineBase::write() scalarList& vals = allTrackVals[tracki]; if (vals.size()) { - label newTracki = oldToNewTrack[tracki]; + const label newTracki = oldToNewTrack[tracki]; scalarValues[scalari][newTracki].transfer(vals); } } @@ -811,7 +838,7 @@ bool Foam::functionObjects::streamLineBase::write() // Convert vector values - if (allVectors_.size() > 0 && tracks.size() > 0) + if (!allVectors_.empty() && !tracks.empty()) { List<List<vectorField>> vectorValues(allVectors_.size()); @@ -825,7 +852,7 @@ bool Foam::functionObjects::streamLineBase::write() vectorList& vals = allTrackVals[tracki]; if (vals.size()) { - label newTracki = oldToNewTrack[tracki]; + const label newTracki = oldToNewTrack[tracki]; vectorValues[vectori][newTracki].transfer(vals); } } @@ -854,20 +881,18 @@ bool Foam::functionObjects::streamLineBase::write() // File names are generated on the master but setProperty needs to // be across all procs Pstream::scatter(scalarVtkFile); - forAll(scalarNames_, namei) + for (const word& fieldName : scalarNames_) { dictionary propsDict; propsDict.add("file", scalarVtkFile); - const word& fieldName = scalarNames_[namei]; setProperty(fieldName, propsDict); } Pstream::scatter(vectorVtkFile); - forAll(vectorNames_, namei) + for (const word& fieldName : vectorNames_) { dictionary propsDict; propsDict.add("file", vectorVtkFile); - const word& fieldName = vectorNames_[namei]; setProperty(fieldName, propsDict); } diff --git a/src/functionObjects/field/streamLine/streamLineBase.H b/src/functionObjects/field/streamLine/streamLineBase.H index a87e3fd2109..881ef4d140d 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.H +++ b/src/functionObjects/field/streamLine/streamLineBase.H @@ -63,6 +63,14 @@ class streamLineBase : public fvMeshFunctionObject { + // Private data + + //- Seed set engine + mutable autoPtr<sampledSet> sampledSetPtr_; + + //- Axis of the sampled points to output + mutable word sampledSetAxis_; + protected: //- Input dictionary @@ -102,35 +110,35 @@ protected: wordList vectorNames_; - // Demand driven + // Demand driven - //- Mesh searching enigne - autoPtr<meshSearch> meshSearchPtr_; + //- File writer for scalar data + autoPtr<writer<scalar>> scalarFormatterPtr_; - //- Seed set engine - autoPtr<sampledSet> sampledSetPtr_; + //- File writer for vector data + autoPtr<writer<vector>> vectorFormatterPtr_; - //- Axis of the sampled points to output - word sampledSetAxis_; - //- File writer for scalar data - autoPtr<writer<scalar>> scalarFormatterPtr_; + // Generated data - //- File writer for vector data - autoPtr<writer<vector>> vectorFormatterPtr_; + //- All tracks. Per track the points it passed through + DynamicList<List<point>> allTracks_; + //- Per scalarField, per track, the sampled values + List<DynamicList<scalarList>> allScalars_; - // Generated data + //- Per vectorField, per track, the sampled values + List<DynamicList<vectorList>> allVectors_; - //- All tracks. Per track the points it passed through - DynamicList<List<point>> allTracks_; - //- Per scalarField, per track, the sampled values - List<DynamicList<scalarList>> allScalars_; + // Protected Member Functions - //- Per vectorField, per track, the sampled values - List<DynamicList<vectorList>> allVectors_; + //- The axis of the sampledSet. Creates sampledSet if required. + const word& sampledSetAxis() const; + //- Demand driven construction of the sampledSet. + // Also updates sampledSetAxis_ + const sampledSet& sampledSetPoints() const; //- Construct patch out of all wall patch faces autoPtr<indirectPrimitivePatch> wallPatch() const; diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C index ce96d787142..d5b25603293 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C @@ -131,12 +131,11 @@ void Foam::functionObjects::wallBoundedStreamLine::track() // Get the seed points // ~~~~~~~~~~~~~~~~~~~ - const sampledSet& seedPoints = sampledSetPtr_(); - + const sampledSet& seedPoints = sampledSetPoints(); forAll(seedPoints, i) { - label celli = seedPoints.cells()[i]; + const label celli = seedPoints.cells()[i]; if (celli != -1) { -- GitLab From b29f2a61b6237ba68fba0bf2bb5b655d2823039e Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 13 Oct 2017 12:45:28 +0200 Subject: [PATCH 039/126] BUG: missing parallel-aware for metis-like decomposition --- applications/test/decomposePar/Make/options | 3 +- .../cellSizeAndAlignmentGrid/Make/options | 3 +- .../foamyMesh/foamyHexMesh/Make/options | 3 +- .../foamyHexMeshSurfaceSimplify/Make/options | 4 +- .../foamyMesh/foamyQuadMesh/Make/options | 3 +- .../generation/snappyHexMesh/Make/options | 5 +- .../manipulation/renumberMesh/Make/options | 3 +- .../decomposePar/Make/options | 3 +- .../redistributePar/Make/options | 3 +- .../metisLikeDecomp/metisLikeDecomp.C | 11 +- .../decompose/kahipDecomp/kahipDecomp.C | 4 +- .../decompose/metisDecomp/metisDecomp.C | 7 +- .../externalSolarLoad/Allrun | 9 +- .../externalSolarLoad/Allrun-parallel | 14 +- .../externalSolarLoad/Allrun.pre | 17 +-- .../Allrun-parallel | 9 +- tutorials/mesh/parallel/cavity/Allclean | 7 +- tutorials/mesh/parallel/cavity/Allrun | 18 +-- .../parallel/cavity/system/decomposeParDict | 15 +- .../parallel/cavity/system/decomposeParDict-2 | 143 ------------------ .../parallel/cavity/system/decomposeParDict-5 | 15 +- 21 files changed, 80 insertions(+), 219 deletions(-) delete mode 100644 tutorials/mesh/parallel/cavity/system/decomposeParDict-2 diff --git a/applications/test/decomposePar/Make/options b/applications/test/decomposePar/Make/options index 1f62e3ffa8a..a81cfd44fcf 100644 --- a/applications/test/decomposePar/Make/options +++ b/applications/test/decomposePar/Make/options @@ -8,5 +8,6 @@ EXE_INC = \ EXE_LIBS = \ -ldecompose \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp -lkahipDecomp \ + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lscotchDecomp \ -lregionModels diff --git a/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options b/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options index 386b6690838..703a72fcc0f 100644 --- a/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options +++ b/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options @@ -28,5 +28,6 @@ EXE_LIBS = \ -lmeshTools \ -lsampling \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp \ + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \ -ldynamicMesh diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options index 40373bec9dd..772de8d78a4 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options @@ -31,5 +31,6 @@ EXE_LIBS = \ -lsampling \ -ldecompositionMethods \ -ldecompose \ - -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp -lscotchDecomp \ + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \ -ldynamicMesh diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options index 66ddf81aac5..67cd78a01af 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options @@ -18,6 +18,8 @@ EXE_LIBS = \ -L$(FASTDUALOCTREE_SRC_PATH) -lperf_main \ -lGL \ -lconformalVoronoiMesh \ - -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lscotchDecomp \ + -ldecompositionMethods \ + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lscotchDecomp \ -lmeshTools \ -ldynamicMesh diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options index 1b509ac9df0..ed15cdf94e3 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options @@ -31,4 +31,5 @@ EXE_LIBS = \ -lsampling \ -ldynamicMesh \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp diff --git a/applications/utilities/mesh/generation/snappyHexMesh/Make/options b/applications/utilities/mesh/generation/snappyHexMesh/Make/options index bb863797fae..ed8acb579c1 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/Make/options +++ b/applications/utilities/mesh/generation/snappyHexMesh/Make/options @@ -13,9 +13,8 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \ - /* note: scotch < 6.0 does not like both scotch and ptscotch together */ \ - -lscotchDecomp \ + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \ -lmeshTools \ -ldynamicMesh \ -ldecompose \ diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options index 5803e893aac..e2343e6ee69 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options +++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options @@ -18,4 +18,5 @@ EXE_LIBS = \ -lreconstruct \ $(LINK_FLAGS) \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp -lkahipDecomp + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lscotchDecomp diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index 34f3e5de333..7e74790e00d 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -12,7 +12,8 @@ EXE_LIBS = \ -ldecompose \ -lgenericPatchFields \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp -lkahipDecomp \ + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lscotchDecomp \ -llagrangian \ -ldynamicMesh \ -lregionModels diff --git a/applications/utilities/parallelProcessing/redistributePar/Make/options b/applications/utilities/parallelProcessing/redistributePar/Make/options index 189902467f7..46f67054e24 100644 --- a/applications/utilities/parallelProcessing/redistributePar/Make/options +++ b/applications/utilities/parallelProcessing/redistributePar/Make/options @@ -11,7 +11,8 @@ EXE_LIBS = \ -lfiniteVolume \ -lgenericPatchFields \ -ldecompositionMethods \ - -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp -lscotchDecomp \ + -L$(FOAM_LIBBIN)/dummy \ + -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \ -ldecompose \ -lmeshTools \ -llagrangian \ diff --git a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C index a5dffec83c0..232a351f596 100644 --- a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C +++ b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C @@ -181,7 +181,7 @@ Foam::labelList Foam::metisLikeDecomp::decompose mesh, identity(mesh.nCells()), mesh.nCells(), - false, + true, cellCells ); @@ -214,7 +214,14 @@ Foam::labelList Foam::metisLikeDecomp::decompose // xadj(celli) : start of information in adjncy for celli CompactListList<label> cellCells; - calcCellCells(mesh, agglom, agglomPoints.size(), false, cellCells); + calcCellCells + ( + mesh, + agglom, + agglomPoints.size(), + true, + cellCells + ); // Decompose using default weights labelList decomp; diff --git a/src/parallel/decompose/kahipDecomp/kahipDecomp.C b/src/parallel/decompose/kahipDecomp/kahipDecomp.C index 180f8783e04..55cba9cfc38 100644 --- a/src/parallel/decompose/kahipDecomp/kahipDecomp.C +++ b/src/parallel/decompose/kahipDecomp/kahipDecomp.C @@ -92,7 +92,9 @@ Foam::label Foam::kahipDecomp::decomposeSerial List<int> cellWeights; // Check for externally provided cellweights and if so initialise weights - const scalar minWeights = gMin(cWeights); + // Note: min, not gMin since routine runs on master only. + const scalar minWeights = min(cWeights); + if (!cWeights.empty()) { if (minWeights <= 0) diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.C b/src/parallel/decompose/metisDecomp/metisDecomp.C index cfc896d2518..3822a0a31e2 100644 --- a/src/parallel/decompose/metisDecomp/metisDecomp.C +++ b/src/parallel/decompose/metisDecomp/metisDecomp.C @@ -77,10 +77,11 @@ Foam::label Foam::metisDecomp::decomposeSerial // Face weights (so on the edges of the dual) List<label> faceWeights; - // Check for externally provided cellweights and if so initialise weights - const scalar minWeights = gMin(cWeights); - if (cWeights.size() > 0) + // Note: min, not gMin since routine runs on master only. + const scalar minWeights = min(cWeights); + + if (!cWeights.empty()) { if (minWeights <= 0) { diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun index c20d1cd3be0..f59f69f8c19 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun @@ -12,20 +12,21 @@ cd ${0%/*} || exit 1 # Run from this directory # Agglomerate patch faces for i in air do - faceAgglomerate -region $i -dict constant/viewFactorsDict > log.faceAgglomerate.$i 2>&1 + runApplication -s $i \ + faceAgglomerate -region $i -dict constant/viewFactorsDict done # Generate view factors for i in air do - viewFactorsGen -region $i > log.viewFactorsGen.$i 2>&1 + runApplication -s $i \ + viewFactorsGen -region $i done runApplication $(getApplication) - echo -echo "creating files for paraview post-processing" +echo "Creating files for paraview post-processing" echo paraFoam -touchAll diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel index 32453b285e7..7f0488b40f1 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Setup case ./Allrun.pre @@ -15,18 +13,18 @@ runApplication decomposePar -allRegions -constant # Agglomerate patch faces for i in air do - runParallel -s $i -np 4 \ + runParallel -s $i \ faceAgglomerate -region $i -dict constant/viewFactorsDict done # Generate view factors for i in air do - runParallel -s $i -np 4 \ + runParallel -s $i \ viewFactorsGen -region $i done -# set the initial fields +# Set the initial fields restore0Dir runParallel $(getApplication) @@ -35,7 +33,7 @@ runParallel $(getApplication) runApplication reconstructPar -allRegions echo -echo "creating files for paraview post-processing" +echo "Creating files for paraview post-processing" echo paraFoam -touchAll diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre index ad4135ab5cb..5094b7903f6 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre @@ -1,30 +1,27 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet runApplication splitMeshRegions -cellZones -overwrite # Remove unwanted region -rm -r 0/domain3 -rm -r constant/domain3 -rm -r system/domain3 +rm -rf 0/domain3 constant/domain3 system/domain3 -# remove fluid fields from solid regions (important for post-processing) +# Remove fluid fields from solid regions (important for post-processing) for i in solid floor do rm -f 0*/$i/{rho,mut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault} done -# set the initial fields +# Set the initial fields restore0Dir for i in air solid floor do - runApplication -s $i changeDictionary -region $i -subDict dictionaryReplacement + runApplication -s $i changeDictionary \ + -region $i -subDict dictionaryReplacement done # ----------------------------------------------------------------------------- diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel index f8131b1da89..ddcb5a103ff 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel @@ -4,11 +4,9 @@ cd ${0%/*} || exit 1 # Run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions - # Setup case ./Allrun.pre - #-- Run in parallel # Decompose @@ -17,14 +15,14 @@ runApplication decomposePar -allRegions # Agglomerate patch faces for i in bottomAir topAir do - runParallel -s $i -np 4 \ + runParallel -s $i \ faceAgglomerate -region $i -dict constant/viewFactorsDict done # Generate view factors for i in bottomAir topAir do - runParallel -s $i -np 4 \ + runParallel -s $i \ viewFactorsGen -region $i done @@ -34,9 +32,8 @@ runParallel $(getApplication) # Reconstruct runApplication reconstructPar -allRegions - echo -echo "creating files for paraview post-processing" +echo "Creating files for paraview post-processing" echo paraFoam -touchAll diff --git a/tutorials/mesh/parallel/cavity/Allclean b/tutorials/mesh/parallel/cavity/Allclean index 1ddaee91ff1..ee9845194cb 100755 --- a/tutorials/mesh/parallel/cavity/Allclean +++ b/tutorials/mesh/parallel/cavity/Allclean @@ -1,13 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase # Restore default dictionaries -cp system/decomposeParDict-2 system/decomposeParDict cp system/controlDict-startTime system/controlDict # ----------------------------------------------------------------------------- diff --git a/tutorials/mesh/parallel/cavity/Allrun b/tutorials/mesh/parallel/cavity/Allrun index 26c8762dcc9..6c7668f4faf 100755 --- a/tutorials/mesh/parallel/cavity/Allrun +++ b/tutorials/mesh/parallel/cavity/Allrun @@ -1,13 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh -#cp system/decomposeParDict-2 system/decomposeParDict -#runApplication decomposePar +decompDict5="-decomposeParDict system/decomposeParDict-5" # redistributePar to do decomposition runParallel -s decompose redistributePar -decompose @@ -25,15 +22,12 @@ runParallel -s random icoFoam cp system/controlDict-latestTime system/controlDict # Redistribute to 5 processors -runParallel -s 5 -np 5 redistributePar \ - -decomposeParDict system/decomposeParDict-5 -cellDist +runParallel -s 5 $decompDict5 redistributePar -cellDist # Run a bit more -runParallel -s 5 -np 5 icoFoam \ - -decomposeParDict system/decomposeParDict-5 +runParallel -s 5 $decompDict5 icoFoam # Reconstruct mesh and results -runParallel -s reconstruct -np 5 redistributePar -reconstruct - +runParallel -s reconstruct -np 5 redistributePar -reconstruct # ----------------------------------------------------------------------------- diff --git a/tutorials/mesh/parallel/cavity/system/decomposeParDict b/tutorials/mesh/parallel/cavity/system/decomposeParDict index 8c054db9bbb..01c1ede6e17 100644 --- a/tutorials/mesh/parallel/cavity/system/decomposeParDict +++ b/tutorials/mesh/parallel/cavity/system/decomposeParDict @@ -43,13 +43,14 @@ numberOfSubdomains 2; // for a balanced number of particles in a lagrangian simulation. // weightField dsmcRhoNMean; -method scotch; -//method hierarchical; -// method simple; -// method metis; -// method manual; -// method multiLevel; -// method structured; // does 2D decomposition of structured mesh +method scotch; +// method kahip; +// method metis; +// method hierarchical; +// method simple; +// method manual; +// method multiLevel; +// method structured; // does 2D decomposition of structured mesh multiLevelCoeffs { diff --git a/tutorials/mesh/parallel/cavity/system/decomposeParDict-2 b/tutorials/mesh/parallel/cavity/system/decomposeParDict-2 deleted file mode 100644 index 8c054db9bbb..00000000000 --- a/tutorials/mesh/parallel/cavity/system/decomposeParDict-2 +++ /dev/null @@ -1,143 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - note "mesh decomposition control dictionary"; - object decomposeParDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -numberOfSubdomains 2; - -//- Keep owner and neighbour on same processor for faces in zones: -// preserveFaceZones (heater solid1 solid3); - -//- Keep owner and neighbour on same processor for faces in patches: -// (makes sense only for cyclic patches) -//preservePatches (cyclic_half0 cyclic_half1); - -//- Keep all of faceSet on a single processor. This puts all cells -// connected with a point, edge or face on the same processor. -// (just having face connected cells might not guarantee a balanced -// decomposition) -// The processor can be -1 (the decompositionMethod chooses the processor -// for a good load balance) or explicitly provided (upsets balance). -//singleProcessorFaceSets ((f0 -1)); - - -//- Keep owner and neighbour of baffles on same processor (i.e. keep it -// detectable as a baffle). Baffles are two boundary face sharing the -// same points. -//preserveBaffles true; - -//- Use the volScalarField named here as a weight for each cell in the -// decomposition. For example, use a particle population field to decompose -// for a balanced number of particles in a lagrangian simulation. -// weightField dsmcRhoNMean; - -method scotch; -//method hierarchical; -// method simple; -// method metis; -// method manual; -// method multiLevel; -// method structured; // does 2D decomposition of structured mesh - -multiLevelCoeffs -{ - // Decomposition methods to apply in turn. This is like hierarchical but - // fully general - every method can be used at every level. - - level0 - { - numberOfSubdomains 64; - //method simple; - //simpleCoeffs - //{ - // n (2 1 1); - // delta 0.001; - //} - method scotch; - } - level1 - { - numberOfSubdomains 4; - method scotch; - } -} - -// Desired output - -simpleCoeffs -{ - n (2 1 1); - delta 0.001; -} - -hierarchicalCoeffs -{ - n (1 2 1); - delta 0.001; - order xyz; -} - -metisCoeffs -{ - /* - processorWeights - ( - 1 - 1 - 1 - 1 - ); - */ -} - -scotchCoeffs -{ - //processorWeights - //( - // 1 - // 1 - // 1 - // 1 - //); - //writeGraph true; - //strategy "b"; -} - -manualCoeffs -{ - dataFile "decompositionData"; -} - -structuredCoeffs -{ - // Patches to do 2D decomposition on. Structured mesh only; cells have - // to be in 'columns' on top of patches. - patches (movingWall); - - // Method to use on the 2D subset - method scotch; -} - -//// Is the case distributed? Note: command-line argument -roots takes -//// precedence -//distributed yes; -//// Per slave (so nProcs-1 entries) the directory above the case. -//roots -//( -// "/tmp" -// "/tmp" -//); - -// ************************************************************************* // diff --git a/tutorials/mesh/parallel/cavity/system/decomposeParDict-5 b/tutorials/mesh/parallel/cavity/system/decomposeParDict-5 index 0692228c7c8..00c7e2a0a75 100644 --- a/tutorials/mesh/parallel/cavity/system/decomposeParDict-5 +++ b/tutorials/mesh/parallel/cavity/system/decomposeParDict-5 @@ -43,13 +43,14 @@ numberOfSubdomains 5; // for a balanced number of particles in a lagrangian simulation. // weightField dsmcRhoNMean; -method scotch; -//method hierarchical; -// method simple; -// method metis; -// method manual; -// method multiLevel; -// method structured; // does 2D decomposition of structured mesh +method scotch; +// method kahip; +// method metis; +// method hierarchical; +// method simple; +// method manual; +// method multiLevel; +// method structured; // does 2D decomposition of structured mesh multiLevelCoeffs { -- GitLab From 10c512f9efa97d31ad257ba4a5d2bdcb5b892d19 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Thu, 19 Oct 2017 17:25:53 +0200 Subject: [PATCH 040/126] STYLE: note correct defaults for profiling --- src/OpenFOAM/global/profiling/profiling.C | 4 ++-- src/OpenFOAM/global/profiling/profiling.H | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/global/profiling/profiling.C b/src/OpenFOAM/global/profiling/profiling.C index 2c212044182..e6a85fbefe6 100644 --- a/src/OpenFOAM/global/profiling/profiling.C +++ b/src/OpenFOAM/global/profiling/profiling.C @@ -48,8 +48,7 @@ Foam::profilingInformation* Foam::profiling::find const label parentId ) { - StorageContainer::iterator iter = hash_.find(Key(descr, parentId)); - return (iter.found() ? iter() : 0); + return hash_.lookup(Key(descr, parentId), nullptr); } @@ -313,6 +312,7 @@ const Foam::Time& Foam::profiling::owner() const return owner_; } + Foam::label Foam::profiling::size() const { return stack_.size(); diff --git a/src/OpenFOAM/global/profiling/profiling.H b/src/OpenFOAM/global/profiling/profiling.H index 4b6fc498206..0059dfb2aa5 100644 --- a/src/OpenFOAM/global/profiling/profiling.H +++ b/src/OpenFOAM/global/profiling/profiling.H @@ -33,9 +33,9 @@ Description profiling { active true; - cpuInfo true; + cpuInfo false; memInfo false; - sysInfo true; + sysInfo false; } \endcode or simply using all defaults: -- GitLab From e16121af68622af30e5d2106609417d1adc86be0 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Thu, 19 Oct 2017 18:04:24 +0200 Subject: [PATCH 041/126] ENH: emit number of blocks for decomposedBlockData in header - better documentation of the file contents. - quicker to obtain number of blocks without reading an entire file. --- .../decomposedBlockData/decomposedBlockData.C | 26 +++++++++++++++++-- .../collatedFileOperation.C | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C index d5a93363386..21ad121dfb9 100644 --- a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C +++ b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C @@ -30,8 +30,9 @@ License #include "Fstream.H" #include "StringStream.H" #include "dictionary.H" -#include <sys/time.h> #include "objectRegistry.H" +#include "foamVersion.H" +#include <sys/time.h> // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -204,6 +205,20 @@ void Foam::decomposedBlockData::writeHeader << " version " << version << ";\n" << " format " << format << ";\n" << " class " << type << ";\n"; + + // This may be useful to have as well + /* + if (os.format() == IOstream::BINARY) + { + os << " arch " << Foam::FOAMbuildArch << ";\n"; + } + */ + + if (Pstream::parRun()) + { + os << " blocks " << Pstream::nProcs() << ";\n"; + } + if (note.size()) { os << " note " << note << ";\n"; @@ -938,7 +953,7 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName) return nBlocks; } - // Skip header + // FoamFile header token firstToken(is); if @@ -951,8 +966,15 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName) dictionary headerDict(is); is.version(headerDict.lookup("version")); is.format(headerDict.lookup("format")); + + // Obtain number of blocks directly + if (headerDict.readIfPresent("blocks", nBlocks)) + { + return nBlocks; + } } + // Fallback to brute force read of each data block List<char> data; while (is.good()) { diff --git a/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C b/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C index b5dbb13517b..dd105496a4e 100644 --- a/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C @@ -200,7 +200,7 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation << " may \"hang\". If thread support cannot be " "enabled, deactivate threading" << nl << " by setting maxThreadFileBufferSize to 0 in " - "$FOAM_ETC/controlDict" + "the OpenFOAM etc/controlDict" << endl; } -- GitLab From c792a9d7df3b6f43d021975b56202c0581a06d28 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 12 Oct 2017 19:20:56 +0200 Subject: [PATCH 042/126] TUT: script cleanup, provide cleanCase0 for commonly used operation --- .../surface/surfaceBooleanFeatures/Allwmake | 2 +- bin/foamCleanTutorials | 4 +- bin/foamRunTutorials | 8 +- bin/tools/CleanFunctions | 30 ++-- bin/tools/RunFunctions | 150 ++++++++++-------- src/mesh/Allwmake | 2 +- tutorials/DNS/dnsFoam/boxTurb16/Allclean | 6 +- tutorials/DNS/dnsFoam/boxTurb16/Allrun | 6 +- tutorials/IO/fileHandler/Allclean | 6 +- tutorials/IO/fileHandler/Allrun | 6 +- tutorials/IO/fileHandler/Alltest | 6 +- tutorials/basic/laplacianFoam/flange/Allclean | 6 +- tutorials/basic/laplacianFoam/flange/Allrun | 6 +- .../heatTransfer/Allclean | 9 +- .../overLaplacianDyMFoam/heatTransfer/Allrun | 4 +- .../heatTransfer/Allrun.pre | 4 +- .../basic/potentialFoam/cylinder/Allclean | 9 +- tutorials/basic/potentialFoam/cylinder/Allrun | 6 +- .../basic/potentialFoam/pitzDaily/Allclean | 9 +- .../basic/potentialFoam/pitzDaily/Allrun | 6 +- .../flamePropagationWithObstacles/Allclean | 9 +- .../flamePropagationWithObstacles/Allrun | 6 +- .../annularCombustorTurbine/Allclean | 9 +- .../XiDyMFoam/annularCombustorTurbine/Allrun | 6 +- .../annularCombustorTurbine/Allrun.mesh | 6 +- tutorials/combustion/XiFoam/RAS/Allclean | 12 +- tutorials/combustion/XiFoam/RAS/Allrun | 6 +- tutorials/combustion/chemFoam/gri/Allclean | 9 +- tutorials/combustion/chemFoam/gri/Allrun | 6 +- tutorials/combustion/chemFoam/h2/Allclean | 9 +- tutorials/combustion/chemFoam/h2/Allrun | 6 +- tutorials/combustion/chemFoam/ic8h18/Allclean | 9 +- tutorials/combustion/chemFoam/ic8h18/Allrun | 6 +- .../combustion/chemFoam/ic8h18_TDAC/Allclean | 9 +- .../combustion/chemFoam/ic8h18_TDAC/Allrun | 6 +- .../ic8h18_TDAC/validation/createGraph | 2 +- tutorials/combustion/chemFoam/nc7h16/Allclean | 9 +- tutorials/combustion/chemFoam/nc7h16/Allrun | 6 +- .../combustion/engineFoam/kivaTest/Allclean | 9 +- .../combustion/engineFoam/kivaTest/Allrun | 6 +- .../fireFoam/LES/compartmentFire/Allclean | 8 +- .../fireFoam/LES/compartmentFire/Allrun | 8 +- .../flameSpreadWaterSuppressionPanel/Allclean | 6 +- .../flameSpreadWaterSuppressionPanel/Allrun | 6 +- .../LES/oppositeBurningPanels/Allclean | 6 +- .../fireFoam/LES/oppositeBurningPanels/Allrun | 6 +- .../fireFoam/LES/simplePMMApanel/Allclean | 8 +- .../fireFoam/LES/simplePMMApanel/Allrun | 8 +- .../fireFoam/LES/smallPoolFire2D/Allclean | 6 +- .../fireFoam/LES/smallPoolFire2D/Allrun | 6 +- .../fireFoam/LES/smallPoolFire3D/Allclean | 6 +- .../fireFoam/LES/smallPoolFire3D/Allrun | 6 +- .../reactingFoam/RAS/DLR_A_LTS/Allclean | 6 +- .../reactingFoam/RAS/DLR_A_LTS/Allrun | 6 +- .../reactingFoam/RAS/SandiaD_LTS/Allclean | 10 +- .../reactingFoam/RAS/SandiaD_LTS/Allrun | 6 +- .../rhoCentralFoam/biconic25-55Run35/Allclean | 6 +- .../rhoCentralFoam/biconic25-55Run35/Allrun | 6 +- .../rhoCentralFoam/shockTube/Allclean | 9 +- .../rhoCentralFoam/shockTube/Allrun | 6 +- .../rutlandVortex2D/Allclean | 10 +- .../rutlandVortex2D/Allrun | 8 +- .../annularThermalMixer/Allclean | 9 +- .../annularThermalMixer/Allrun | 6 +- .../rhoPimpleFoam/RAS/angledDuct/Allrun | 6 +- .../rhoPimpleFoam/RAS/angledDuctLTS/Allrun | 6 +- .../rhoPimpleFoam/RAS/mixerVessel2D/Allrun | 6 +- .../rhoPimpleFoam/RAS/mixerVessel2D/makeMesh | 8 +- .../laminar/helmholtzResonance/Allclean | 6 +- .../laminar/helmholtzResonance/Allrun | 6 +- .../laminar/sineWaveDamping/Allclean | 6 +- .../laminar/sineWaveDamping/Allrun | 6 +- .../angledDuct/explicit/Allclean | 10 +- .../angledDuct/explicit/Allrun | 6 +- .../angledDuct/implicit/Allclean | 10 +- .../angledDuct/implicit/Allrun | 6 +- .../angledDuctExplicitFixedCoeff/Allrun | 6 +- .../gasMixing/injectorPipe/Allclean | 9 +- .../gasMixing/injectorPipe/Allrun | 6 +- .../gasMixing/injectorPipe/Allrun.mesh | 6 +- .../sonicFoam/RAS/nacaAirfoil/Allclean | 6 +- .../sonicFoam/RAS/nacaAirfoil/Allrun | 6 +- .../sonicFoam/laminar/shockTube/Allclean | 9 +- .../sonicFoam/laminar/shockTube/Allrun | 6 +- .../compressible/sonicLiquidFoam/Allclean | 6 +- tutorials/compressible/sonicLiquidFoam/Allrun | 6 +- .../dsmcFoam/freeSpacePeriodic/Allclean | 7 +- .../dsmcFoam/freeSpacePeriodic/Allrun | 6 +- .../dsmcFoam/freeSpaceStream/Allclean | 7 +- .../dsmcFoam/freeSpaceStream/Allrun | 6 +- .../dsmcFoam/supersonicCorner/Allclean | 7 +- .../dsmcFoam/supersonicCorner/Allrun | 6 +- .../dsmcFoam/wedge15Ma5/Allclean | 7 +- .../dsmcFoam/wedge15Ma5/Allrun | 6 +- .../periodicCubeArgon/Allclean | 6 +- .../periodicCubeArgon/Allrun | 6 +- .../periodicCubeWater/Allclean | 6 +- .../periodicCubeWater/Allrun | 6 +- .../mdFoam/nanoNozzle/Allclean | 6 +- .../mdFoam/nanoNozzle/Allrun | 6 +- .../mhdFoam/hartmann/Allclean | 6 +- .../electromagnetics/mhdFoam/hartmann/Allrun | 6 +- .../hotRoom/Allclean | 6 +- .../hotRoom/Allrun | 6 +- .../hotRoom/Allclean | 6 +- .../hotRoom/Allrun | 6 +- .../iglooWithFridges/Allrun | 6 +- .../buoyantPimpleFoam/hotRoom/Allclean | 9 +- .../buoyantPimpleFoam/hotRoom/Allrun | 6 +- .../thermocoupleTestCase/Allclean | 6 +- .../thermocoupleTestCase/Allrun | 6 +- .../buoyantSimpleFoam/buoyantCavity/Allclean | 6 +- .../buoyantSimpleFoam/buoyantCavity/Allrun | 6 +- .../circuitBoardCooling/Allclean | 9 +- .../circuitBoardCooling/Allrun | 6 +- .../hotRadiationRoom/Allclean | 6 +- .../buoyantSimpleFoam/hotRadiationRoom/Allrun | 6 +- .../hotRadiationRoomFvDOM/Allclean | 6 +- .../hotRadiationRoomFvDOM/Allrun | 6 +- .../externalCoupledMultiRegionHeater/Allclean | 8 +- .../externalCoupledMultiRegionHeater/Allrun | 8 +- .../Allrun.pre | 8 +- .../externalSolarLoad/Allclean | 9 +- .../externalSolarLoad/Allrun | 8 +- .../externalSolarLoad/Allrun-parallel | 2 +- .../externalSolarLoad/Allrun.pre | 2 +- .../multiRegionHeater/Allclean | 6 +- .../multiRegionHeater/Allrun | 6 +- .../snappyMultiRegionHeater/Allclean | 6 +- .../snappyMultiRegionHeater/Allrun | 6 +- .../windshieldCondensation/Allclean | 9 +- .../windshieldCondensation/Allrun | 6 +- .../windshieldCondensation/Allrun-parallel | 6 +- .../windshieldDefrost/Allclean | 9 +- .../windshieldDefrost/Allrun | 8 +- .../windshieldDefrost/Allrun-parallel | 8 +- .../windshieldDefrost/Allrun.pre | 8 +- .../heatExchanger/Allclean | 9 +- .../heatExchanger/Allrun | 8 +- .../heatExchanger/Allrun-parallel | 8 +- .../heatExchanger/Allrun.pre | 8 +- .../jouleHeatingSolid/Allclean | 9 +- .../jouleHeatingSolid/Allrun | 8 +- .../jouleHeatingSolid/Allrun-parallel | 8 +- .../jouleHeatingSolid/Allrun.pre | 8 +- .../multiRegionHeaterRadiation/Allclean | 7 +- .../multiRegionHeaterRadiation/Allrun | 6 +- .../Allrun-parallel | 6 +- .../multiRegionHeaterRadiation/Allrun.pre | 6 +- .../SRFPimpleFoam/rotor2D/Allrun | 6 +- .../boundaryWallFunctionsProfile/Allclean | 6 +- .../boundaryWallFunctionsProfile/Allrun | 6 +- .../incompressible/icoFoam/cavity/Allclean | 11 +- .../incompressible/icoFoam/cavity/Allrun | 19 ++- .../icoFoam/cavityMappingTest/Allclean | 6 +- .../icoFoam/cavityMappingTest/Allrun | 8 +- .../icoFoam/cavityMappingTest/Allrun-parallel | 8 +- .../incompressible/icoFoam/elbow/Allclean | 6 +- tutorials/incompressible/icoFoam/elbow/Allrun | 6 +- .../lumpedPointMotion/building/Allrun | 4 +- .../lumpedPointMotion/building/Allrun.move | 4 +- .../building/files/Allrun.movement | 4 +- .../building/files/Allrun.transient | 4 +- .../building/steady/Allclean | 7 +- .../lumpedPointMotion/building/steady/Allrun | 4 +- .../building/steady/Allrun.pre | 4 +- .../overPimpleDyMFoam/cylinder/Allclean | 2 +- .../overPimpleDyMFoam/cylinder/Allrun | 5 +- .../overPimpleDyMFoam/cylinder/Allrun.pre | 5 +- .../cylinder/cylinderAndBackground/Allclean | 9 +- .../cylinder/cylinderAndBackground/Allrun | 4 +- .../cylinder/cylinderAndBackground/Allrun.pre | 4 +- .../cylinder/cylinderMesh/Allrun.pre | 5 +- .../overPimpleDyMFoam/simpleRotor/Allclean | 9 +- .../overPimpleDyMFoam/simpleRotor/Allrun | 4 +- .../overPimpleDyMFoam/simpleRotor/Allrun.pre | 4 +- .../twoSimpleRotors/Allclean | 9 +- .../overPimpleDyMFoam/twoSimpleRotors/Allrun | 4 +- .../twoSimpleRotors/Allrun.pre | 4 +- .../overSimpleFoam/aeroFoil/Allclean | 27 ++-- .../overSimpleFoam/aeroFoil/Allrun | 12 +- .../overSimpleFoam/aeroFoil/Allrun.pre | 15 +- .../aeroFoil/aeroFoil_overset/Allrun.pre | 9 +- .../aeroFoil_snappyHexMesh/Allrun.pre | 8 +- .../aeroFoil/background_overset/Allclean | 9 +- .../aeroFoil/background_overset/Allrun | 4 +- .../aeroFoil/background_overset/Allrun.pre | 4 +- .../background_snappyHexMesh/Allrun.pre | 9 +- .../pimpleDyMFoam/mixerVesselAMI2D/Allrun | 6 +- .../pimpleDyMFoam/mixerVesselAMI2D/makeMesh | 6 +- .../oscillatingInletACMI2D/Allclean | 9 +- .../oscillatingInletACMI2D/Allrun | 8 +- .../oscillatingInletACMI2D/Allrun-parallel | 8 +- .../oscillatingInletACMI2D/Allrun.pre | 8 +- .../pimpleDyMFoam/propeller/Allclean | 9 +- .../pimpleDyMFoam/propeller/Allrun | 8 +- .../pimpleDyMFoam/propeller/Allrun.pre | 7 +- .../pimpleDyMFoam/wingMotion/Allclean | 23 +-- .../pimpleDyMFoam/wingMotion/Allrun | 6 +- .../pimpleFoam/LES/channel395/Allrun | 6 +- .../pimpleFoam/LES/channel395DFSEM/Allrun | 8 +- .../pimpleFoam/LES/vortexShed/Allclean | 10 +- .../pimpleFoam/LES/vortexShed/Allrun | 8 +- .../pimpleFoam/RAS/TJunctionFan/Allclean | 9 +- .../pimpleFoam/RAS/TJunctionFan/Allrun | 8 +- .../pimpleFoam/RAS/elipsekkLOmega/Allclean | 6 +- .../pimpleFoam/RAS/elipsekkLOmega/Allrun | 6 +- .../laminar/planarPoiseuille/Allclean | 6 +- .../laminar/planarPoiseuille/Allrun | 6 +- .../planarPoiseuille/validation/createGraph | 2 +- .../pisoFoam/LES/motorBike/Allclean | 6 +- .../pisoFoam/LES/motorBike/Allrun | 4 +- .../pisoFoam/LES/motorBike/lesFiles/Allrun | 6 +- .../pisoFoam/LES/motorBike/motorBike/Allclean | 9 +- .../pisoFoam/LES/motorBike/motorBike/Allrun | 6 +- .../pisoFoam/laminar/porousBlockage/Allrun | 6 +- .../angledDuct/explicit/Allclean | 10 +- .../angledDuct/explicit/Allrun | 6 +- .../angledDuct/implicit/Allclean | 10 +- .../angledDuct/implicit/Allrun | 6 +- .../straightDuctImplicit/Allclean | 6 +- .../straightDuctImplicit/Allrun | 6 +- .../straightDuctImplicit/Allrun.pre | 6 +- .../incompressible/simpleFoam/T3A/Allclean | 6 +- .../incompressible/simpleFoam/T3A/Allrun | 6 +- .../simpleFoam/airFoil2D/Allrun | 6 +- .../simpleFoam/mixerVessel2D/Allrun | 6 +- .../simpleFoam/mixerVessel2D/makeMesh | 6 +- .../simpleFoam/motorBike/Allclean | 9 +- .../simpleFoam/motorBike/Allrun | 8 +- .../simpleFoam/pipeCyclic/Allclean | 9 +- .../simpleFoam/pipeCyclic/Allrun | 6 +- .../simpleFoam/rotorDisk/Allclean | 6 +- .../simpleFoam/rotorDisk/Allrun | 6 +- .../simpleFoam/simpleCar/Allrun | 6 +- .../simpleFoam/turbineSiting/Allclean | 9 +- .../simpleFoam/turbineSiting/Allrun | 6 +- .../simpleFoam/windAroundBuildings/Allclean | 6 +- .../simpleFoam/windAroundBuildings/Allrun | 6 +- .../lagrangian/MPPICFoam/cyclone/Allclean | 6 +- tutorials/lagrangian/MPPICFoam/cyclone/Allrun | 6 +- .../coalChemistryFoam/simplifiedSiwek/Allrun | 6 +- .../mixerVesselAMI2D/Allrun | 8 +- .../hopper/Allclean | 19 +-- .../hopper/Allrun | 6 +- .../reactingParcelFoam/cylinder/Allclean | 9 +- .../reactingParcelFoam/cylinder/Allrun | 6 +- .../reactingParcelFoam/cylinder/Allrun.pre | 6 +- .../reactingParcelFoam/filter/Allclean | 9 +- .../reactingParcelFoam/filter/Allrun | 6 +- .../reactingParcelFoam/hotBoxes/Allclean | 9 +- .../reactingParcelFoam/hotBoxes/Allrun | 6 +- .../hotBoxes/Allrun-parallel | 6 +- .../reactingParcelFoam/hotBoxes/Allrun.pre | 6 +- .../reactingParcelFoam/rivuletPanel/Allclean | 9 +- .../reactingParcelFoam/rivuletPanel/Allrun | 6 +- .../rivuletPanel/Allrun.pre | 6 +- .../reactingParcelFoam/splashPanel/Allclean | 9 +- .../reactingParcelFoam/splashPanel/Allrun | 6 +- .../reactingParcelFoam/splashPanel/Allrun.pre | 6 +- .../verticalChannel/Allclean | 9 +- .../reactingParcelFoam/verticalChannel/Allrun | 6 +- .../verticalChannelLTS/Allclean | 9 +- .../verticalChannelLTS/Allrun | 6 +- .../verticalChannel/Allclean | 9 +- .../verticalChannel/Allrun | 6 +- tutorials/mesh/blockMesh/pipe/Allrun | 6 +- tutorials/mesh/blockMesh/sphere/Allrun | 6 +- tutorials/mesh/blockMesh/sphere7/Allrun | 6 +- .../blockMesh/sphere7ProjectedEdges/Allrun | 6 +- tutorials/mesh/foamyHexMesh/Allrun | 26 +-- tutorials/mesh/foamyHexMesh/blob/Allclean | 9 +- tutorials/mesh/foamyHexMesh/blob/Allrun | 6 +- .../mesh/foamyHexMesh/blob/Allrun-parallel | 6 +- tutorials/mesh/foamyHexMesh/flange/Allclean | 9 +- tutorials/mesh/foamyHexMesh/flange/Allrun | 6 +- .../mesh/foamyHexMesh/flange/Allrun-parallel | 6 +- .../mesh/foamyHexMesh/mixerVessel/Allclean | 9 +- .../mesh/foamyHexMesh/mixerVessel/Allrun | 6 +- .../mesh/foamyHexMesh/mixerVessel/Allrun-pre | 8 +- .../mixerVessel/Allrun-simulation | 6 +- .../mesh/foamyHexMesh/simpleShapes/Allclean | 9 +- .../mesh/foamyHexMesh/simpleShapes/Allrun | 6 +- tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean | 9 +- tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun | 6 +- .../OpenCFD/Allrun-rhoCentralFoam | 6 +- .../foamyQuadMesh/jaggedBoundary/Allclean | 6 +- .../mesh/foamyQuadMesh/jaggedBoundary/Allrun | 6 +- tutorials/mesh/foamyQuadMesh/square/Allclean | 6 +- tutorials/mesh/foamyQuadMesh/square/Allrun | 6 +- .../moveDynamicMesh/relativeMotion/Allclean | 18 +-- .../moveDynamicMesh/relativeMotion/Allrun | 6 +- tutorials/mesh/parallel/cavity/Allclean | 2 +- tutorials/mesh/parallel/cavity/Allrun | 2 +- tutorials/mesh/parallel/filter/Allclean | 9 +- tutorials/mesh/parallel/filter/Allrun | 8 +- .../mesh/refineMesh/refineFieldDirs/Allclean | 9 +- .../mesh/refineMesh/refineFieldDirs/Allrun | 6 +- tutorials/mesh/snappyHexMesh/Allrun | 18 +-- .../addLayersToFaceZone/Allclean | 6 +- .../snappyHexMesh/addLayersToFaceZone/Allrun | 6 +- tutorials/mesh/snappyHexMesh/flange/Allclean | 9 +- tutorials/mesh/snappyHexMesh/flange/Allrun | 6 +- .../mesh/snappyHexMesh/gap_detection/Allclean | 6 +- .../mesh/snappyHexMesh/gap_detection/Allrun | 6 +- .../MPPICInterFoam/twoPhasePachuka/Allclean | 8 +- .../MPPICInterFoam/twoPhasePachuka/Allrun | 8 +- .../multiphase/cavitatingFoam/LES/Allrun | 11 +- .../cavitatingFoam/LES/throttle/Allclean | 6 +- .../cavitatingFoam/LES/throttle/Allrun | 6 +- .../cavitatingFoam/LES/throttle3D/Allclean | 9 +- .../cavitatingFoam/LES/throttle3D/Allrun | 6 +- .../cavitatingFoam/RAS/throttle/Allclean | 6 +- .../cavitatingFoam/RAS/throttle/Allrun | 6 +- .../laminar/sloshingTank2D/Allrun | 6 +- .../laminar/sphereDrop/Allclean | 8 +- .../laminar/sphereDrop/Allrun | 4 +- .../laminar/sphereDrop/Allrun.parallel | 4 +- .../laminar/depthCharge2D/Allclean | 9 +- .../laminar/depthCharge2D/Allrun | 6 +- .../laminar/depthCharge3D/Allclean | 9 +- .../laminar/depthCharge3D/Allrun | 6 +- .../laminar/damBreak4phase/Allclean | 9 +- .../laminar/damBreak4phase/Allrun | 6 +- .../driftFluxFoam/RAS/mixerVessel2D/Allrun | 6 +- .../driftFluxFoam/RAS/mixerVessel2D/makeMesh | 2 + .../driftFluxFoam/RAS/tank3D/Allrun | 6 +- .../condensatingVessel/Allclean | 6 +- .../condensatingVessel/Allrun | 6 +- .../interDyMFoam/RAS/DTCHull/Allclean | 8 +- .../interDyMFoam/RAS/DTCHull/Allrun | 6 +- .../interDyMFoam/RAS/floatingObject/Allclean | 9 +- .../interDyMFoam/RAS/floatingObject/Allrun | 6 +- .../interDyMFoam/RAS/mixerVesselAMI/Allclean | 9 +- .../interDyMFoam/RAS/mixerVesselAMI/Allrun | 6 +- .../RAS/mixerVesselAMI/Allrun.pre | 6 +- .../interDyMFoam/RAS/motorBike/Allclean | 11 +- .../interDyMFoam/RAS/motorBike/Allrun | 8 +- .../interDyMFoam/RAS/motorBike/Allrun.pre | 6 +- .../laminar/damBreakWithObstacle/Allclean | 9 +- .../laminar/damBreakWithObstacle/Allrun | 6 +- .../laminar/sloshingCylinder/Allrun | 6 +- .../laminar/sloshingTank2D/Allrun | 6 +- .../laminar/sloshingTank2D3DoF/Allrun | 6 +- .../laminar/sloshingTank3D/Allrun | 6 +- .../laminar/sloshingTank3D3DoF/Allrun | 6 +- .../laminar/sloshingTank3D6DoF/Allrun | 6 +- .../laminar/testTubeMixer/Allclean | 6 +- .../interDyMFoam/laminar/testTubeMixer/Allrun | 6 +- .../interFoam/LES/nozzleFlow2D/Allclean | 6 +- .../interFoam/LES/nozzleFlow2D/Allrun | 6 +- .../multiphase/interFoam/RAS/DTCHull/Allclean | 9 +- .../multiphase/interFoam/RAS/DTCHull/Allrun | 6 +- .../interFoam/RAS/angledDuct/Allrun | 6 +- .../interFoam/RAS/damBreak/Allclean | 6 +- .../multiphase/interFoam/RAS/damBreak/Allrun | 6 +- .../interFoam/RAS/damBreak/damBreak/Allclean | 6 +- .../interFoam/RAS/damBreak/damBreak/Allrun | 6 +- .../RAS/damBreakPorousBaffle/Allclean | 6 +- .../interFoam/RAS/damBreakPorousBaffle/Allrun | 6 +- .../interFoam/RAS/waterChannel/Allclean | 6 +- .../interFoam/RAS/waterChannel/Allmesh | 6 +- .../interFoam/RAS/waterChannel/Allrun | 6 +- .../interFoam/RAS/weirOverflow/Allclean | 9 +- .../interFoam/RAS/weirOverflow/Allrun | 6 +- .../interFoam/laminar/capillaryRise/Allrun | 6 +- .../interFoam/laminar/damBreak/Allclean | 6 +- .../interFoam/laminar/damBreak/Allrun | 6 +- .../laminar/damBreak/damBreak/Allclean | 6 +- .../laminar/damBreak/damBreak/Allrun | 6 +- .../interFoam/laminar/mixerVessel2D/Allrun | 6 +- .../interFoam/laminar/mixerVessel2D/makeMesh | 2 + .../interFoam/laminar/vofToLagrangian/Allrun | 8 +- .../eulerianInjection/Allclean | 9 +- .../vofToLagrangian/eulerianInjection/Allrun | 6 +- .../lagrangianDistributionInjection/Allclean | 9 +- .../lagrangianDistributionInjection/Allrun | 8 +- .../lagrangianParticleInjection/Allclean | 9 +- .../lagrangianParticleInjection/Allrun | 8 +- .../laminar/waveExampleCnoidal/Allclean | 11 +- .../laminar/waveExampleCnoidal/Allrun | 8 +- .../laminar/waveExampleSolitary/Allclean | 11 +- .../laminar/waveExampleSolitary/Allrun | 8 +- .../waveExampleSolitaryGrimshaw/Allclean | 11 +- .../waveExampleSolitaryGrimshaw/Allrun | 8 +- .../waveExampleSolitaryMcCowan/Allclean | 11 +- .../laminar/waveExampleSolitaryMcCowan/Allrun | 8 +- .../laminar/waveExampleStokesI/Allclean | 11 +- .../laminar/waveExampleStokesI/Allrun | 8 +- .../laminar/waveExampleStokesII/Allclean | 11 +- .../laminar/waveExampleStokesII/Allrun | 8 +- .../laminar/waveExampleStokesV/Allclean | 11 +- .../laminar/waveExampleStokesV/Allrun | 8 +- .../multiphase/interIsoFoam/damBreak/Allclean | 11 +- .../multiphase/interIsoFoam/damBreak/Allrun | 8 +- .../interIsoFoam/damBreak/Allrun-parallel | 8 +- .../interIsoFoam/discInConstantFlow/Allclean | 9 +- .../interIsoFoam/discInConstantFlow/Allrun | 9 +- .../discInReversedVortexFlow/Allclean | 10 +- .../discInReversedVortexFlow/Allrun | 8 +- .../notchedDiscInSolidBodyRotation/Allclean | 10 +- .../notchedDiscInSolidBodyRotation/Allrun | 8 +- .../sphereInReversedVortexFlow/Allclean | 10 +- .../sphereInReversedVortexFlow/Allrun | 8 +- .../interIsoFoam/standingWave/Allclean | 10 +- .../interIsoFoam/standingWave/Allrun | 8 +- .../interMixingFoam/laminar/damBreak/Allrun | 6 +- .../propeller/Allclean | 9 +- .../interPhaseChangeDyMFoam/propeller/Allrun | 6 +- .../propeller/Allrun.pre | 10 +- .../cavitatingBullet/Allclean | 9 +- .../cavitatingBullet/Allrun | 6 +- .../damBreak4phase/Allclean | 9 +- .../multiphaseEulerFoam/damBreak4phase/Allrun | 6 +- .../damBreak4phaseFine/Allclean | 9 +- .../damBreak4phaseFine/Allrun | 6 +- .../multiphaseEulerFoam/mixerVessel2D/Allrun | 6 +- .../mixerVessel2D/makeMesh | 2 + .../laminar/mixerVesselAMI2D/Allrun | 6 +- .../laminar/mixerVesselAMI2D/makeMesh | 6 +- .../laminar/damBreak4phase/Allclean | 9 +- .../laminar/damBreak4phase/Allrun | 6 +- .../laminar/damBreak4phaseFine/Allclean | 9 +- .../laminar/damBreak4phaseFine/Allrun | 6 +- .../laminar/mixerVessel2D/Allclean | 6 +- .../laminar/mixerVessel2D/Allrun | 6 +- .../laminar/mixerVessel2D/makeMesh | 2 + .../overInterDyMFoam/floatingBody/Allclean | 8 +- .../overInterDyMFoam/floatingBody/Allrun | 8 +- .../overInterDyMFoam/floatingBody/Allrun.pre | 5 +- .../floatingBody/background/Allclean | 8 +- .../floatingBody/background/Allrun.pre | 4 +- .../floatingBody/floatingBody/Allclean | 12 +- .../floatingBody/floatingBody/Allrun.pre | 8 +- .../oscillatingBox/Allclean | 9 +- .../oscillatingBox/Allrun | 6 +- .../oscillatingBox/extractHeightData | 3 + .../oscillatingBox/Allclean | 9 +- .../oscillatingBox/Allrun | 6 +- .../oscillatingBox/extractHeightData | 3 + .../laminar/mixerVessel2D/Allrun | 6 +- .../laminar/mixerVessel2D/makeMesh | 2 + .../RAS/wallBoiling/Allclean | 6 +- .../RAS/wallBoiling/Allrun | 6 +- .../RAS/wallBoilingIATE/Allclean | 6 +- .../RAS/wallBoilingIATE/Allrun | 6 +- .../laminar/mixerVessel2D/Allrun | 6 +- .../laminar/mixerVessel2D/makeMesh | 2 + .../twoLiquidMixingFoam/lockExchange/Allclean | 9 +- .../twoLiquidMixingFoam/lockExchange/Allrun | 6 +- .../laminar/mixerVessel2D/Allrun | 6 +- .../laminar/mixerVessel2D/makeMesh | 2 + .../createZeroDirectory/cavity/Allclean | 9 +- .../createZeroDirectory/cavity/Allrun | 6 +- .../createZeroDirectory/motorBike/Allclean | 9 +- .../createZeroDirectory/motorBike/Allrun | 8 +- .../snappyMultiRegionHeater/Allclean | 11 +- .../snappyMultiRegionHeater/Allrun | 8 +- .../solidDisplacementFoam/plateHole/Allclean | 6 +- .../solidDisplacementFoam/plateHole/Allrun | 6 +- 460 files changed, 1283 insertions(+), 2129 deletions(-) diff --git a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake index db490161d8e..d1ec8b77c1f 100755 --- a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake +++ b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake @@ -15,4 +15,4 @@ fi wmake -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/bin/foamCleanTutorials b/bin/foamCleanTutorials index 8712bb25fae..c313a9a2a57 100755 --- a/bin/foamCleanTutorials +++ b/bin/foamCleanTutorials @@ -30,9 +30,7 @@ # and all its subdirectories. # #------------------------------------------------------------------------------ - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions thisScript=$0 if [ "/${thisScript#/}" != "$thisScript" ] diff --git a/bin/foamRunTutorials b/bin/foamRunTutorials index df8f148ca5f..5c2b49435b4 100755 --- a/bin/foamRunTutorials +++ b/bin/foamRunTutorials @@ -30,19 +30,18 @@ # and all its subdirectories. # #------------------------------------------------------------------------------ +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Normally use standard "make" make="make" -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - thisScript=$0 if [ "/${thisScript#/}" != "$thisScript" ] then thisScript="$PWD/$thisScript" fi +unset passArgs runTests skipFirst=false # Parse options @@ -52,16 +51,15 @@ do -t | -test) passArgs="-test" runTests=true - shift ;; -s | -skipFirst) skipFirst=true - shift ;; *) break ;; esac + shift done # If an argument is supplied do not execute ./Allrun to avoid recursion diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 91867f1051d..8bd95eea84e 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -31,7 +31,7 @@ cleanTimeDirectories() { - echo "Cleaning $PWD case" + echo "Cleaning case $PWD" zeros="" while [ ${#zeros} -lt 8 ] do @@ -105,15 +105,13 @@ cleanCase() cleanSnappyFiles rm -f 0/cellDist > /dev/null 2>&1 - if [ -d constant ] - then - (cd constant && \ - rm -rf \ - cellDecomposition cellToRegion cellLevel* pointLevel* \ - polyMesh tetDualMesh \ - > /dev/null 2>&1 \ - ) - fi + ( + cd constant 2>/dev/null && \ + rm -rf \ + cellDecomposition cellToRegion cellLevel* pointLevel* \ + polyMesh tetDualMesh \ + > /dev/null 2>&1 \ + ) if [ -e system/blockMeshDict.m4 ] then @@ -122,9 +120,17 @@ cleanCase() } +# Frequently used - cleanCase and rm -rf 0/ +cleanCase0() +{ + cleanCase + rm -rf 0 +} + + removeCase() { - echo "Removing ${1:-unknown} case" + echo "Removing case ${1:-unknown}" [ "$#" -ge 1 ] && rm -rf "$1" } @@ -143,7 +149,7 @@ cleanUcomponents() cleanApplication() { - echo "Cleaning $PWD application" + echo "Cleaning application $PWD" wclean } diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index e4a49bef181..06272605bcd 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -43,6 +43,7 @@ isParallel() return 1 } + # # Look for '-test' in the argument list. # @@ -52,6 +53,7 @@ isTest() return 1 } + # # Extract 'numberOfSubdomains' from system/decomposeParDict # (or alternative location). @@ -100,120 +102,139 @@ getApplication() fi } + +# +# Run given application in serial with logfile output. +# The preexistence of the log file prevents rerunning. +# runApplication() { - APP_RUN= - LOG_IGNORE=false - LOG_APPEND=false - LOG_SUFFIX= - - # Parse options and executable - while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do - key="$1" - case "$key" in - -append|-a) - LOG_IGNORE=true - LOG_APPEND=true + local appRun logFile logMode + + # Any additional parsed arguments (eg, decomposeParDict) + local appArgs + + # Parse options until executable is encountered + while [ $# -gt 0 -a -z "$appRun" ] + do + case "$1" in + -a | -append) + logMode=append ;; - -overwrite|-o) - LOG_IGNORE=true + -o | -overwrite) + logMode=overwrite ;; - -suffix|-s) - LOG_SUFFIX=".$2" + -s | -suffix) + logFile=".$2" shift ;; + -decomposeParDict) + appArgs="$appArgs $1 $2" + shift + ;; + '') + ;; *) - APP_RUN="$key" - APP_NAME="${key##*/}" - LOG_SUFFIX="${APP_NAME}${LOG_SUFFIX}" + appRun="$1" ;; esac shift done - if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ] + local appName="${appRun##*/}" + logFile="log.$appName$logFile" + + if [ -f "$logFile" -a -z "$logMode" ] then - echo "$APP_NAME already run on $PWD:" \ - "remove log file 'log.$LOG_SUFFIX' to re-run" + echo "$appName already run on $PWD:" \ + "remove log file '$logFile' to re-run" else - echo "Running $APP_RUN on $PWD" - if [ "$LOG_APPEND" = "true" ]; then - $APP_RUN "$@" >> log.$LOG_SUFFIX 2>&1 + echo "Running $appRun on $PWD" + if [ "$logMode" = append ] + then + $appRun $appArgs "$@" >> $logFile 2>&1 else - $APP_RUN "$@" > log.$LOG_SUFFIX 2>&1 + $appRun $appArgs "$@" > $logFile 2>&1 fi fi } + +# +# Run given application in parallel with logfile output. +# The preexistence of the log file prevents rerunning. +# runParallel() { - APP_RUN= - LOG_IGNORE=false - LOG_APPEND=false - LOG_SUFFIX= - - # Store any parsed additional arguments e.g. decomposeParDict - APP_PARARGS= - - # Initialise number of procs to unset value - nProcs=-1 - - # Parse options and executable - while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do - key="$1" - case "$key" in - -append|-a) - LOG_IGNORE=true - LOG_APPEND=true + local appRun logFile logMode nProcs + + # Any additional parsed arguments (eg, decomposeParDict) + local appArgs="-parallel" + + # Parse options until executable is encountered + while [ $# -gt 0 -a -z "$appRun" ] + do + case "$1" in + -a | -append) + logMode=append ;; - -overwrite|-o) - LOG_IGNORE=true + -o | -overwrite) + logMode=overwrite ;; - -suffix|-s) - LOG_SUFFIX=".$2" + -s | -suffix) + logFile=".$2" shift ;; - -np|-n) + -n | -np) nProcs="$2" shift ;; -decomposeParDict) + appArgs="$appArgs $1 $2" nProcs=$(getNumberOfProcessors "$2") - APP_PARARGS="$APP_PARARGS -decomposeParDict $2" shift ;; + '') + ;; *) - APP_RUN="$key" - APP_NAME="${key##*/}" - LOG_SUFFIX="${APP_NAME}${LOG_SUFFIX}" + appRun="$1" ;; esac - shift done - [ "$nProcs" -eq -1 ] && nProcs=$(getNumberOfProcessors system/decomposeParDict) + [ -n "$nProcs" ] || nProcs=$(getNumberOfProcessors system/decomposeParDict) - if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ] + local appName="${appRun##*/}" + logFile="log.$appName$logFile" + + if [ -f "$logFile" -a -z "$logMode" ] then - echo "$APP_NAME already run on $PWD:" \ - "remove log file 'log.$LOG_SUFFIX' to re-run" + echo "$appName already run on $PWD:" \ + "remove log file '$logFile' to re-run" else - echo "Running $APP_RUN in parallel on $PWD using $nProcs processes" - if [ "$LOG_APPEND" = "true" ]; then - ( mpirun -np $nProcs $APP_RUN $APP_PARARGS -parallel "$@" < /dev/null >> log.$LOG_SUFFIX 2>&1 ) + echo "Running $appRun ($nProcs processes) on $PWD " + if [ "$logMode" = append ] + then + ( + mpirun -np $nProcs $appRun $appArgs "$@" </dev/null >> $logFile 2>&1 + ) else - ( mpirun -np $nProcs $APP_RUN $APP_PARARGS -parallel "$@" < /dev/null > log.$LOG_SUFFIX 2>&1 ) + ( + mpirun -np $nProcs $appRun $appArgs "$@" </dev/null > $logFile 2>&1 + ) fi fi } + compileApplication() { echo "Compiling $1 application" wmake $1 } + # # cloneCase srcDir dstDir # @@ -249,6 +270,7 @@ cloneCase() return 0 } + # # cloneParallelCase srcDir dstDir [...times] # @@ -312,6 +334,7 @@ cloneParallelCase() return 0 } + # Overwrite 0/ with the contents of 0.orig/ if it exists. # The -processor option to do the processor directories instead # @@ -338,4 +361,5 @@ restore0Dir() fi } + #------------------------------------------------------------------------------ diff --git a/src/mesh/Allwmake b/src/mesh/Allwmake index 9aa9ba5bfcc..52ef361a9fd 100755 --- a/src/mesh/Allwmake +++ b/src/mesh/Allwmake @@ -8,4 +8,4 @@ wmake $targetType snappyHexMesh wmake $targetType blockMesh wmake $targetType extrudeModel -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/tutorials/DNS/dnsFoam/boxTurb16/Allclean b/tutorials/DNS/dnsFoam/boxTurb16/Allclean index d3bb3531956..63c2af729c6 100755 --- a/tutorials/DNS/dnsFoam/boxTurb16/Allclean +++ b/tutorials/DNS/dnsFoam/boxTurb16/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -f 0/enstrophy diff --git a/tutorials/DNS/dnsFoam/boxTurb16/Allrun b/tutorials/DNS/dnsFoam/boxTurb16/Allrun index 125c236a6c7..73fb0ad1aa2 100755 --- a/tutorials/DNS/dnsFoam/boxTurb16/Allrun +++ b/tutorials/DNS/dnsFoam/boxTurb16/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication boxTurb diff --git a/tutorials/IO/fileHandler/Allclean b/tutorials/IO/fileHandler/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/IO/fileHandler/Allclean +++ b/tutorials/IO/fileHandler/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/IO/fileHandler/Allrun b/tutorials/IO/fileHandler/Allrun index d70139ef72e..1f90a49f6b2 100755 --- a/tutorials/IO/fileHandler/Allrun +++ b/tutorials/IO/fileHandler/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/IO/fileHandler/Alltest b/tutorials/IO/fileHandler/Alltest index 98f9166d69b..d5416642d47 100755 --- a/tutorials/IO/fileHandler/Alltest +++ b/tutorials/IO/fileHandler/Alltest @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Reset the controlDict if [ -f system/controlDict.orig ] diff --git a/tutorials/basic/laplacianFoam/flange/Allclean b/tutorials/basic/laplacianFoam/flange/Allclean index dc38fab61fd..1c56b00e18e 100755 --- a/tutorials/basic/laplacianFoam/flange/Allclean +++ b/tutorials/basic/laplacianFoam/flange/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf Fieldview > /dev/null 2>&1 diff --git a/tutorials/basic/laplacianFoam/flange/Allrun b/tutorials/basic/laplacianFoam/flange/Allrun index 59e996ba18f..53a0f0634ac 100755 --- a/tutorials/basic/laplacianFoam/flange/Allrun +++ b/tutorials/basic/laplacianFoam/flange/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runAnsysToFoam() { diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean index bd7671dd1e7..fad073e1431 100755 --- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean +++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean @@ -1,11 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 -cleanCase rm -f constant/polyMesh/boundary rm -f constant/polyMesh/zoneID -rm -rf 0 - #------------------------------------------------------------------------------ diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun index 07dafa9e953..395446555eb 100755 --- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun +++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre index 16135b7062a..baa7887883a 100755 --- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre +++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/basic/potentialFoam/cylinder/Allclean b/tutorials/basic/potentialFoam/cylinder/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/basic/potentialFoam/cylinder/Allclean +++ b/tutorials/basic/potentialFoam/cylinder/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/basic/potentialFoam/cylinder/Allrun b/tutorials/basic/potentialFoam/cylinder/Allrun index 6e5e8f42de9..754c15e58c0 100755 --- a/tutorials/basic/potentialFoam/cylinder/Allrun +++ b/tutorials/basic/potentialFoam/cylinder/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh diff --git a/tutorials/basic/potentialFoam/pitzDaily/Allclean b/tutorials/basic/potentialFoam/pitzDaily/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/basic/potentialFoam/pitzDaily/Allclean +++ b/tutorials/basic/potentialFoam/pitzDaily/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/basic/potentialFoam/pitzDaily/Allrun b/tutorials/basic/potentialFoam/pitzDaily/Allrun index b4667497e46..6ea7923d16b 100755 --- a/tutorials/basic/potentialFoam/pitzDaily/Allrun +++ b/tutorials/basic/potentialFoam/pitzDaily/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh diff --git a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean index 189dd60ac40..b6e861cc69c 100755 --- a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean +++ b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf VTK diff --git a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun index 312f7aa370c..509c9850525 100755 --- a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun +++ b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh diff --git a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean +++ b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun index fa51ae65e3c..5e6d5291c4c 100755 --- a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun +++ b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.mesh diff --git a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh index 59a8b9b93db..28b75a27c1d 100755 --- a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh +++ b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/combustion/XiFoam/RAS/Allclean b/tutorials/combustion/XiFoam/RAS/Allclean index edc01a252b9..39e9b455bf7 100755 --- a/tutorials/combustion/XiFoam/RAS/Allclean +++ b/tutorials/combustion/XiFoam/RAS/Allclean @@ -1,19 +1,13 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions keepCases="moriyoshiHomogeneous" loseCases="moriyoshiHomogeneousPart2 moriyoshiHomogeneousHydrogen" for caseName in $keepCases do -( - cd $caseName || exit - - foamCleanTutorials -) + ( cd $caseName && foamCleanTutorials ) done for caseName in $loseCases diff --git a/tutorials/combustion/XiFoam/RAS/Allrun b/tutorials/combustion/XiFoam/RAS/Allrun index b3d0e3bf1d5..213d7e06648 100755 --- a/tutorials/combustion/XiFoam/RAS/Allrun +++ b/tutorials/combustion/XiFoam/RAS/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions setControlDict() { diff --git a/tutorials/combustion/chemFoam/gri/Allclean b/tutorials/combustion/chemFoam/gri/Allclean index 6d98f58208e..9bc42acc50c 100755 --- a/tutorials/combustion/chemFoam/gri/Allclean +++ b/tutorials/combustion/chemFoam/gri/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf chemFoam.out constant/reactions constant/thermo \ validation/OF_vs_CHEMKINII.eps validation/chemkinII diff --git a/tutorials/combustion/chemFoam/gri/Allrun b/tutorials/combustion/chemFoam/gri/Allrun index 9f91a1a6ccd..192618695d3 100755 --- a/tutorials/combustion/chemFoam/gri/Allrun +++ b/tutorials/combustion/chemFoam/gri/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication chemkinToFoam \ diff --git a/tutorials/combustion/chemFoam/h2/Allclean b/tutorials/combustion/chemFoam/h2/Allclean index 5d4bbd8d845..e01a93433e6 100755 --- a/tutorials/combustion/chemFoam/h2/Allclean +++ b/tutorials/combustion/chemFoam/h2/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII diff --git a/tutorials/combustion/chemFoam/h2/Allrun b/tutorials/combustion/chemFoam/h2/Allrun index a90b3d865ce..bf06d218a86 100755 --- a/tutorials/combustion/chemFoam/h2/Allrun +++ b/tutorials/combustion/chemFoam/h2/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication $(getApplication) diff --git a/tutorials/combustion/chemFoam/ic8h18/Allclean b/tutorials/combustion/chemFoam/ic8h18/Allclean index 5d4bbd8d845..e01a93433e6 100755 --- a/tutorials/combustion/chemFoam/ic8h18/Allclean +++ b/tutorials/combustion/chemFoam/ic8h18/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII diff --git a/tutorials/combustion/chemFoam/ic8h18/Allrun b/tutorials/combustion/chemFoam/ic8h18/Allrun index a90b3d865ce..bf06d218a86 100755 --- a/tutorials/combustion/chemFoam/ic8h18/Allrun +++ b/tutorials/combustion/chemFoam/ic8h18/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication $(getApplication) diff --git a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean index 5d4bbd8d845..e01a93433e6 100755 --- a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean +++ b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII diff --git a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun index a90b3d865ce..bf06d218a86 100755 --- a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun +++ b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication $(getApplication) diff --git a/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph b/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph index 43e3c36e10e..ebb4474ddda 100755 --- a/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph +++ b/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph @@ -21,4 +21,4 @@ gnuplot<<EOF "chemkinII" with lines title "Chemkin II" lt -1 EOF -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/combustion/chemFoam/nc7h16/Allclean b/tutorials/combustion/chemFoam/nc7h16/Allclean index 5d4bbd8d845..e01a93433e6 100755 --- a/tutorials/combustion/chemFoam/nc7h16/Allclean +++ b/tutorials/combustion/chemFoam/nc7h16/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII diff --git a/tutorials/combustion/chemFoam/nc7h16/Allrun b/tutorials/combustion/chemFoam/nc7h16/Allrun index a90b3d865ce..bf06d218a86 100755 --- a/tutorials/combustion/chemFoam/nc7h16/Allrun +++ b/tutorials/combustion/chemFoam/nc7h16/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication $(getApplication) diff --git a/tutorials/combustion/engineFoam/kivaTest/Allclean b/tutorials/combustion/engineFoam/kivaTest/Allclean index b1fa019711a..71df6ecdbb3 100755 --- a/tutorials/combustion/engineFoam/kivaTest/Allclean +++ b/tutorials/combustion/engineFoam/kivaTest/Allclean @@ -1,13 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions mv ./-180 temp180 -cleanCase -rm -rf 0 +cleanCase0 mv temp180 ./-180 diff --git a/tutorials/combustion/engineFoam/kivaTest/Allrun b/tutorials/combustion/engineFoam/kivaTest/Allrun index d5434dff007..80677173bdf 100755 --- a/tutorials/combustion/engineFoam/kivaTest/Allrun +++ b/tutorials/combustion/engineFoam/kivaTest/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication kivaToFoam -file otape17 runApplication $(getApplication) diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean b/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean index 3ed713392c5..9ead8681dec 100755 --- a/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean +++ b/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean @@ -1,11 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf constant/panelRegion/polyMesh rm -f constant/polyMesh/boundary rm -f validation/*.eps -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun b/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun index 1fb613fedb3..c09ed1e6e3e 100755 --- a/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun +++ b/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create the blockMesh file with the parametric one m4 system/blockMeshDict.m4 > system/blockMeshDict @@ -25,4 +23,4 @@ paraFoam -touch -region panelRegion (cd validation && ./createGraphs) -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean index 615ace08b76..b38edacb897 100755 --- a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean +++ b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun index b18a484335d..e99924ab9d4 100755 --- a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun +++ b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create the underlying block mesh runApplication blockMesh diff --git a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean index f8c61931336..fcfdc325778 100755 --- a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean +++ b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun index c46299855a1..259ca145a6b 100755 --- a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun +++ b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean index b333961d48f..2e8de5d05fc 100755 --- a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean +++ b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean @@ -1,10 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf constant/panelRegion/polyMesh -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun index ba88bc10f31..dcd2bad0e5a 100755 --- a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun +++ b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet @@ -11,4 +9,4 @@ runApplication $(getApplication) paraFoam -touchAll -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean index 333e5d8d25c..b75804a65ba 100755 --- a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean +++ b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun index 942f56f2ec9..39af3c029d8 100755 --- a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun +++ b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean index 333e5d8d25c..b75804a65ba 100755 --- a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean +++ b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun index 8c42b7a25ef..de0f52b40bc 100755 --- a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun +++ b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean index 79defe511db..c81ffab9ed9 100755 --- a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean +++ b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun index a3d72f117c5..1476376f443 100755 --- a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun +++ b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Application name application=$(getApplication) diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean index 9f691c93851..e2f275d9fd6 100755 --- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean +++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean @@ -1,11 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase - -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun index 5afd8b9d746..6299aedeab7 100755 --- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun +++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Application name application=$(getApplication) diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean index a5e65c7d81b..f2d7cca6654 100755 --- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase cleanSamples diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun index 1df0a7e3419..544ba54bad5 100755 --- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/compressible/rhoCentralFoam/shockTube/Allclean b/tutorials/compressible/rhoCentralFoam/shockTube/Allclean index b6716d88fb7..69fe9734a91 100755 --- a/tutorials/compressible/rhoCentralFoam/shockTube/Allclean +++ b/tutorials/compressible/rhoCentralFoam/shockTube/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase +cleanCase0 cleanSamples -rm -rf 0 #------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoCentralFoam/shockTube/Allrun b/tutorials/compressible/rhoCentralFoam/shockTube/Allrun index 4e1c0a9fbc8..055484463ab 100755 --- a/tutorials/compressible/rhoCentralFoam/shockTube/Allrun +++ b/tutorials/compressible/rhoCentralFoam/shockTube/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean index f60abaf9c58..e2f275d9fd6 100755 --- a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean @@ -1,9 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -\rm -rf 0 +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun index 9961aeb245f..528f1a0404d 100755 --- a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun @@ -1,11 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh runApplication -s preProcess $(getApplication) -postProcess -dict system/preProcess runApplication decomposePar runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean index 14de6e88627..794ee1b81e4 100755 --- a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean +++ b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1 diff --git a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun index e7b28d6aa52..2b52d36edd8 100755 --- a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun +++ b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication surfaceFeatureExtract diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun index ccdfefe5c1c..54368cee898 100755 --- a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun +++ b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun index ccdfefe5c1c..54368cee898 100755 --- a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun +++ b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun index 52b2a4941d7..5db0a1c8e5a 100755 --- a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun +++ b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./makeMesh runApplication $(getApplication) diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh index aad5edd02d7..6f4a3fffe32 100755 --- a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh +++ b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh @@ -1,8 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 < system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean index 92ec2e3cea0..2b124ecf38e 100755 --- a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean +++ b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun index 0e680451304..8143eddba2b 100755 --- a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun +++ b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Run function links the appropriate mesh files and clones the case diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean +++ b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun index 8a77ff80763..e0f9af4df86 100755 --- a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun +++ b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean index 7b7e1442f81..0686c27498f 100755 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean @@ -1,12 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase +cleanCase0 # Remove copies of common files -\rm -rf 0 constant +\rm -rf constant #------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun index f7891cd4f8d..13311998451 100755 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions echo "Use common files for 0/, constant/ and blockMeshDict" \rm -rf 0 constant diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean index 7b7e1442f81..0686c27498f 100755 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean @@ -1,12 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase +cleanCase0 # Remove copies of common files -\rm -rf 0 constant +\rm -rf constant #------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun index f7891cd4f8d..13311998451 100755 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions echo "Use common files for 0/, constant/ and blockMeshDict" \rm -rf 0 constant diff --git a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun index ccdfefe5c1c..54368cee898 100755 --- a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun +++ b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict diff --git a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean index deba0577f49..6eb1457dbc3 100755 --- a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean +++ b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -f constant/triSurface/*.eMesh* > /dev/null 2>&1 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1 diff --git a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun index a8d8e758dd1..ea3d94ccaeb 100755 --- a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun +++ b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.mesh diff --git a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh index 4a2c4342d1f..4c4121816cc 100755 --- a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh +++ b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication surfaceFeatureExtract diff --git a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean index 1deb2091334..e681fce19f5 100755 --- a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean +++ b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun index 4b94147c58f..8bd01b9e40f 100755 --- a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun +++ b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Convert mesh from resources directory runApplication star4ToFoam -scale 1 \ diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean b/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean index b6716d88fb7..69fe9734a91 100755 --- a/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean +++ b/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase +cleanCase0 cleanSamples -rm -rf 0 #------------------------------------------------------------------------------ diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun b/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun index 4a38818ccc6..5ef8615ad95 100755 --- a/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun +++ b/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh diff --git a/tutorials/compressible/sonicLiquidFoam/Allclean b/tutorials/compressible/sonicLiquidFoam/Allclean index aa8cb7bc24c..cbd249f6efb 100755 --- a/tutorials/compressible/sonicLiquidFoam/Allclean +++ b/tutorials/compressible/sonicLiquidFoam/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions removeCase decompressionTankFine foamCleanTutorials cases diff --git a/tutorials/compressible/sonicLiquidFoam/Allrun b/tutorials/compressible/sonicLiquidFoam/Allrun index deb3e8f4c6e..f7f2c64c042 100755 --- a/tutorials/compressible/sonicLiquidFoam/Allrun +++ b/tutorials/compressible/sonicLiquidFoam/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions setDecompressionTankFine() { diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean index 36f3cdc151b..40d55b2780e 100755 --- a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean @@ -1,10 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase + rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 #------------------------------------------------------------------------------ diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun index d56e57bf75b..ffa109248bc 100755 --- a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun +++ b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication dsmcInitialise diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean index 36f3cdc151b..40d55b2780e 100755 --- a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean @@ -1,10 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase + rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 #------------------------------------------------------------------------------ diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun index d56e57bf75b..ffa109248bc 100755 --- a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun +++ b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication dsmcInitialise diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean index 36f3cdc151b..40d55b2780e 100755 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean @@ -1,10 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase + rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 #------------------------------------------------------------------------------ diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun index d433a8c0269..0c110250f64 100755 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication decomposePar diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean index 36f3cdc151b..40d55b2780e 100755 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean @@ -1,10 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase + rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 #------------------------------------------------------------------------------ diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun index d433a8c0269..0c110250f64 100755 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication decomposePar diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean index 194c42b8c62..2b07ff650e1 100755 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun index 31e783b003a..2ec6f7b0778 100755 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication mdInitialise diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean index d52fe88c714..ca2f48ed946 100755 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun index 31e783b003a..2ec6f7b0778 100755 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication mdInitialise diff --git a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean index 7fa5428f73e..bc26045cbda 100755 --- a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean +++ b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf processor[0-9] diff --git a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun index 66482be7d4b..cd4b14a1f9b 100755 --- a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun +++ b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication decomposePar diff --git a/tutorials/electromagnetics/mhdFoam/hartmann/Allclean b/tutorials/electromagnetics/mhdFoam/hartmann/Allclean index a5e65c7d81b..f2d7cca6654 100755 --- a/tutorials/electromagnetics/mhdFoam/hartmann/Allclean +++ b/tutorials/electromagnetics/mhdFoam/hartmann/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase cleanSamples diff --git a/tutorials/electromagnetics/mhdFoam/hartmann/Allrun b/tutorials/electromagnetics/mhdFoam/hartmann/Allrun index 8bf5318684b..23a6711db49 100755 --- a/tutorials/electromagnetics/mhdFoam/hartmann/Allrun +++ b/tutorials/electromagnetics/mhdFoam/hartmann/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean index be62031288e..01dae1a898f 100755 --- a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean +++ b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -f 0/T diff --git a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun index ac13b064274..f8719a73da3 100755 --- a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun +++ b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh \cp 0/T.orig 0/T diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean index be62031288e..01dae1a898f 100755 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -f 0/T diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun index ac13b064274..f8719a73da3 100755 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh \cp 0/T.orig 0/T diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun index afe3cd23cfe..d0102481dad 100755 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean +++ b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun index c61e8a418c5..1e6177fd594 100755 --- a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun +++ b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean +++ b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun index 8a77ff80763..e0f9af4df86 100755 --- a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun +++ b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean index f02ac1a6eb2..8ad093a08cd 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean +++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -f validation/*.eps diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun index 33dbc862702..4abae23d19b 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun +++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean index eb1e8dba18a..0e33c8258de 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/baffle3DRegion diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun index 1927ad7c820..357dac9b56c 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun index 8a77ff80763..e0f9af4df86 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun index 8a77ff80763..e0f9af4df86 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean index 757a0f3d6cc..3f7a0cb7a67 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase @@ -23,4 +21,4 @@ rm -rf constant/heater/polyMesh rm -rf constant/leftSolid/polyMesh rm -rf constant/rightSolid/polyMesh -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun index 6191f4b7b12..25b14f2bb7c 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -32,4 +30,4 @@ runApplication ./externalSolver # Reconstruct runApplication reconstructPar -allRegions -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre index 481deedc7be..aebfbaa5aea 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet @@ -29,4 +27,4 @@ echo "creating files for paraview post-processing" echo paraFoam -touchAll 2>/dev/null -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean index bd637e1bf9b..fecea96c55a 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf VTK rm -rf constant/cellToRegion diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun index f59f69f8c19..b1618a81199 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Setup case ./Allrun.pre @@ -30,4 +28,4 @@ echo "Creating files for paraview post-processing" echo paraFoam -touchAll -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel index 7f0488b40f1..4fd07828f95 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel @@ -37,4 +37,4 @@ echo "Creating files for paraview post-processing" echo paraFoam -touchAll -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre index 5094b7903f6..35a20b5e48a 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre @@ -24,4 +24,4 @@ do -region $i -subDict dictionaryReplacement done -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean index 8b0c932d51b..fad685f8abf 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun index 619f8c0af0a..5cf86d4458f 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean index 230730502d4..0ad9dc9eb83 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun index e46f7210888..b3614e73078 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions rm -rf constant/polyMesh/sets diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean index c34834dedb6..d28baddd336 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/windshield/polyMesh rm -rf constant/cabin/polyMesh diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun index 7704bd9ea55..51e2df24b4f 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create the underlying block mesh runApplication blockMesh diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel index 18fefcf28cf..bdd571ebfcd 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create the underlying block mesh runApplication blockMesh diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean index 92a631d049e..9ce122ce3d9 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/exterior/polyMesh rm -rf constant/ice/polyMesh diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun index f4d82024cdb..4a206678cd0 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun @@ -1,11 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre runApplication $(getApplication) -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel index 4ec7e69c221..53e574a9d5a 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -19,4 +17,4 @@ runApplication -s ice reconstructPar -region ice runApplication -s exterior reconstructPar -region exterior -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre index 44fa75f381c..69ef3caa419 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create the underlying block mesh runApplication blockMesh @@ -19,4 +17,4 @@ runApplication splitMeshRegions -cellZones -overwrite # set the initial fields restore0Dir -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean index 5a54eef9a0e..2d12f3a3ee4 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 foamCleanPolyMesh -region air foamCleanPolyMesh -region porous diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun index f4d82024cdb..4a206678cd0 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun @@ -1,11 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre runApplication $(getApplication) -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel index 2be2e1edda0..2527a2edf58 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -14,4 +12,4 @@ runParallel $(getApplication) runApplication -s air reconstructPar -latestTime -region air runApplication -s porous reconstructPar -latestTime -region porous -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre index 6d3c8f35440..b3f7c19f36f 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions #create meshes runApplication -s air blockMesh -region air @@ -26,4 +24,4 @@ paraFoam -touch -region air restore0Dir -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean index 31c0b764b5a..6d4b7f5c83e 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 foamCleanPolyMesh -region solid diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun index 98857416a91..b7d6fe2a4db 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -10,4 +8,4 @@ runApplication $(getApplication) ./createGraphs -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel index b48e4c119d9..26499f21152 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -14,4 +12,4 @@ runApplication -s solid reconstructPar -latestTime -region solid ./createGraphs -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre index c8198f9848a..4197c7f941c 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Create meshe runApplication -s solid blockMesh -region solid @@ -12,4 +10,4 @@ paraFoam -touch -region solid restore0Dir -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean index 0df7ec62070..8232cefee71 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean @@ -1,10 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase + rm -rf VTK rm -rf constant/cellToRegion rm -rf 0/bottomAir diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun index 50db130fe23..e726d6fcab9 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Setup case diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel index ddcb5a103ff..42b3aad0227 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Setup case ./Allrun.pre diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre index 091548c051a..b28d6eee4f1 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun b/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun index 52b2a4941d7..5db0a1c8e5a 100755 --- a/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun +++ b/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./makeMesh runApplication $(getApplication) diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean index 98908744330..53c93d35b81 100755 --- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean +++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun index 7f68f709137..0a453a02799 100755 --- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun +++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/incompressible/icoFoam/cavity/Allclean b/tutorials/incompressible/icoFoam/cavity/Allclean index 842bb7ced7d..4431913e3bb 100755 --- a/tutorials/incompressible/icoFoam/cavity/Allclean +++ b/tutorials/incompressible/icoFoam/cavity/Allclean @@ -1,18 +1,13 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions keepCases="cavity cavityGrade cavityClipped" loseCases="cavityFine cavityHighRe" for caseName in $keepCases do -( - cd $caseName || exit - foamCleanTutorials -) + ( cd $caseName && foamCleanTutorials ) done for caseName in $loseCases diff --git a/tutorials/incompressible/icoFoam/cavity/Allrun b/tutorials/incompressible/icoFoam/cavity/Allrun index fdeea0d08d2..c1454a28614 100755 --- a/tutorials/incompressible/icoFoam/cavity/Allrun +++ b/tutorials/incompressible/icoFoam/cavity/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions cavityCases="cavity cavityFine cavityGrade cavityHighRe cavityClipped" @@ -55,20 +53,21 @@ setCavityHighRe() } +unset previousCase for caseName in $cavityCases do - if [ "$caseName" = cavityFine ] - then + case "$caseName" in + cavityFine) cloneCase cavity $caseName setCavityFine - fi + ;; - if [ "$caseName" = cavityHighRe ] - then + cavityHighRe) cloneCase cavity $caseName setCavityHighRe copySolutionDirs $caseName cavity - fi + ;; + esac ( cd $caseName && runApplication blockMesh ) diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean b/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean index 3512fe5e6eb..63145a3803c 100755 --- a/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf constant/coarseMesh diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun index 767ff8591ff..7d2e3238433 100755 --- a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse @@ -13,4 +11,4 @@ runApplication -s fine blockMesh -dict system/blockMeshDict.fine runApplication $(getApplication) -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel index 2577f9c8669..524002c6ec5 100755 --- a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel +++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse @@ -21,4 +19,4 @@ runParallel $(getApplication) # #runApplication -s coarseMesh reconstructPar -region coarseMesh -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/icoFoam/elbow/Allclean b/tutorials/incompressible/icoFoam/elbow/Allclean index 400ad856874..7238840f835 100755 --- a/tutorials/incompressible/icoFoam/elbow/Allclean +++ b/tutorials/incompressible/icoFoam/elbow/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf fluentInterface diff --git a/tutorials/incompressible/icoFoam/elbow/Allrun b/tutorials/incompressible/icoFoam/elbow/Allrun index d4774871961..a42f83926bc 100755 --- a/tutorials/incompressible/icoFoam/elbow/Allrun +++ b/tutorials/incompressible/icoFoam/elbow/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication fluentMeshToFoam elbow.msh diff --git a/tutorials/incompressible/lumpedPointMotion/building/Allrun b/tutorials/incompressible/lumpedPointMotion/building/Allrun index 8aad569cae6..b922844f842 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/Allrun +++ b/tutorials/incompressible/lumpedPointMotion/building/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # 1) First run steady-state to establish a good initial field. diff --git a/tutorials/incompressible/lumpedPointMotion/building/Allrun.move b/tutorials/incompressible/lumpedPointMotion/building/Allrun.move index 33b1a80e7b3..bed249580f5 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/Allrun.move +++ b/tutorials/incompressible/lumpedPointMotion/building/Allrun.move @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # 1) Run meshing # 2) Reconstruct diff --git a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement index bf69827a2c1..82baeb53be6 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement +++ b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # The 0/ field only # runApplication reconstructPar -withZero -time 0 diff --git a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient index 50047173685..951dd76adbe 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient +++ b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Cleanup old junk that may prevent things from starting \rm -f comms/OpenFOAM.lock diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean b/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean index 3b8b23422e8..e2f275d9fd6 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean +++ b/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean @@ -1,8 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -cleanCase -\rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun index 57456db2fd7..fd9ff050c42 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun +++ b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre index de42e2de8ce..fb357cee786 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre +++ b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Copy building from resources directory mkdir -p constant/triSurface/ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean index 862ed262d87..a916d075547 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean @@ -7,4 +7,4 @@ cd ${0%/*} || exit 1 # run from this directory # Add background mesh (cd cylinderMesh && foamCleanTutorials) -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun index 7604f9ad35a..5758f007251 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun @@ -1,8 +1,11 @@ #!/bin/sh -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Extrude mesh around cylinder (cd cylinderMesh && ./Allrun.pre) # Add background mesh (cd cylinderAndBackground && ./Allrun) + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre index 788e9474864..d87c892a624 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre @@ -1,8 +1,11 @@ #!/bin/sh -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Extrude mesh around cylinder (cd cylinderMesh && ./Allrun.pre) # Add background mesh (cd cylinderAndBackground && ./Allrun.pre) + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean index 6be736ea3ca..aab71fa2ca4 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean @@ -1,12 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 -cleanCase rm -f constant/polyMesh/boundary rm -f constant/polyMesh/zoneID rm -f constant/cellInterpolationWeight -rm -rf 0 - #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun index 50626eed683..67519235562 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre index f4910d875d6..fb7e1120bdf 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Create background mesh runApplication blockMesh diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre index ad0801bbb90..a86d9586601 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre @@ -1,8 +1,11 @@ #!/bin/sh -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Generate mesh from surface (in constant/triSurface) runApplication extrudeMesh # Make front and back type empty runApplication createPatch -overwrite + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean index 6be736ea3ca..aab71fa2ca4 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean @@ -1,12 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 -cleanCase rm -f constant/polyMesh/boundary rm -f constant/polyMesh/zoneID rm -f constant/cellInterpolationWeight -rm -rf 0 - #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun index d8593e52877..2ac685b863b 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre index 4eafbde2339..217161cb95c 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre +++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean index 6be736ea3ca..aab71fa2ca4 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean @@ -1,12 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 -cleanCase rm -f constant/polyMesh/boundary rm -f constant/polyMesh/zoneID rm -f constant/cellInterpolationWeight -rm -rf 0 - #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun index e4b389b8c57..10707b2f2cd 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre index 44fee43b005..abccd3163c9 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean index 10394c3ebe5..b7522e086ba 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean @@ -1,20 +1,15 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +for caseName in aeroFoil_snappyHexMesh background_snappyHexMesh +do + ( cd $caseName && cleanCase ) +done -cd aeroFoil_snappyHexMesh -cleanCase +for caseName in aeroFoil_overset background_overset +do + ( cd $caseName && cleanCase0 ) +done -cd ../aeroFoil_overset -cleanCase -rm -rf 0 - -cd ../background_snappyHexMesh -cleanCase - - -cd ../background_overset -cleanCase -./Allclean +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun index 728e17019da..96bbd15dee0 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun @@ -1,10 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre -cd background_overset -./Allrun +( cd background_overset && ./Allrun ) + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre index 6b300fc25ac..e3784e5ab62 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre @@ -1,12 +1,15 @@ #!/bin/sh -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions -# create aeroFoil mesh using snappyHexMesh -(cd aeroFoil_snappyHexMesh && ./Allrun.pre) +# Create aeroFoil mesh using snappyHexMesh +( cd aeroFoil_snappyHexMesh && ./Allrun.pre ) # Extrude mesh -(cd aeroFoil_overset && ./Allrun.pre) +( cd aeroFoil_overset && ./Allrun.pre ) -(cd background_snappyHexMesh && ./Allrun.pre) +( cd background_snappyHexMesh && ./Allrun.pre ) -(cd background_overset && ./Allrun.pre) +( cd background_overset && ./Allrun.pre ) + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre index 98a5ce71db0..66379c68c14 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre @@ -1,10 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Make a 2D mesh by extruding a patch and solve to steady state. runApplication extrudeMesh runApplication createPatch -overwrite + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre index fdfb7e78d16..7525ed4239f 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre @@ -1,9 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Make 3D mesh in slab of cells. runApplication blockMesh runApplication snappyHexMesh -overwrite + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean index 6be736ea3ca..aab71fa2ca4 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean @@ -1,12 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 -cleanCase rm -f constant/polyMesh/boundary rm -f constant/polyMesh/zoneID rm -f constant/cellInterpolationWeight -rm -rf 0 - #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun index 488b782585a..c290d0dd5ec 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Serial #runApplication $(getApplication) diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre index 858bba21fe7..4ce424d93f8 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication extrudeMesh runApplication createPatch -overwrite diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre index 75612046476..c221f0abd3c 100755 --- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre +++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre @@ -1,10 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -# Make 3D mesh in slab of cells. # Make 3D mesh in slab of cells. runApplication blockMesh runApplication snappyHexMesh -overwrite + +#------------------------------------------------------------------------------- diff --git a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun index 162255286a9..9450e8b3f6e 100755 --- a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun +++ b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./makeMesh diff --git a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh index bcb12c0e9ac..fc56e7be3ce 100755 --- a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh +++ b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 < system/blockMeshDict.m4 > system/blockMeshDict diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean +++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun index f4d82024cdb..4a206678cd0 100755 --- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun +++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun @@ -1,11 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre runApplication $(getApplication) -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel index 51af1fb48a6..c9e323cdb77 100755 --- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel +++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -10,4 +8,4 @@ runApplication decomposePar runParallel $(getApplication) runApplication reconstructPar -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre index c484c19d159..3d4d5ecf6fe 100755 --- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre +++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh @@ -13,4 +11,4 @@ runApplication createBaffles -overwrite restore0Dir -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean b/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean index 2334d531d33..88ad2ecc84a 100755 --- a/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean +++ b/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 # Remove surfaces and features rm -f constant/triSurface/propellerTip.obj.gz > /dev/null 2>&1 diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun index 51af1fb48a6..c9e323cdb77 100755 --- a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun +++ b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -10,4 +8,4 @@ runApplication decomposePar runParallel $(getApplication) runApplication reconstructPar -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre index fd9adacb88d..78478afc1ea 100755 --- a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre +++ b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre @@ -1,13 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy propeller surface from resources directory cp $FOAM_TUTORIALS/resources/geometry/propellerTip.obj.gz constant/triSurface/ - # - meshing runApplication blockMesh diff --git a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean index ae51d1251b2..a7438920301 100755 --- a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean +++ b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean @@ -1,24 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +( cd wingMotion_snappyHexMesh && cleanCase ) -( - cd wingMotion_snappyHexMesh || exit 1 - cleanCase -) +( cd wingMotion2D_simpleFoam && cleanCase0 ) -( - cd wingMotion2D_simpleFoam || exit 1 - cleanCase - rm -rf 0 -) - -( - cd wingMotion2D_pimpleDyMFoam || exit 1 - cleanCase - rm -rf 0 -) +( cd wingMotion2D_pimpleDyMFoam && cleanCase0 ) #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun index 0b5930fddc5..f173a5d46fa 100755 --- a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun +++ b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Make 3D mesh in slab of cells. ( diff --git a/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun b/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun index 8d10da5a1f4..08e91994a5c 100755 --- a/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun +++ b/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun b/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun index 5d8a22acc0b..d6690e27eda 100755 --- a/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun +++ b/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh @@ -14,4 +12,4 @@ runApplication decomposePar -cellDist runParallel $(getApplication) #runApplication reconstructPar -latestTime -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean index 97f2707db81..e2f275d9fd6 100755 --- a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean +++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean @@ -1,9 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -cleanCase - -\rm -rf 0 +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun index 8551f1c7155..df2af133800 100755 --- a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun +++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions rm -f system/blockMeshDict m4 system/blockMeshDict.m4 > system/blockMeshDict @@ -14,3 +12,5 @@ restore0Dir runApplication decomposePar runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean +++ b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun index 1492c40ae09..7a41c215689 100755 --- a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun +++ b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh @@ -17,4 +15,4 @@ runApplication createBaffles -overwrite runApplication $(getApplication) -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean +++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun index a1f6b6bbb67..097989bcc7b 100755 --- a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun +++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean index 78739484071..bb826d2457a 100755 --- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean +++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf *.dat validation/*.eps diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun index 1737ee272a0..784b7fab75c 100755 --- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun +++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph index d6402c1b4d2..b44450a7833 100755 --- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph +++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph @@ -24,4 +24,4 @@ gnuplot<<EOF "../WatersKing.dat" with lines t "Analytical" lt -1 EOF -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean b/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean index 5521d49681a..507327c90a4 100755 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions (cd motorBike && ./Allclean) diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun b/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun index 65eb7ef78f7..9f48464dc2b 100755 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Do the Spalart-Allmaras steady-state case (cd motorBike && foamRunTutorials) diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun b/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun index e18982c7e64..5bd3017bd20 100755 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Set-up the LES case \cp ../lesFiles/fvS* ../lesFiles/controlDict system/ diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean index da3e9263331..d4886e92271 100755 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 # Remove surface rm -f constant/triSurface/motorBike.obj.gz diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun index b3fbef32912..ede3cb25c2e 100755 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy motorbike surface from resources directory \cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/ diff --git a/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun b/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun index db65453658e..f88fe7fd920 100755 --- a/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun +++ b/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean index 7b7e1442f81..0686c27498f 100755 --- a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean +++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean @@ -1,12 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase +cleanCase0 # Remove copies of common files -\rm -rf 0 constant +\rm -rf constant #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun index f7891cd4f8d..13311998451 100755 --- a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun +++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions echo "Use common files for 0/, constant/ and blockMeshDict" \rm -rf 0 constant diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean index 7b7e1442f81..0686c27498f 100755 --- a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean +++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean @@ -1,12 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase +cleanCase0 # Remove copies of common files -\rm -rf 0 constant +\rm -rf constant #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun index f7891cd4f8d..13311998451 100755 --- a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun +++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions echo "Use common files for 0/, constant/ and blockMeshDict" \rm -rf 0 constant diff --git a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean index 4ebf8a1a7ff..d6454c597fc 100755 --- a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean +++ b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun index dbc0b12711c..4a206678cd0 100755 --- a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun +++ b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre index 33bf5258ce2..d8dd0702144 100755 --- a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre +++ b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication surfaceFeatureExtract diff --git a/tutorials/incompressible/simpleFoam/T3A/Allclean b/tutorials/incompressible/simpleFoam/T3A/Allclean index f02ac1a6eb2..8ad093a08cd 100755 --- a/tutorials/incompressible/simpleFoam/T3A/Allclean +++ b/tutorials/incompressible/simpleFoam/T3A/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -f validation/*.eps diff --git a/tutorials/incompressible/simpleFoam/T3A/Allrun b/tutorials/incompressible/simpleFoam/T3A/Allrun index 666bf88e7e4..c43f9985737 100755 --- a/tutorials/incompressible/simpleFoam/T3A/Allrun +++ b/tutorials/incompressible/simpleFoam/T3A/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/incompressible/simpleFoam/airFoil2D/Allrun b/tutorials/incompressible/simpleFoam/airFoil2D/Allrun index c96f61d7ef3..16a6a8651d6 100755 --- a/tutorials/incompressible/simpleFoam/airFoil2D/Allrun +++ b/tutorials/incompressible/simpleFoam/airFoil2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication $(getApplication) diff --git a/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun b/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun index 52b2a4941d7..5db0a1c8e5a 100755 --- a/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun +++ b/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./makeMesh runApplication $(getApplication) diff --git a/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh b/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh index 5cd24a55282..0caafbabf9e 100755 --- a/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh +++ b/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 < system/blockMeshDict.m4 > system/blockMeshDict diff --git a/tutorials/incompressible/simpleFoam/motorBike/Allclean b/tutorials/incompressible/simpleFoam/motorBike/Allclean index 1dca1e06777..a0bb1b4d393 100755 --- a/tutorials/incompressible/simpleFoam/motorBike/Allclean +++ b/tutorials/incompressible/simpleFoam/motorBike/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 # Remove surface and features rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1 diff --git a/tutorials/incompressible/simpleFoam/motorBike/Allrun b/tutorials/incompressible/simpleFoam/motorBike/Allrun index c110f083ecd..268780fb13c 100755 --- a/tutorials/incompressible/simpleFoam/motorBike/Allrun +++ b/tutorials/incompressible/simpleFoam/motorBike/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Alternative decomposeParDict name: decompDict="-decomposeParDict system/decomposeParDict.6" @@ -15,7 +13,7 @@ runApplication surfaceFeatureExtract runApplication blockMesh -runApplication decomposePar $decompDict +runApplication $decompDict decomposePar # Using distributedTriSurfaceMesh? if foamDictionary -entry geometry -value system/snappyHexMeshDict | \ diff --git a/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean b/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean +++ b/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun b/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun index 0cade47aa82..9b8ed30d971 100755 --- a/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun +++ b/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/incompressible/simpleFoam/rotorDisk/Allclean b/tutorials/incompressible/simpleFoam/rotorDisk/Allclean index 47d0a0c0c11..09925d447d0 100755 --- a/tutorials/incompressible/simpleFoam/rotorDisk/Allclean +++ b/tutorials/incompressible/simpleFoam/rotorDisk/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/incompressible/simpleFoam/rotorDisk/Allrun b/tutorials/incompressible/simpleFoam/rotorDisk/Allrun index f6f12582312..12d9aa38bfd 100755 --- a/tutorials/incompressible/simpleFoam/rotorDisk/Allrun +++ b/tutorials/incompressible/simpleFoam/rotorDisk/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Meshing runApplication blockMesh diff --git a/tutorials/incompressible/simpleFoam/simpleCar/Allrun b/tutorials/incompressible/simpleFoam/simpleCar/Allrun index db65453658e..f88fe7fd920 100755 --- a/tutorials/incompressible/simpleFoam/simpleCar/Allrun +++ b/tutorials/incompressible/simpleFoam/simpleCar/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/Allclean b/tutorials/incompressible/simpleFoam/turbineSiting/Allclean index abf6e2e700e..c357ba7bfe5 100755 --- a/tutorials/incompressible/simpleFoam/turbineSiting/Allclean +++ b/tutorials/incompressible/simpleFoam/turbineSiting/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 # Remove decomposeParDict rm -f system/decomposeParDict diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/Allrun b/tutorials/incompressible/simpleFoam/turbineSiting/Allrun index fd62abc0fa7..ef45fe0dd57 100755 --- a/tutorials/incompressible/simpleFoam/turbineSiting/Allrun +++ b/tutorials/incompressible/simpleFoam/turbineSiting/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Make dummy 0 directory mkdir 0 diff --git a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean index 8039a752640..53afd7eaead 100755 --- a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean +++ b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun index 06dc7a18c55..cc32f55043d 100755 --- a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun +++ b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication surfaceFeatureExtract diff --git a/tutorials/lagrangian/MPPICFoam/cyclone/Allclean b/tutorials/lagrangian/MPPICFoam/cyclone/Allclean index e274cef962b..d4f2a95a0e3 100755 --- a/tutorials/lagrangian/MPPICFoam/cyclone/Allclean +++ b/tutorials/lagrangian/MPPICFoam/cyclone/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/lagrangian/MPPICFoam/cyclone/Allrun b/tutorials/lagrangian/MPPICFoam/cyclone/Allrun index 8af86abdc32..680e22fbc3b 100755 --- a/tutorials/lagrangian/MPPICFoam/cyclone/Allrun +++ b/tutorials/lagrangian/MPPICFoam/cyclone/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions cp $FOAM_TUTORIALS/resources/geometry/cyclone.stl.gz constant/triSurface diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun index 158fb0bf528..1c2a7447eb1 100755 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create mesh runApplication blockMesh diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun index ac4e385790a..413155fdb03 100755 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun @@ -1,11 +1,11 @@ #!/bin/sh - -cd ${0%/*} || exit 1 # Run from this directory - -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 < system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh runApplication $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean index 47cedce61ea..d837e1f7609 100755 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean @@ -1,20 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +( cd hopperInitialState && cleanCase ) -( - cd hopperInitialState || exit 1 - - cleanCase -) - -( - cd hopperEmptying || exit 1 - - cleanCase - rm -rf 0 -) +( cd hopperEmptying && cleanCase0 ) #------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun index 2beb0f03550..c8e15ac9446 100755 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ( cd hopperInitialState || exit 1 diff --git a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean index 4d36bb740b1..51e9ee16ca9 100755 --- a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean +++ b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/wallFilmRegion rm -f *.obj diff --git a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun index dbc0b12711c..4a206678cd0 100755 --- a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre index 1ad7fbb61c7..1f5781ea73a 100755 --- a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre +++ b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/Allclean b/tutorials/lagrangian/reactingParcelFoam/filter/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/lagrangian/reactingParcelFoam/filter/Allclean +++ b/tutorials/lagrangian/reactingParcelFoam/filter/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/Allrun b/tutorials/lagrangian/reactingParcelFoam/filter/Allrun index 183ac7a8643..683c4a31e0f 100755 --- a/tutorials/lagrangian/reactingParcelFoam/filter/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/filter/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean index 6ed9b627a76..9b60dae89ea 100755 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf system/wallFilmRegion rm -rf constant/wallFilmRegion diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun index dbc0b12711c..4a206678cd0 100755 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel index a061f0da4c3..77822ffda3f 100755 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre index a9f16e526ad..4a6913188f2 100755 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean index 4d36bb740b1..51e9ee16ca9 100755 --- a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean +++ b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/wallFilmRegion rm -f *.obj diff --git a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun index dbc0b12711c..4a206678cd0 100755 --- a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre index 4ff21dad8e0..4002157fcf9 100755 --- a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre +++ b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean index 4d36bb740b1..51e9ee16ca9 100755 --- a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean +++ b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/wallFilmRegion rm -f *.obj diff --git a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun index dbc0b12711c..4a206678cd0 100755 --- a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre index 00eed56aae6..1722219969f 100755 --- a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre +++ b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun index 58c87fca193..9edda44dd8d 100755 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create mesh runApplication blockMesh diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun index 58c87fca193..9edda44dd8d 100755 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create mesh runApplication blockMesh diff --git a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean +++ b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun index 6be8a205163..c2c258a8241 100755 --- a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun +++ b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/mesh/blockMesh/pipe/Allrun b/tutorials/mesh/blockMesh/pipe/Allrun index 3c4ef3e7fff..a33126fcfd5 100755 --- a/tutorials/mesh/blockMesh/pipe/Allrun +++ b/tutorials/mesh/blockMesh/pipe/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/mesh/blockMesh/sphere/Allrun b/tutorials/mesh/blockMesh/sphere/Allrun index 3c4ef3e7fff..a33126fcfd5 100755 --- a/tutorials/mesh/blockMesh/sphere/Allrun +++ b/tutorials/mesh/blockMesh/sphere/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/mesh/blockMesh/sphere7/Allrun b/tutorials/mesh/blockMesh/sphere7/Allrun index 3c4ef3e7fff..a33126fcfd5 100755 --- a/tutorials/mesh/blockMesh/sphere7/Allrun +++ b/tutorials/mesh/blockMesh/sphere7/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun b/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun index 3c4ef3e7fff..a33126fcfd5 100755 --- a/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun +++ b/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/mesh/foamyHexMesh/Allrun b/tutorials/mesh/foamyHexMesh/Allrun index 93da24214e4..d8d59bb6615 100755 --- a/tutorials/mesh/foamyHexMesh/Allrun +++ b/tutorials/mesh/foamyHexMesh/Allrun @@ -1,32 +1,18 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Any cases that are links to solver test cases and are run when the Allrun # scripts of those solvers are run. This script avoids meshing these cases # twice. -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -( - cd blob || exit - ./Allrun $* -) -( - cd simpleShapes || exit - ./Allrun $* -) +( cd blob && ./Allrun $* ) +( cd simpleShapes && ./Allrun $* ) if ! isTest $@ then - ( - cd flange || exit - ./Allrun $* - ) - ( - cd mixerVessel || exit - ./Allrun $* - ) + ( cd flange && ./Allrun $* ) + ( cd mixerVessel && ./Allrun $* ) fi #------------------------------------------------------------------------------ diff --git a/tutorials/mesh/foamyHexMesh/blob/Allclean b/tutorials/mesh/foamyHexMesh/blob/Allclean index f4dcb53f51a..1b3fad50fc9 100755 --- a/tutorials/mesh/foamyHexMesh/blob/Allclean +++ b/tutorials/mesh/foamyHexMesh/blob/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/triSurface/blob.stl.gz > /dev/null 2>&1 diff --git a/tutorials/mesh/foamyHexMesh/blob/Allrun b/tutorials/mesh/foamyHexMesh/blob/Allrun index a4d7bd61d58..b4c8454ee3a 100755 --- a/tutorials/mesh/foamyHexMesh/blob/Allrun +++ b/tutorials/mesh/foamyHexMesh/blob/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy flange surface from resources directory cp $FOAM_TUTORIALS/resources/geometry/blob.stl.gz constant/triSurface/ diff --git a/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel b/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel index 7947ab35f21..32429bd2394 100755 --- a/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel +++ b/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy flange surface from resources directory cp $FOAM_TUTORIALS/resources/geometry/blob.stl.gz constant/triSurface/ diff --git a/tutorials/mesh/foamyHexMesh/flange/Allclean b/tutorials/mesh/foamyHexMesh/flange/Allclean index 75abafd12bb..c4e27e7164d 100755 --- a/tutorials/mesh/foamyHexMesh/flange/Allclean +++ b/tutorials/mesh/foamyHexMesh/flange/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -r constant/triSurface/flange.stl.gz > /dev/null 2>&1 diff --git a/tutorials/mesh/foamyHexMesh/flange/Allrun b/tutorials/mesh/foamyHexMesh/flange/Allrun index 414ca8f4a3d..5487824ca4b 100755 --- a/tutorials/mesh/foamyHexMesh/flange/Allrun +++ b/tutorials/mesh/foamyHexMesh/flange/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy flange surface from resources directory cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/ diff --git a/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel b/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel index fb57faff8e1..c9e154a60cf 100755 --- a/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel +++ b/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy flange surface from resources directory cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/ diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean b/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean index afee03547e3..7a64d7a6b53 100755 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/extendedFeatureEdgeMesh/ rm -f constant/triSurface/*.eMesh* diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun index b66c25a9a4a..5aabd4c3eea 100755 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Generate mesh ./Allrun-pre diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre index 21c5d3f1998..fa89b7f6c32 100755 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions intersectSurfaces() { @@ -38,7 +36,7 @@ intersectSurfaces stirrer_baffles.stl stirrer.stl -surf1Baffle -perturb intersectSurfaces rotating.stl shaft.stl -surf1Baffle -perturb # Intersect blades with the plate -for bladeI in $(seq 1 6); +for bladeI in $(seq 1 6) do intersectSurfaces \ stirrer_baffles_$bladeI.obj \ diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation index 392878e5d3a..a7922952e6b 100755 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions cp system/controlDict.flow system/controlDict diff --git a/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean b/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean index 5ef122ebb30..42523e30e7b 100755 --- a/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean +++ b/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -r constant/extendedFeatureEdgeMesh constant/internalDelaunayVertices > /dev/null 2>&1 rm -f constant/triSurface/*.eMesh > /dev/null 2>&1 diff --git a/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun b/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun index 1535c7a3a82..482564c8b5d 100755 --- a/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun +++ b/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication -s cone \ surfaceOrient constant/triSurface/cone.stl \ diff --git a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean index 894a75c4e03..26eaea4667a 100755 --- a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean +++ b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1 rm -rf constant/triSurface/*.eMesh > /dev/null 2>&1 diff --git a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun index cdd750415ca..f22a5824bb5 100755 --- a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun +++ b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Make sure surface is oriented properly. Since the letters diff --git a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam index 56aef09d09b..c4060eedef0 100755 --- a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam +++ b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions \cp system/controlDict.rhoCentralFoam system/controlDict restore0Dir diff --git a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean index 1048413963c..429017895d4 100755 --- a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean +++ b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun index 5434248652e..f559f8204e3 100755 --- a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun +++ b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication surfaceFeatureExtract runApplication foamyQuadMesh -overwrite diff --git a/tutorials/mesh/foamyQuadMesh/square/Allclean b/tutorials/mesh/foamyQuadMesh/square/Allclean index 8da713f31dc..dc764a614a3 100755 --- a/tutorials/mesh/foamyQuadMesh/square/Allclean +++ b/tutorials/mesh/foamyQuadMesh/square/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/mesh/foamyQuadMesh/square/Allrun b/tutorials/mesh/foamyQuadMesh/square/Allrun index 87a113fc126..f72c275f01f 100755 --- a/tutorials/mesh/foamyQuadMesh/square/Allrun +++ b/tutorials/mesh/foamyQuadMesh/square/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication surfaceFeatureExtract runApplication foamyQuadMesh -overwrite diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean index a94a6172db5..57317ddb1ff 100755 --- a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean +++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean @@ -1,19 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -( - cd box_snappyHexMesh || exit 1 - cleanCase -) - -( - cd box2D_moveDynamicMesh || exit 1 - cleanCase - rm -rf 0 -) +( cd box_snappyHexMesh && cleanCase ) +( cd box2D_moveDynamicMesh && cleanCase0 ) #------------------------------------------------------------------------------ diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun index 456beeaab5f..785ab59cd0b 100755 --- a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun +++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Make 3D mesh in slab of cells. ( diff --git a/tutorials/mesh/parallel/cavity/Allclean b/tutorials/mesh/parallel/cavity/Allclean index ee9845194cb..3bd36a4b031 100755 --- a/tutorials/mesh/parallel/cavity/Allclean +++ b/tutorials/mesh/parallel/cavity/Allclean @@ -7,4 +7,4 @@ cleanCase # Restore default dictionaries cp system/controlDict-startTime system/controlDict -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/mesh/parallel/cavity/Allrun b/tutorials/mesh/parallel/cavity/Allrun index 6c7668f4faf..fdb4a734ca7 100755 --- a/tutorials/mesh/parallel/cavity/Allrun +++ b/tutorials/mesh/parallel/cavity/Allrun @@ -30,4 +30,4 @@ runParallel -s 5 $decompDict5 icoFoam # Reconstruct mesh and results runParallel -s reconstruct -np 5 redistributePar -reconstruct -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/mesh/parallel/filter/Allclean b/tutorials/mesh/parallel/filter/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/mesh/parallel/filter/Allclean +++ b/tutorials/mesh/parallel/filter/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/mesh/parallel/filter/Allrun b/tutorials/mesh/parallel/filter/Allrun index 598afe74a52..5ac013e09f7 100755 --- a/tutorials/mesh/parallel/filter/Allrun +++ b/tutorials/mesh/parallel/filter/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions application=$(getApplication) @@ -29,4 +27,4 @@ runParallel -s parallel $application #- Reconstruct all times runParallel -s 1 redistributePar -reconstruct -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/mesh/refineMesh/refineFieldDirs/Allclean b/tutorials/mesh/refineMesh/refineFieldDirs/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/mesh/refineMesh/refineFieldDirs/Allclean +++ b/tutorials/mesh/refineMesh/refineFieldDirs/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/mesh/refineMesh/refineFieldDirs/Allrun b/tutorials/mesh/refineMesh/refineFieldDirs/Allrun index c3bdd399618..26cdf66ba12 100755 --- a/tutorials/mesh/refineMesh/refineFieldDirs/Allrun +++ b/tutorials/mesh/refineMesh/refineFieldDirs/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions wmake calcRadiusField wclean calcRadiusField diff --git a/tutorials/mesh/snappyHexMesh/Allrun b/tutorials/mesh/snappyHexMesh/Allrun index f81482f8745..976f75d38cb 100755 --- a/tutorials/mesh/snappyHexMesh/Allrun +++ b/tutorials/mesh/snappyHexMesh/Allrun @@ -1,21 +1,9 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory - -( - cd flange || exit - ./Allrun $* -) - -( - cd addLayersToFaceZone || exit - ./Allrun -) - -( - cd gap_detection || exit - ./Allrun -) +( cd flange && ./Allrun $* ) +( cd addLayersToFaceZone && ./Allrun ) +( cd gap_detection && ./Allrun ) exit 0 diff --git a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean +++ b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun index 7a0dffe68c3..0ee02ee2269 100755 --- a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun +++ b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/mesh/snappyHexMesh/flange/Allclean b/tutorials/mesh/snappyHexMesh/flange/Allclean index e46b494f7bf..69d183efe5b 100755 --- a/tutorials/mesh/snappyHexMesh/flange/Allclean +++ b/tutorials/mesh/snappyHexMesh/flange/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -f ./flange ./*.obj > /dev/null 2>&1 diff --git a/tutorials/mesh/snappyHexMesh/flange/Allrun b/tutorials/mesh/snappyHexMesh/flange/Allrun index cae2427078d..8e2c10e1edd 100755 --- a/tutorials/mesh/snappyHexMesh/flange/Allrun +++ b/tutorials/mesh/snappyHexMesh/flange/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy flange surface from resources directory cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/ diff --git a/tutorials/mesh/snappyHexMesh/gap_detection/Allclean b/tutorials/mesh/snappyHexMesh/gap_detection/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/mesh/snappyHexMesh/gap_detection/Allclean +++ b/tutorials/mesh/snappyHexMesh/gap_detection/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/mesh/snappyHexMesh/gap_detection/Allrun b/tutorials/mesh/snappyHexMesh/gap_detection/Allrun index fb62f26883d..afb0ddb7344 100755 --- a/tutorials/mesh/snappyHexMesh/gap_detection/Allrun +++ b/tutorials/mesh/snappyHexMesh/gap_detection/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean index eb6c79aa663..8b16e2858e0 100755 --- a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean +++ b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean @@ -1,12 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -f system/blockMeshDict rm -f 0/alpha.water -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun index 73737743f25..b2023e2d8f4 100755 --- a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun +++ b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # create the underlying block mesh m4 system/pachuka.m4 > system/blockMeshDict @@ -29,4 +27,4 @@ runParallel $(getApplication) # Reconstruct case runApplication reconstructPar -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/cavitatingFoam/LES/Allrun b/tutorials/multiphase/cavitatingFoam/LES/Allrun index e0ffdffe185..153b2506fcb 100755 --- a/tutorials/multiphase/cavitatingFoam/LES/Allrun +++ b/tutorials/multiphase/cavitatingFoam/LES/Allrun @@ -1,14 +1,7 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -( - cd throttle || exit - ./Allrun $* -) - -( - cd throttle3D || exit - ./Allrun $* -) +( cd throttle && ./Allrun $* ) +( cd throttle3D && ./Allrun $* ) #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean index 6bb45f9da9b..7e94847a483 100755 --- a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean +++ b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun index d399430e224..1b1d5e80a04 100755 --- a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun +++ b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions refineMeshByCellSet() { diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean index 8b8b96fa046..d695acbf073 100755 --- a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean +++ b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm system/topoSetDict > /dev/null 2>&1 rm -rf processor[0-9] > /dev/null 2>&1 diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun index 39816254dd4..15a39575b71 100755 --- a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun +++ b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions refineMeshByCellSet() { diff --git a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean index 6bb45f9da9b..7e94847a483 100755 --- a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean +++ b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun index d399430e224..1b1d5e80a04 100755 --- a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun +++ b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions refineMeshByCellSet() { diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun index 31527e6ec22..c63280a960d 100755 --- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun +++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean index e49ac35744e..e2f275d9fd6 100755 --- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean +++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean @@ -1,9 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -cleanCase - -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun index 7c3704c1685..55bb318bf30 100755 --- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun +++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel index bdf2b279c78..e66ceb6b8f9 100755 --- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel +++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean +++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun index fd07af1d46b..423e9ec8333 100755 --- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun +++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh restore0Dir diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean index 86d93673831..3b8c6e8e2fb 100755 --- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean +++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf processor* #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun index 6c6dafdea44..bdb96428fab 100755 --- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun +++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh restore0Dir diff --git a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean +++ b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun index 6cfec647c79..efced0038e9 100755 --- a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun +++ b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun index f1273de8e41..6aeae155532 100755 --- a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun +++ b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh index 4d667956a0a..4065edb322f 100755 --- a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh @@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict blockMesh topoSet setsToZones -noFlipMap + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun b/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun index c96f61d7ef3..16a6a8651d6 100755 --- a/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun +++ b/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication $(getApplication) diff --git a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean +++ b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun index ebc19b3d2a4..5aace967ac4 100755 --- a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun +++ b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions application=$(getApplication) diff --git a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean index a0aed574d06..6149df2bfa8 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean +++ b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean @@ -1,11 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -cleanCase -rm -rf 0 rm system/topoSetDict > /dev/null 2>&1 # Remove surface and features diff --git a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun index 99249befa72..975e30d65ed 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun +++ b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy DTC hull surface from resources folder cp $FOAM_TUTORIALS/resources/geometry/DTC-scaled.stl.gz constant/triSurface/ diff --git a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean +++ b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun index 6a9d0d02293..7aede960f72 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun +++ b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean index d3b4c4257f3..9f8dfd78081 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean +++ b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 > /dev/null 2>&1 +cleanCase0 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1 rm -f constant/triSurface/*.eMesh* > /dev/null 2>&1 diff --git a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun index 83e66bcf9ca..62fbd9b2141 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun +++ b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre index 0d993b2ee7d..684bc569961 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre +++ b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions \rm -rf 0 diff --git a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean index 5442dc1333e..a8a5c30fc0f 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean +++ b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 # Remove surface and features \rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1 @@ -14,4 +11,4 @@ rm -rf 0 \cp system/controlDict_run system/controlDict -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun index af3c3b444d5..e2641b89348 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun +++ b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre @@ -16,4 +14,4 @@ FOAM_SIGFPE=false runParallel -s reconstruct redistributePar -reconstruct runParallel -s decompose redistributePar -decompose -latestTime runParallel -s restart $(getApplication) -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre index d4a3ff96399..030f1f8113c 100755 --- a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre +++ b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy motorbike surface from resources directory \cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/ diff --git a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean index c9e8210d778..dced1dda723 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean +++ b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm system/cellSetDict > /dev/null 2>&1 diff --git a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun index 755d7612a41..4c6e367d388 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir runApplication blockMesh diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun index 355fea57a8d..9fa872e193f 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication snappyHexMesh -overwrite diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun index e827b4c66ab..ae24f74396c 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun index e827b4c66ab..ae24f74396c 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun index e827b4c66ab..ae24f74396c 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun index 823b296e60d..faada17ac68 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun index 31527e6ec22..c63280a960d 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict runApplication blockMesh diff --git a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean index 8c9c9abaac6..e068de2b139 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean +++ b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm -rf 0/alpha.water diff --git a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun index 0af06e79fb4..a96f714b609 100755 --- a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun +++ b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh cp 0/alpha.water.orig 0/alpha.water diff --git a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean index 473383859a0..20ea2353bb1 100755 --- a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean +++ b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm system/topoSetDict > /dev/null 2>&1 diff --git a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun index f110e3491b5..dc59cb1831b 100755 --- a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun +++ b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean b/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean index 0086cd47cb0..9c855955a4e 100755 --- a/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean +++ b/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm system/topoSetDict > /dev/null 2>&1 diff --git a/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun b/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun index 3eddb17d71b..2bd2c19a2ff 100755 --- a/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun +++ b/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy DTC hull surface from resources folder \cp $FOAM_TUTORIALS/resources/geometry/DTC-scaled.stl.gz constant/triSurface/ diff --git a/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun b/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun index ccdfefe5c1c..54368cee898 100755 --- a/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun +++ b/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 system/blockMeshDict.m4 > system/blockMeshDict diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/Allclean b/tutorials/multiphase/interFoam/RAS/damBreak/Allclean index efbd66e1c26..050c71bde5f 100755 --- a/tutorials/multiphase/interFoam/RAS/damBreak/Allclean +++ b/tutorials/multiphase/interFoam/RAS/damBreak/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions keepCases="damBreak" loseCases="damBreakFine" diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/Allrun b/tutorials/multiphase/interFoam/RAS/damBreak/Allrun index 928fc5036d5..5588e4ecd03 100755 --- a/tutorials/multiphase/interFoam/RAS/damBreak/Allrun +++ b/tutorials/multiphase/interFoam/RAS/damBreak/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions setDamBreakFine () { diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean index 652e15f7215..f578727b2fe 100755 --- a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean +++ b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase \cp 0/alpha.water.orig 0/alpha.water diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun index ed61ac54353..5bd0f99f303 100755 --- a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun +++ b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication setFields diff --git a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean index 652e15f7215..f578727b2fe 100755 --- a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean +++ b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase \cp 0/alpha.water.orig 0/alpha.water diff --git a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun index 4c6866acbc1..7d165432443 100755 --- a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun +++ b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication setFields diff --git a/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean b/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean index e67e3024e88..b5e3d9ce881 100755 --- a/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean +++ b/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh b/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh index 92d09ceaef7..d0b3f753781 100755 --- a/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh +++ b/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun b/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun index 5a86d49dcb6..072b6d2b199 100755 --- a/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun +++ b/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allmesh diff --git a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean +++ b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun index e0a3d741250..c7107259267 100755 --- a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun +++ b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun b/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun index b52e0c12fd0..42050e1779d 100755 --- a/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun +++ b/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh \cp 0/alpha.water.orig 0/alpha.water diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/Allclean b/tutorials/multiphase/interFoam/laminar/damBreak/Allclean index efbd66e1c26..050c71bde5f 100755 --- a/tutorials/multiphase/interFoam/laminar/damBreak/Allclean +++ b/tutorials/multiphase/interFoam/laminar/damBreak/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions keepCases="damBreak" loseCases="damBreakFine" diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/Allrun b/tutorials/multiphase/interFoam/laminar/damBreak/Allrun index 928fc5036d5..5588e4ecd03 100755 --- a/tutorials/multiphase/interFoam/laminar/damBreak/Allrun +++ b/tutorials/multiphase/interFoam/laminar/damBreak/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions setDamBreakFine () { diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean index 652e15f7215..f578727b2fe 100755 --- a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean +++ b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase \cp 0/alpha.water.orig 0/alpha.water diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun index ed61ac54353..5bd0f99f303 100755 --- a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun +++ b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication setFields diff --git a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun index d347ad0a845..3aa1e7a9dd9 100755 --- a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun +++ b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh \cp 0/alpha.water.orig 0/alpha.water diff --git a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh index 4d667956a0a..4065edb322f 100755 --- a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh @@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict blockMesh topoSet setsToZones -noFlipMap + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun index da1575a1aa0..a9796a5b0f0 100755 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun @@ -1,9 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions (cd eulerianInjection && ./Allrun) (cd lagrangianParticleInjection && ./Allrun) (cd lagrangianDistributionInjection && ./Allrun) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean index 8976b1e90b5..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -\rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun index 8c13891df5b..bf653b64836 100755 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication -s createBlockage topoSet -dict system/topoSetDict.createBlockage diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean index c07f861837c..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean @@ -1,8 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -\rm -rf 0 -cleanCase +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun index 8c4e782f632..3dd409fe044 100755 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions eulerianCase=../eulerianInjection @@ -53,3 +51,5 @@ runApplication decomposePar runParallel $(getApplication) runApplication reconstructPar + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean index c07f861837c..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean @@ -1,8 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -\rm -rf 0 -cleanCase +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun index 8c4e782f632..3dd409fe044 100755 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions eulerianCase=../eulerianInjection @@ -53,3 +51,5 @@ runApplication decomposePar runParallel $(getApplication) runApplication reconstructPar + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean index 705f91474c4..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean +++ b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -rm -rf 0 - -cleanCase +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun index 9f0c668029a..28bf991e627 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun +++ b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -13,3 +11,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean index 705f91474c4..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean +++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -rm -rf 0 - -cleanCase +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun index 9f0c668029a..28bf991e627 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun +++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -13,3 +11,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean index 705f91474c4..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean +++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -rm -rf 0 - -cleanCase +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun index 9f0c668029a..28bf991e627 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun +++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -13,3 +11,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean index 705f91474c4..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean +++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -rm -rf 0 - -cleanCase +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun index 9f0c668029a..28bf991e627 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun +++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -13,3 +11,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean index 705f91474c4..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -rm -rf 0 - -cleanCase +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun index 9f0c668029a..28bf991e627 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -13,3 +11,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean index 705f91474c4..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -rm -rf 0 - -cleanCase +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun index 9f0c668029a..28bf991e627 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -13,3 +11,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean index 705f91474c4..e2f275d9fd6 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -rm -rf 0 - -cleanCase +cleanCase0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun index 9f0c668029a..28bf991e627 100755 --- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -13,3 +11,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/damBreak/Allclean b/tutorials/multiphase/interIsoFoam/damBreak/Allclean index 513c366d4e4..40363dccf7f 100755 --- a/tutorials/multiphase/interIsoFoam/damBreak/Allclean +++ b/tutorials/multiphase/interIsoFoam/damBreak/Allclean @@ -1,9 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 +\rm -rf isoFaces -cleanCase - -\rm -rf 0 isoFaces +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/damBreak/Allrun b/tutorials/multiphase/interIsoFoam/damBreak/Allrun index 73a4aa44fc9..afce7038479 100755 --- a/tutorials/multiphase/interIsoFoam/damBreak/Allrun +++ b/tutorials/multiphase/interIsoFoam/damBreak/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -10,3 +8,5 @@ runApplication blockMesh runApplication setFields runApplication $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel b/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel index 729fedf62cb..2a2861b7303 100755 --- a/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel +++ b/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -11,3 +9,5 @@ runApplication decomposePar runParallel setFields runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean index 78449efd836..e2f275d9fd6 100755 --- a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean +++ b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean @@ -1,8 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -cleanCase -\rm -rf 0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun index 47d57eb4f77..4abdc78d004 100755 --- a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun +++ b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun @@ -1,7 +1,6 @@ -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -9,3 +8,5 @@ runApplication blockMesh runApplication setAlphaField runApplication $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean index c11c2183476..e2f275d9fd6 100755 --- a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean +++ b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean @@ -1,7 +1,7 @@ -#!/bin/bash +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -cleanCase -\rm -rf 0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun index 474424491f3..7e395e78326 100755 --- a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun +++ b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -15,3 +13,5 @@ runApplication -s 2 refineMesh -overwrite runApplication setAlphaField runApplication $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean index 97f2707db81..e2f275d9fd6 100755 --- a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean +++ b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean @@ -1,9 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -cleanCase - -\rm -rf 0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun index 317234a300a..a919ed91c4a 100755 --- a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun +++ b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions application=$(getApplication) @@ -17,3 +15,5 @@ runApplication setAlphaField runApplication setFields runApplication ${application} + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean index c11c2183476..e2f275d9fd6 100755 --- a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean +++ b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean @@ -1,7 +1,7 @@ -#!/bin/bash +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -cleanCase -\rm -rf 0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun index f21f9b5925b..1767cd6b1b3 100755 --- a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun +++ b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -11,3 +9,5 @@ runApplication blockMesh runApplication setAlphaField runApplication decomposePar runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/standingWave/Allclean b/tutorials/multiphase/interIsoFoam/standingWave/Allclean index 9738fda663b..e2f275d9fd6 100755 --- a/tutorials/multiphase/interIsoFoam/standingWave/Allclean +++ b/tutorials/multiphase/interIsoFoam/standingWave/Allclean @@ -1,9 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -cleanCase - -\rm -rf 0 +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interIsoFoam/standingWave/Allrun b/tutorials/multiphase/interIsoFoam/standingWave/Allrun index 3f7a4cb538a..d00d2326e7f 100755 --- a/tutorials/multiphase/interIsoFoam/standingWave/Allrun +++ b/tutorials/multiphase/interIsoFoam/standingWave/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir @@ -15,3 +13,5 @@ runApplication -s 2 refineMesh -dict system/refineMeshDict2 -overwrite runApplication setAlphaField runApplication $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun index b20c96d45ab..48c2856ca16 100755 --- a/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh cp 0/alpha.air.orig 0/alpha.air diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean index af5bf72167e..d31f20c24dd 100755 --- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean +++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 > /dev/null 2>&1 +cleanCase0 # Remove surface rm -f constant/triSurface/propellerTip.obj.gz > /dev/null 2>&1 diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun index 59aa02e7533..b44aaf01a37 100755 --- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun +++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre index b9980dd726d..b39d40fad9c 100755 --- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre +++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre @@ -1,13 +1,10 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy propeller surface from resources directory \cp $FOAM_TUTORIALS/resources/geometry/propellerTip.obj.gz constant/triSurface/ - # - meshing runApplication blockMesh @@ -18,7 +15,6 @@ runApplication renumberMesh -overwrite # force removal of fields generated by snappy rm -rf 0 - # - generate face/cell sets and zones #runApplication setSet -batch createInletOutletSets.setSet @@ -28,11 +24,9 @@ runApplication topoSet -dict system/createInletOutletSets.topoSetDict runApplication createPatch -overwrite - # - test by running moveDynamicMesh #runApplication moveDynamicMesh -checkAMI - # - apply the initial fields restore0Dir diff --git a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean index 05fe1e79a3f..24df93fd3d2 100755 --- a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean +++ b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 # Remove surface rm -f constant/triSurface/bullet.stl.gz diff --git a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun index 4f35a71a264..dd1ff0aa950 100755 --- a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun +++ b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Copy bullet surface from resources directory cp $FOAM_TUTORIALS/resources/geometry/bullet.stl.gz constant/triSurface/ diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean +++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun index 6cfec647c79..efced0038e9 100755 --- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun +++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean +++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun index fb2c7cf7a73..125f3e96ba2 100755 --- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun +++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun index f1273de8e41..6aeae155532 100755 --- a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun +++ b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh index 4d667956a0a..4065edb322f 100755 --- a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh @@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict blockMesh topoSet setsToZones -noFlipMap + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun index cf76c5c4a6c..3d69efdb3a2 100755 --- a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun +++ b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./makeMesh diff --git a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh index bcb12c0e9ac..fc56e7be3ce 100755 --- a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh +++ b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions m4 < system/blockMeshDict.m4 > system/blockMeshDict diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun index 6cfec647c79..efced0038e9 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun index fb2c7cf7a73..125f3e96ba2 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean index e62451c67f9..feb117fb229 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase rm 0/alphas > /dev/null 2>&1 diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun index f1273de8e41..6aeae155532 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh index 4d667956a0a..4065edb322f 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh @@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict blockMesh topoSet setsToZones -noFlipMap + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean index e3c5c15e9c9..27381f42e7b 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean @@ -1,10 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions (cd background && ./Allclean) (cd floatingBody && ./Allclean) -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun index 95ffcc4bf4c..66997244578 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun @@ -1,10 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions ./Allrun.pre (cd background && runApplication $(getApplication)) -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre index a69774179d3..ef286ecbfa8 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre @@ -1,8 +1,11 @@ #!/bin/sh -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # mesh floating body (cd floatingBody && ./Allrun.pre) # Add background mesh (cd background && ./Allrun.pre) + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean index e49ac35744e..e2f275d9fd6 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean @@ -1,9 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -cleanCase - -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre index 31eb9edf99d..9a44881018b 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre @@ -1,6 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # Create background mesh runApplication blockMesh diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean index d16400a94f6..e2f275d9fd6 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean @@ -1,11 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cleanCase0 -rm -rf 0 > /dev/null 2>&1 - -cleanCase - -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre index 0a33b80dda3..8142d7c389d 100755 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre @@ -1,11 +1,9 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet runApplication subsetMesh -overwrite c0 -patch floatingObject -# ----------------------------------------------------------------- end-of-file +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean index 5b172378266..496dfec3c17 100755 --- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean +++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf poolHeight poolHeight_vs_time #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun index 7cdbc56f458..40555d56e14 100755 --- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun +++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData index b653b581b7a..4f6979a83f0 100755 --- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData +++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData @@ -1,2 +1,5 @@ #!/bin/sh + awk '{print $1 " " $3}' postProcessing/poolHeight/0/surfaceFieldValue.dat > poolHeight_vs_time + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean index 5b172378266..496dfec3c17 100755 --- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean +++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf poolHeight poolHeight_vs_time #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun index 03b5ca39482..897dccd0bb7 100755 --- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun +++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication topoSet diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData index b653b581b7a..4f6979a83f0 100755 --- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData +++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData @@ -1,2 +1,5 @@ #!/bin/sh + awk '{print $1 " " $3}' postProcessing/poolHeight/0/surfaceFieldValue.dat > poolHeight_vs_time + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun index f1273de8e41..6aeae155532 100755 --- a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun +++ b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh index 4d667956a0a..4065edb322f 100755 --- a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh @@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict blockMesh topoSet setsToZones -noFlipMap + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean index 4d3ae417ce6..ba5873a4aef 100755 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase cp ./system/controlDict.org ./system/controlDict diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun index 59d62c7881f..001a60c8fdd 100755 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean index 4d3ae417ce6..ba5873a4aef 100755 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase cp ./system/controlDict.org ./system/controlDict diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun index 59d62c7881f..001a60c8fdd 100755 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun index f1273de8e41..6aeae155532 100755 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh index 4d667956a0a..4065edb322f 100755 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh @@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict blockMesh topoSet setsToZones -noFlipMap + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean +++ b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun index 6cfec647c79..efced0038e9 100755 --- a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun +++ b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions restore0Dir diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun index f1273de8e41..6aeae155532 100755 --- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun +++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh runApplication $(getApplication) diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh index 4d667956a0a..4065edb322f 100755 --- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh @@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict blockMesh topoSet setsToZones -noFlipMap + +#------------------------------------------------------------------------------ diff --git a/tutorials/preProcessing/createZeroDirectory/cavity/Allclean b/tutorials/preProcessing/createZeroDirectory/cavity/Allclean index 61edfb30323..e2f275d9fd6 100755 --- a/tutorials/preProcessing/createZeroDirectory/cavity/Allclean +++ b/tutorials/preProcessing/createZeroDirectory/cavity/Allclean @@ -1,10 +1,7 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/preProcessing/createZeroDirectory/cavity/Allrun b/tutorials/preProcessing/createZeroDirectory/cavity/Allrun index 909a10a372f..51286c4dbda 100755 --- a/tutorials/preProcessing/createZeroDirectory/cavity/Allrun +++ b/tutorials/preProcessing/createZeroDirectory/cavity/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication createZeroDirectory diff --git a/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean b/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean index 7ba7ddabb3e..b52876b6996 100755 --- a/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean +++ b/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 # Remove surface and features \rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1 diff --git a/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun b/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun index bec223b5dee..9dce39c1732 100755 --- a/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun +++ b/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions # copy motorbike surface from resources folder cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/ @@ -22,4 +20,4 @@ runParallel $(getApplication) runApplication reconstructParMesh -constant runApplication reconstructPar -latestTime -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean index c0d30ba4bfd..b8032f8f34e 100755 --- a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean +++ b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean @@ -1,11 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions - -cleanCase -rm -rf 0 +cleanCase0 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1 rm -f constant/triSurface/*.eMesh > /dev/null 2>&1 @@ -17,4 +14,4 @@ rm -rf constant/heater/polyMesh rm -rf constant/leftSolid/polyMesh rm -rf constant/rightSolid/polyMesh -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun index 6b946fe298e..15fab73b655 100755 --- a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun +++ b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions rm -rf constant/polyMesh/sets @@ -34,4 +32,4 @@ echo "creating files for paraview post-processing" echo paraFoam -touchAll -# ----------------------------------------------------------------------------- +#------------------------------------------------------------------------------ diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean index 6b45f82a41b..be7ddb06884 100755 --- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean +++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial clean functions -. $WM_PROJECT_DIR/bin/tools/CleanFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun index 9c5c0bb36ee..e59dad068ee 100755 --- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun +++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication blockMesh runApplication $(getApplication) -- GitLab From 74f667a85be07ce2d7505f7afd2a86fbc0cf43a7 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 20 Oct 2017 10:26:55 +0200 Subject: [PATCH 043/126] ENH: additional low-level raw binary output for Ostream. - low-level beginRaw(), writeRaw(), endRaw() methods. These can be used to directly add '()' decorators for serial output or prepare/cleanup parallel buffers. Used, for example, when outputting indirect lists in binary to avoid. --- .../test/IndirectList/Test-IndirectList.C | 65 +++++++++++- .../containers/Lists/FixedList/FixedListIO.C | 16 +-- src/OpenFOAM/containers/Lists/List/ListIO.C | 16 +-- .../containers/Lists/PtrList/PtrListIO.C | 10 +- .../Lists/UIndirectList/UIndirectListIO.C | 67 +++++++------ src/OpenFOAM/containers/Lists/UList/UListIO.C | 72 +++++++------- .../containers/Lists/UPtrList/UPtrListIO.C | 18 ++-- src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H | 45 ++++++--- .../db/IOstreams/Pstreams/UOPstream.C | 99 +++++++++++++++---- .../db/IOstreams/Pstreams/UOPstream.H | 27 ++++- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C | 48 ++++++++- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H | 21 +++- 12 files changed, 370 insertions(+), 134 deletions(-) diff --git a/applications/test/IndirectList/Test-IndirectList.C b/applications/test/IndirectList/Test-IndirectList.C index 4727ed52484..449af8ca7d4 100644 --- a/applications/test/IndirectList/Test-IndirectList.C +++ b/applications/test/IndirectList/Test-IndirectList.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,15 +27,18 @@ Description #include "IndirectList.H" #include "IOstreams.H" +#include "Fstream.H" #include "ListOps.H" #include "labelIndList.H" +#include "argList.H" using namespace Foam; template<class ListType> void printInfo(const ListType& lst) { - Info<< "addr: " << flatOutput(lst.addressing()) << nl + Info<< "full: " << flatOutput(lst.completeList()) << nl + << "addr: " << flatOutput(lst.addressing()) << nl << "list: " << flatOutput(lst) << nl << endl; } @@ -61,6 +64,15 @@ void testFind(const T& val, const ListType& lst) int main(int argc, char *argv[]) { + argList::addOption + ( + "binary", + "file", + "write lists in binary to specified file" + ); + + argList args(argc, argv); + List<label> completeList(20); forAll(completeList, i) @@ -104,6 +116,55 @@ int main(int argc, char *argv[]) printInfo(idl2); printInfo(idl3); + fileName binaryOutput; + if (args.optionReadIfPresent("binary", binaryOutput)) + { + Info<<"Writing output to " << binaryOutput << endl; + + OFstream os(binaryOutput, IOstream::BINARY); + + os.writeEntry("idl1", idl1); + os.writeEntry("idl2", idl2); + os.writeEntry("idl3", idl3); + } + + if (Pstream::parRun()) + { + if (Pstream::master()) + { + Pout<< "full: " << flatOutput(idl3.completeList()) << nl + << "send: " << flatOutput(idl3) << endl; + + for + ( + int slave = Pstream::firstSlave(); + slave <= Pstream::lastSlave(); + ++slave + ) + { + OPstream toSlave(Pstream::commsTypes::scheduled, slave); + toSlave << idl3; + } + } + else + { + // From master + IPstream fromMaster + ( + Pstream::commsTypes::scheduled, + Pstream::masterNo() + ); + + List<label> recv(fromMaster); + + Pout<<"recv: " << flatOutput(recv) << endl; + } + + // MPI barrier + bool barrier = true; + Pstream::scatter(barrier); + } + Info<< "End\n" << endl; return 0; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C index 6d1d65b20e2..87851fcef4a 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C @@ -91,10 +91,10 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList // Write size (so it is valid dictionary entry) and start delimiter os << Size << token::BEGIN_BLOCK; - // Write contents + // Contents os << L[0]; - // Write end delimiter + // End delimiter os << token::END_BLOCK; } else if @@ -103,31 +103,31 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList || (Size <= unsigned(shortListLen) && contiguous<T>()) ) { - // Write start delimiter + // Start delimiter os << token::BEGIN_LIST; - // Write contents + // Contents forAll(L, i) { if (i) os << token::SPACE; os << L[i]; } - // Write end delimiter + // End delimiter os << token::END_LIST; } else { - // Write start delimiter + // Start delimiter os << nl << token::BEGIN_LIST << nl; - // Write contents + // Contents forAll(L, i) { os << L[i] << nl; } - // Write end delimiter + // End delimiter os << token::END_LIST << nl; } } diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C index b21b6a86648..b29418c24a1 100644 --- a/src/OpenFOAM/containers/Lists/List/ListIO.C +++ b/src/OpenFOAM/containers/Lists/List/ListIO.C @@ -64,10 +64,10 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L) } else if (firstToken.isLabel()) { - const label s = firstToken.labelToken(); + const label sz = firstToken.labelToken(); // Set list length to that read - L.setSize(s); + L.setSize(sz); // Read list contents depending on data format @@ -76,11 +76,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L) // Read beginning of contents const char delimiter = is.readBeginList("List"); - if (s) + if (sz) { if (delimiter == token::BEGIN_LIST) { - for (label i=0; i<s; ++i) + for (label i=0; i<sz; ++i) { is >> L[i]; @@ -103,7 +103,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L) "reading the single entry" ); - for (label i=0; i<s; ++i) + for (label i=0; i<sz; ++i) { L[i] = element; } @@ -115,11 +115,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L) } else { - // contents are binary and contiguous + // Contents are binary and contiguous - if (s) + if (sz) { - is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T)); + is.read(reinterpret_cast<char*>(L.data()), sz*sizeof(T)); is.fatalCheck ( diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C b/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C index 6aff9ed81e0..594aa01e4dd 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C @@ -48,19 +48,19 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt) if (firstToken.isLabel()) { // Read size of list - const label s = firstToken.labelToken(); + const label sz = firstToken.labelToken(); // Set list length to that read - setSize(s); + setSize(sz); // Read beginning of contents const char delimiter = is.readBeginList("PtrList"); - if (s) + if (sz) { if (delimiter == token::BEGIN_LIST) { - forAll(*this, i) + for (label i=0; i<sz; ++i) { set(i, inewt(is)); @@ -82,7 +82,7 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt) "reading the single entry" ); - for (label i=1; i<s; ++i) + for (label i=1; i<sz; ++i) { set(i, tPtr->clone()); } diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C index de49fc74a0c..b990952e2d4 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C @@ -39,14 +39,16 @@ Foam::Ostream& Foam::UIndirectList<T>::writeList { const UIndirectList<T>& L = *this; + const label sz = L.size(); + // Write list contents depending on data format if (os.format() == IOstream::ASCII || !contiguous<T>()) { // Can the contents be considered 'uniform' (ie, identical)? - bool uniform = (L.size() > 1 && contiguous<T>()); + bool uniform = (sz > 1 && contiguous<T>()); if (uniform) { - forAll(L, i) + for (label i=1; i < sz; ++i) { if (L[i] != L[0]) { @@ -58,65 +60,72 @@ Foam::Ostream& Foam::UIndirectList<T>::writeList if (uniform) { - // Write size and start delimiter - os << L.size() << token::BEGIN_BLOCK; + // Size and start delimiter + os << sz << token::BEGIN_BLOCK; - // Write contents + // Contents os << L[0]; - // Write end delimiter + // End delimiter os << token::END_BLOCK; } else if ( - L.size() <= 1 || !shortListLen - || (L.size() <= shortListLen && contiguous<T>()) + sz <= 1 || !shortListLen + || (sz <= shortListLen && contiguous<T>()) ) { - // Write size and start delimiter - os << L.size() << token::BEGIN_LIST; + // Size and start delimiter + os << sz << token::BEGIN_LIST; - // Write contents - forAll(L, i) + // Contents + for (label i=0; i < sz; ++i) { if (i) os << token::SPACE; os << L[i]; } - // Write end delimiter + // End delimiter os << token::END_LIST; } else { - // Write size and start delimiter - os << nl << L.size() << nl << token::BEGIN_LIST << nl; + // Size and start delimiter + os << nl << sz << nl << token::BEGIN_LIST << nl; - // Write contents - forAll(L, i) + // Contents + for (label i=0; i < sz; ++i) { os << L[i] << nl; } - // Write end delimiter + // End delimiter os << token::END_LIST << nl; } } else { // Contents are binary and contiguous - os << nl << L.size() << nl; + os << nl << sz << nl; - if (L.size()) + if (sz) { - // This is annoying, and wasteful, but currently no alternative - List<T> lst = L(); - - // write(...) includes surrounding start/end delimiters - os.write - ( - reinterpret_cast<const char*>(lst.cdata()), - lst.byteSize() - ); + // The TOTAL number of bytes to be written. + // - possibly add start delimiter + os.beginRaw(sz*sizeof(T)); + + // Contents + for (label i=0; i < sz; ++i) + { + os.writeRaw + ( + reinterpret_cast<const char*>(&(L[i])), + sizeof(T) + ); + } + + // End delimiter and/or cleanup. + os.endRaw(); } } diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C index efb2ad3ffce..08d18569172 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListIO.C +++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C @@ -76,14 +76,16 @@ Foam::Ostream& Foam::UList<T>::writeList { const UList<T>& L = *this; + const label sz = L.size(); + // Write list contents depending on data format if (os.format() == IOstream::ASCII || !contiguous<T>()) { // Can the contents be considered 'uniform' (ie, identical)? - bool uniform = (L.size() > 1 && contiguous<T>()); + bool uniform = (sz > 1 && contiguous<T>()); if (uniform) { - forAll(L, i) + for (label i=1; i < sz; ++i) { if (L[i] != L[0]) { @@ -95,58 +97,62 @@ Foam::Ostream& Foam::UList<T>::writeList if (uniform) { - // Write size and start delimiter - os << L.size() << token::BEGIN_BLOCK; + // Size and start delimiter + os << sz << token::BEGIN_BLOCK; - // Write contents + // Contents os << L[0]; - // Write end delimiter + // End delimiter os << token::END_BLOCK; } else if ( - L.size() <= 1 || !shortListLen - || (L.size() <= shortListLen && contiguous<T>()) + sz <= 1 || !shortListLen + || (sz <= shortListLen && contiguous<T>()) ) { - // Write size and start delimiter - os << L.size() << token::BEGIN_LIST; + // Size and start delimiter + os << sz << token::BEGIN_LIST; - // Write contents - forAll(L, i) + // Contents + for (label i=0; i < sz; ++i) { if (i) os << token::SPACE; os << L[i]; } - // Write end delimiter + // End delimiter os << token::END_LIST; } else { - // Write size and start delimiter - os << nl << L.size() << nl << token::BEGIN_LIST << nl; + // Size and start delimiter + os << nl << sz << nl << token::BEGIN_LIST << nl; - // Write contents - forAll(L, i) + // Contents + for (label i=0; i < sz; ++i) { os << L[i] << nl; } - // Write end delimiter + // End delimiter os << token::END_LIST << nl; } } else { // Contents are binary and contiguous - os << nl << L.size() << nl; + os << nl << sz << nl; - if (L.size()) + if (sz) { // write(...) includes surrounding start/end delimiters - os.write(reinterpret_cast<const char*>(L.cdata()), L.byteSize()); + os.write + ( + reinterpret_cast<const char*>(L.cdata()), + L.byteSize() + ); } } @@ -184,29 +190,29 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L) ) ); // Check list length - const label s = elems.size(); + const label sz = elems.size(); - if (s != L.size()) + if (sz != L.size()) { FatalIOErrorInFunction(is) - << "incorrect length for UList. Read " << s + << "incorrect length for UList. Read " << sz << " expected " << L.size() << exit(FatalIOError); } - for (label i=0; i<s; ++i) + for (label i=0; i<sz; ++i) { L[i] = elems[i]; } } else if (firstToken.isLabel()) { - const label s = firstToken.labelToken(); + const label sz = firstToken.labelToken(); // Set list length to that read - if (s != L.size()) + if (sz != L.size()) { FatalIOErrorInFunction(is) - << "incorrect length for UList. Read " << s + << "incorrect length for UList. Read " << sz << " expected " << L.size() << exit(FatalIOError); } @@ -218,11 +224,11 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L) // Read beginning of contents const char delimiter = is.readBeginList("List"); - if (s) + if (sz) { if (delimiter == token::BEGIN_LIST) { - for (label i=0; i<s; ++i) + for (label i=0; i<sz; ++i) { is >> L[i]; @@ -245,7 +251,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L) "reading the single entry" ); - for (label i=0; i<s; ++i) + for (label i=0; i<sz; ++i) { L[i] = element; } @@ -259,9 +265,9 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L) { // contents are binary and contiguous - if (s) + if (sz) { - is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T)); + is.read(reinterpret_cast<char*>(L.data()), sz*sizeof(T)); is.fatalCheck ( diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C index 2852654dda0..33ff3d9878e 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C @@ -31,18 +31,20 @@ License template<class T> Foam::Ostream& Foam::operator<<(Ostream& os, const UPtrList<T>& L) { - // Write size and start delimiter - os << nl << indent << L.size() << nl - << indent << token::BEGIN_LIST << incrIndent; + const label sz = L.size(); - // Write contents - forAll(L, i) + // Size and start delimiter + os << nl << indent << sz << nl + << indent << token::BEGIN_LIST << incrIndent << nl; + + // Contents + for (label i=0; i < sz; ++i) { - os << nl << L[i]; + os << L[i] << nl; } - // Write end delimiter - os << nl << decrIndent << indent << token::END_LIST << nl; + // End delimiter + os << decrIndent << indent << token::END_LIST << nl; os.check(FUNCTION_NAME); return os; diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index 3604a22d0be..916bae22787 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -97,47 +97,62 @@ public: // Write functions //- Write next token to stream - virtual Ostream& write(const token&) = 0; + virtual Ostream& write(const token& t) = 0; //- Write character - virtual Ostream& write(const char) = 0; + virtual Ostream& write(const char c) = 0; //- Write character string - virtual Ostream& write(const char*) = 0; + virtual Ostream& write(const char* str) = 0; //- Write word - virtual Ostream& write(const word&) = 0; + virtual Ostream& write(const word& str) = 0; //- Write keyType // A plain word is written unquoted. // A regular expression is written as a quoted string. - virtual Ostream& write(const keyType&); + virtual Ostream& write(const keyType& kw); //- Write string - virtual Ostream& write(const string&) = 0; + virtual Ostream& write(const string& str) = 0; //- Write std::string surrounded by quotes. // Optional write without quotes. virtual Ostream& writeQuoted ( - const std::string&, + const std::string& str, const bool quoted=true ) = 0; //- Write int32_t - virtual Ostream& write(const int32_t) = 0; + virtual Ostream& write(const int32_t val) = 0; //- Write int64_t - virtual Ostream& write(const int64_t) = 0; + virtual Ostream& write(const int64_t val) = 0; //- Write floatScalar - virtual Ostream& write(const floatScalar) = 0; + virtual Ostream& write(const floatScalar val) = 0; //- Write doubleScalar - virtual Ostream& write(const doubleScalar) = 0; + virtual Ostream& write(const doubleScalar val) = 0; - //- Write binary block - virtual Ostream& write(const char*, std::streamsize) = 0; + //- Write binary block. + virtual Ostream& write(const char* data, std::streamsize count) = 0; + + //- Emit begin marker for low-level raw binary output. + // The count should indicate the number of bytes for subsequent + // writeRaw calls. + virtual Ostream& beginRaw(std::streamsize count) = 0; + + //- Low-level raw binary output. + virtual Ostream& writeRaw + ( + const char* data, + std::streamsize count + ) = 0; + + //- Emit end marker for low-level raw binary output. + virtual Ostream& endRaw() = 0; //- Add indentation characters virtual void indent() = 0; @@ -164,11 +179,11 @@ public: void decrIndent(); //- Write the keyword followed by an appropriate indentation - virtual Ostream& writeKeyword(const keyType&); + virtual Ostream& writeKeyword(const keyType& kw); //- Write begin block group with the given name // Increments indentation, adds newline. - virtual Ostream& beginBlock(const keyType&); + virtual Ostream& beginBlock(const keyType& keyword); //- Write begin block group without a name // Increments indentation, adds newline. diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index 6667389b742..eb54b5ea61a 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,15 +26,42 @@ License #include "UOPstream.H" #include "int.H" #include "token.H" - #include <cctype> // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +inline void Foam::UOPstream::prepareBuffer +( + const size_t count, + const size_t align +) +{ + if (!count) + { + return; + } + + // The current output position + label pos = sendBuf_.size(); + + if (align > 1) + { + // Align output position. Pads sendBuf_.size() - oldPos characters. + pos = align + ((pos - 1) & ~(align - 1)); + } + + // Extend buffer (as required) + sendBuf_.reserve(max(1000, label(pos + count))); + + // Move to the aligned output position + sendBuf_.setSize(pos); +} + + template<class T> -inline void Foam::UOPstream::writeToBuffer(const T& t) +inline void Foam::UOPstream::writeToBuffer(const T& val) { - writeToBuffer(&t, sizeof(T), sizeof(T)); + writeToBuffer(&val, sizeof(T), sizeof(T)); } @@ -55,25 +82,26 @@ inline void Foam::UOPstream::writeToBuffer const size_t align ) { - if (!sendBuf_.capacity()) + if (!count) { - sendBuf_.setCapacity(1000); + return; } - label alignedPos = sendBuf_.size(); + prepareBuffer(count, align); - if (align > 1) - { - // Align bufPosition. Pads sendBuf_.size() - oldPos characters. - alignedPos = align + ((sendBuf_.size() - 1) & ~(align - 1)); - } + // The aligned output position + const label pos = sendBuf_.size(); + + // Extend the addressable range for direct pointer access + sendBuf_.setSize(pos + count); - // Extend if necessary - sendBuf_.setSize(alignedPos + count); + char* const __restrict__ buf = (sendBuf_.begin() + pos); + const char* const __restrict__ input = reinterpret_cast<const char*>(data); - const char* dataPtr = reinterpret_cast<const char*>(data); - size_t i = count; - while (i--) sendBuf_[alignedPos++] = *dataPtr++; + for (size_t i = 0; i < count; ++i) + { + buf[i] = input[i]; + } } @@ -135,7 +163,7 @@ Foam::UOPstream::~UOPstream() { if ( - !UOPstream::write + !UOPstream::write ( commsType_, toProcNo_, @@ -298,6 +326,41 @@ Foam::Ostream& Foam::UOPstream::write } +Foam::Ostream& Foam::UOPstream::beginRaw +( + const std::streamsize count +) +{ + if (format() != BINARY) + { + FatalErrorInFunction + << "stream format not binary" + << Foam::abort(FatalError); + } + + // Alignment = 8, as per write(const char*, streamsize) + prepareBuffer(count, 8); + + return *this; +} + + +Foam::Ostream& Foam::UOPstream::writeRaw +( + const char* data, + const std::streamsize count +) +{ + // No check for format() == BINARY since this is either done in the + // beginRaw() method, or the caller knows what they are doing. + + // Previously aligned and sizes reserved via beginRaw() + writeToBuffer(data, count, 1); + + return *this; +} + + void Foam::UOPstream::print(Ostream& os) const { os << "Writing from processor " << toProcNo_ diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H index 6ee40e03781..364b10ccdda 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,9 +72,12 @@ class UOPstream // Private Member Functions - //- Write a T to the transfer buffer + //- Prepare buffer for count bytes of output at specified alignment. + inline void prepareBuffer(const size_t count, const size_t align); + + //- Write data to the transfer buffer template<class T> - inline void writeToBuffer(const T& t); + inline void writeToBuffer(const T& val); //- Write a char to the transfer buffer inline void writeToBuffer(const char& c); @@ -182,6 +185,24 @@ public: //- Write binary block with 8-byte alignment. Ostream& write(const char* data, const std::streamsize count); + //- Begin marker for low-level raw binary output. + // The count should indicate the number of bytes for subsequent + // writeRaw calls. + Ostream& beginRaw(const std::streamsize count); + + //- Low-level raw binary output. + Ostream& writeRaw + ( + const char* data, + const std::streamsize count + ); + + //- End marker for low-level raw binary output. + Ostream& endRaw() + { + return *this; + } + //- Add indentation characters void indent() {} diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C index 5dc8a3e6bd9..5c6f14103e7 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C @@ -210,7 +210,24 @@ Foam::Ostream& Foam::OSstream::write(const doubleScalar val) } -Foam::Ostream& Foam::OSstream::write(const char* buf, std::streamsize count) +Foam::Ostream& Foam::OSstream::write +( + const char* data, + const std::streamsize count +) +{ + beginRaw(count); + writeRaw(data, count); + endRaw(); + + return *this; +} + + +Foam::Ostream& Foam::OSstream::beginRaw +( + const std::streamsize count +) { if (format() != BINARY) { @@ -220,8 +237,6 @@ Foam::Ostream& Foam::OSstream::write(const char* buf, std::streamsize count) } os_ << token::BEGIN_LIST; - os_.write(buf, count); - os_ << token::END_LIST; setState(os_.rdstate()); @@ -229,9 +244,34 @@ Foam::Ostream& Foam::OSstream::write(const char* buf, std::streamsize count) } +Foam::Ostream& Foam::OSstream::writeRaw +( + const char* data, + std::streamsize count +) +{ + // No check for format() == BINARY since this is either done in the + // beginRaw() method, or the caller knows what they are doing. + + os_.write(data, count); + setState(os_.rdstate()); + + return *this; +} + + +Foam::Ostream& Foam::OSstream::endRaw() +{ + os_ << token::END_LIST; + setState(os_.rdstate()); + + return *this; +} + + void Foam::OSstream::indent() { - for (unsigned short i = 0; i < indentLevel_*indentSize_; i++) + for (unsigned short i = 0; i < indentLevel_*indentSize_; ++i) { os_ << ' '; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H index 4c6e97fd593..158f7123ece 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H @@ -143,7 +143,26 @@ public: virtual Ostream& write(const doubleScalar val); //- Write binary block - virtual Ostream& write(const char* buf, std::streamsize count); + virtual Ostream& write + ( + const char* data, + const std::streamsize count + ); + + //- Begin marker for low-level raw binary output. + // The count should indicate the number of bytes for subsequent + // writeRaw calls. + virtual Ostream& beginRaw(const std::streamsize count); + + //- Low-level raw binary output. + virtual Ostream& writeRaw + ( + const char* data, + const std::streamsize count + ); + + //- End marker for low-level raw binary output. + virtual Ostream& endRaw(); //- Add indentation characters virtual void indent(); -- GitLab From f603e3e1de11b9f2d9e81855a5afc353b3955e8d Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 20 Oct 2017 14:10:12 +0200 Subject: [PATCH 044/126] STYLE: pass through -test argument --- tutorials/Allrun | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tutorials/Allrun b/tutorials/Allrun index bf468c143e6..0a731b3fc90 100755 --- a/tutorials/Allrun +++ b/tutorials/Allrun @@ -63,6 +63,9 @@ do -collect) optCollectOnly=true ;; + -test) # Known options that should be passed through + break + ;; -*) usage "unknown option: $1" ;; -- GitLab From af5f857618292ca3023f04f4a7e5f78aeb21abec Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 23 Oct 2017 07:50:12 +0200 Subject: [PATCH 045/126] ENH: add reset() method to IStringStream - for convenience and symmetry with OStringStream STYLE: void return value for stream rewind() methods - this makes it easier to design bidirectional streams --- .../test/IStringStream/Test-IStringStream.C | 16 +++++++++------- src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C | 4 +--- src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H | 2 +- src/OpenFOAM/db/IOstreams/IOstreams/Istream.H | 4 ++-- src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C | 3 +-- src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H | 4 ++-- src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C | 4 +--- src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H | 6 +++--- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H | 2 +- .../db/IOstreams/StringStreams/StringStream.H | 7 +++++++ src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C | 4 +--- src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H | 4 ++-- .../{dummyISstream => dummy}/dummyISstream.H | 5 ++--- .../{dummyIstream => dummy}/dummyIstream.H | 4 ++-- 14 files changed, 35 insertions(+), 34 deletions(-) rename src/OpenFOAM/db/IOstreams/{dummyISstream => dummy}/dummyISstream.H (96%) rename src/OpenFOAM/db/IOstreams/{dummyIstream => dummy}/dummyIstream.H (97%) diff --git a/applications/test/IStringStream/Test-IStringStream.C b/applications/test/IStringStream/Test-IStringStream.C index cd8ba0e2a61..b265b15a61f 100644 --- a/applications/test/IStringStream/Test-IStringStream.C +++ b/applications/test/IStringStream/Test-IStringStream.C @@ -36,20 +36,22 @@ using namespace Foam; int main(int argc, char *argv[]) { - IStringStream testStream(Foam::string("1002 sfsd sdfsd")); + IStringStream testStream(Foam::string(" 1002 abcd defg;")); label i(readLabel(testStream)); - Info<< i << endl; + Info<< "label=" << i << nl; - word bla(testStream); - word bla2(testStream); + word w1(testStream); + word w2(testStream); - Info<< bla << tab << bla2 << endl; + Info<< "word=" << w1 << nl; + Info<< "word=" << w2 << nl; - wordList wl(IStringStream("(hello1")()); + testStream.reset("(hello1)"); - Info<< wl << endl; + wordList wl(testStream); + Info<< wl << nl; Info<< "\nEnd\n" << endl; diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C index fd3889618ea..f1c97306ed5 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C +++ b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C @@ -167,7 +167,7 @@ const std::istream& Foam::IFstream::stdStream() const } -Foam::Istream& Foam::IFstream::rewind() +void Foam::IFstream::rewind() { lineNumber_ = 1; // Reset line number @@ -195,8 +195,6 @@ Foam::Istream& Foam::IFstream::rewind() { ISstream::rewind(); } - - return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H index 72f89873c58..34f7c7c9483 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H +++ b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H @@ -130,7 +130,7 @@ public: virtual const std::istream& stdStream() const; //- Rewind the stream so that it may be read again - virtual Istream& rewind(); + virtual void rewind(); // Print diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H index 77131761969..24df823bdda 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H @@ -131,8 +131,8 @@ public: //- Read binary block virtual Istream& read(char*, std::streamsize) = 0; - //- Rewind and return the stream so that it may be read again - virtual Istream& rewind() = 0; + //- Rewind the stream so that it may be read again + virtual void rewind() = 0; // Read List punctuation tokens diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index 333aeca259c..21b412fce39 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -329,10 +329,9 @@ Foam::Istream& Foam::UIPstream::read(char* data, std::streamsize count) } -Foam::Istream& Foam::UIPstream::rewind() +void Foam::UIPstream::rewind() { externalBufPosition_ = 0; - return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H index 4913693741f..d0c0f865529 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H @@ -171,8 +171,8 @@ public: //- Read binary block with 8-byte alignment. Istream& read(char* data, const std::streamsize count); - //- Rewind and return the stream so that it may be read again - Istream& rewind(); + //- Rewind the stream so that it may be read again + void rewind(); // Edit diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C index 40c2d8e5950..15ad568f18f 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C @@ -798,7 +798,7 @@ Foam::Istream& Foam::ISstream::read(char* buf, std::streamsize count) } -Foam::Istream& Foam::ISstream::rewind() +void Foam::ISstream::rewind() { lineNumber_ = 1; // Reset line number @@ -807,8 +807,6 @@ Foam::Istream& Foam::ISstream::rewind() // pubseekpos() rather than seekg() so that it works with gzstream stdStream().rdbuf()->pubseekpos(0, std::ios_base::in); - - return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H index 18890e20873..4a2b510b5b1 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H @@ -82,7 +82,7 @@ public: // Constructors - //- Construct as wrapper around istream + //- Construct as wrapper around std::istream inline ISstream ( std::istream& is, @@ -163,8 +163,8 @@ public: //- Read binary block virtual Istream& read(char* buf, std::streamsize count); - //- Rewind and return the stream so that it may be read again - virtual Istream& rewind(); + //- Rewind the stream so that it may be read again + virtual void rewind(); // Stream state functions diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H index 158f7123ece..2dd13c50fb2 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H @@ -69,7 +69,7 @@ public: // Constructors - //- Construct and set stream status + //- Construct as wrapper around std::ostream and set stream status OSstream ( std::ostream& os, diff --git a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H index 1bdbad9adb7..91b1a7ce34a 100644 --- a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H +++ b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H @@ -171,6 +171,13 @@ public: //- Print description to Ostream void print(Ostream& os) const; + //- Reset the input buffer and rewind the stream + void reset(const std::string& s) + { + this->str(s); + this->rewind(); + } + // Member operators diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C index c9dae122947..c0890dad9d5 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C @@ -154,7 +154,7 @@ Foam::Istream& Foam::ITstream::read(char*, std::streamsize) } -Foam::Istream& Foam::ITstream::rewind() +void Foam::ITstream::rewind() { tokenIndex_ = 0; @@ -164,8 +164,6 @@ Foam::Istream& Foam::ITstream::rewind() } setGood(); - - return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H index 26617cb37e6..b8414cc4f23 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H @@ -188,8 +188,8 @@ public: //- Read binary block virtual Istream& read(char*, std::streamsize); - //- Rewind and return the stream so that it may be read again - virtual Istream& rewind(); + //- Rewind the stream so that it may be read again + virtual void rewind(); // Edit diff --git a/src/OpenFOAM/db/IOstreams/dummyISstream/dummyISstream.H b/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H similarity index 96% rename from src/OpenFOAM/db/IOstreams/dummyISstream/dummyISstream.H rename to src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H index 9477b087914..fa0b441dc2d 100644 --- a/src/OpenFOAM/db/IOstreams/dummyISstream/dummyISstream.H +++ b/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H @@ -126,11 +126,10 @@ public: return *this; } - //- Rewind and return the stream so that it may be read again - virtual Istream& rewind() + //- Rewind the stream so that it may be read again + virtual void rewind() { NotImplemented; - return *this; } //- Return flags of stream diff --git a/src/OpenFOAM/db/IOstreams/dummyIstream/dummyIstream.H b/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H similarity index 97% rename from src/OpenFOAM/db/IOstreams/dummyIstream/dummyIstream.H rename to src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H index 9e8549820db..b15f892ec21 100644 --- a/src/OpenFOAM/db/IOstreams/dummyIstream/dummyIstream.H +++ b/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H @@ -127,8 +127,8 @@ public: return *this; } - //- Rewind and return the stream so that it may be read again - virtual Istream& rewind() + //- Rewind the stream so that it may be read again + virtual void rewind() { NotImplemented; return *this; -- GitLab From 360ccea24e8022049673e663c50753655c4d5a6d Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 23 Oct 2017 09:05:22 +0200 Subject: [PATCH 046/126] COMP: incorrect specialization for Swap(HashSet..) --- src/OpenFOAM/containers/HashTables/HashSet/HashSet.C | 6 +++++- src/OpenFOAM/containers/HashTables/HashSet/HashSet.H | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C index 809adb795b3..020d3e36d9f 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C @@ -278,7 +278,11 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const HashSet<Key, Hash>& tbl) // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // template<class Key, class Hash> -void Foam::Swap(const HashSet<Key, Hash>& a, const HashSet<Key, Hash>& b) +inline void Foam::Swap +( + HashSet<Key, Hash>& a, + HashSet<Key, Hash>& b +) { a.swap(b); } diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H index 12aea8bea33..ace2ca6d7aa 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H @@ -362,8 +362,8 @@ public: // Global Functions -// Exchange contents of hash tables - see HashTable::swap(). -template<class T, class Key, class Hash> +// Exchange contents of HashSets - see HashSet::swap(). +template<class Key, class Hash> inline void Swap ( HashSet<Key, Hash>& a, -- GitLab From 953bd5bdca7907ac452a5999b82ba1abe4e86ff1 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 23 Oct 2017 09:09:59 +0200 Subject: [PATCH 047/126] COMP: clang warnings --- src/OpenFOAM/global/argList/argList.C | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index d832a6d7f25..648138a1477 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -122,8 +122,7 @@ static void printHostsSubscription(const UList<string>& slaveProcs) for (const auto& str : slaveProcs) { - const auto dot = str.rfind('.'); - const std::string curr(std::move(str.substr(0, dot))); + std::string curr(str.substr(0, str.rfind('.'))); if (prev != curr) { -- GitLab From e1167d9592851beb0e4d036e3d587c6bc267aaf6 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 23 Oct 2017 09:38:43 +0200 Subject: [PATCH 048/126] ENH: provide openmp compile and link flags. - the USE_OMP preprocessor symbol is also defined with the openmp compile flag to allow conditional compilation of openmp-specific code. --- applications/test/openmp/Make/files | 3 + applications/test/openmp/Make/options | 4 ++ applications/test/openmp/Test-openmp.C | 69 +++++++++++++++++++ etc/config.sh/kahip | 7 -- src/parallel/decompose/Allwmake | 1 - .../decompose/kahipDecomp/Make/options | 10 +-- wmake/rules/linux64Clang/general | 1 + wmake/rules/linux64Clang/openmp | 4 ++ wmake/rules/linux64Gcc/general | 1 + wmake/rules/linux64Gcc/openmp | 4 ++ wmake/rules/linux64GccKNL/general | 1 + wmake/rules/linux64GccKNL/openmp | 4 ++ wmake/rules/linux64Icc/general | 1 + wmake/rules/linux64Icc/openmp | 4 ++ wmake/rules/linux64IccKNL/openmp | 4 ++ wmake/rules/linuxARM7Gcc/general | 1 + wmake/rules/linuxARM7Gcc/openmp | 4 ++ wmake/rules/linuxClang/general | 1 + wmake/rules/linuxClang/openmp | 4 ++ wmake/rules/linuxGcc/general | 1 + wmake/rules/linuxGcc/openmp | 4 ++ wmake/rules/linuxIA64Gcc/general | 1 + wmake/rules/linuxIA64Gcc/openmp | 4 ++ wmake/rules/linuxIA64Icc/general | 1 + wmake/rules/linuxIA64Icc/openmp | 4 ++ wmake/rules/linuxIcc/general | 1 + wmake/rules/linuxPPC64Gcc/general | 1 + wmake/rules/linuxPPC64Gcc/openmp | 4 ++ wmake/rules/linuxPPC64leGcc/general | 1 + wmake/rules/linuxPPC64leGcc/openmp | 4 ++ 30 files changed, 142 insertions(+), 12 deletions(-) create mode 100644 applications/test/openmp/Make/files create mode 100644 applications/test/openmp/Make/options create mode 100644 applications/test/openmp/Test-openmp.C create mode 100644 wmake/rules/linux64Clang/openmp create mode 100644 wmake/rules/linux64Gcc/openmp create mode 100644 wmake/rules/linux64GccKNL/openmp create mode 100644 wmake/rules/linux64Icc/openmp create mode 100644 wmake/rules/linux64IccKNL/openmp create mode 100644 wmake/rules/linuxARM7Gcc/openmp create mode 100644 wmake/rules/linuxClang/openmp create mode 100644 wmake/rules/linuxGcc/openmp create mode 100644 wmake/rules/linuxIA64Gcc/openmp create mode 100644 wmake/rules/linuxIA64Icc/openmp create mode 100644 wmake/rules/linuxPPC64Gcc/openmp create mode 100644 wmake/rules/linuxPPC64leGcc/openmp diff --git a/applications/test/openmp/Make/files b/applications/test/openmp/Make/files new file mode 100644 index 00000000000..c2749a9419f --- /dev/null +++ b/applications/test/openmp/Make/files @@ -0,0 +1,3 @@ +Test-openmp.C + +EXE = $(FOAM_USER_APPBIN)/Test-openmp diff --git a/applications/test/openmp/Make/options b/applications/test/openmp/Make/options new file mode 100644 index 00000000000..54eed51fb98 --- /dev/null +++ b/applications/test/openmp/Make/options @@ -0,0 +1,4 @@ +EXE_INC = ${COMP_OPENMP} + +/* Mostly do not need to explicitly link openmp libraries */ +/* EXE_LIBS = ${LINK_OPENMP} */ diff --git a/applications/test/openmp/Test-openmp.C b/applications/test/openmp/Test-openmp.C new file mode 100644 index 00000000000..acb68e9ed86 --- /dev/null +++ b/applications/test/openmp/Test-openmp.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + Simple test program for compiling/running openmp + +\*---------------------------------------------------------------------------*/ + +#include <cstdio> +#include <cstdlib> +#include <iostream> + +#ifdef USE_OMP +#include <omp.h> +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + int nThreads, threadId; + +// Fork threads with their own copies of variables +#ifdef USE_OMP +#pragma omp parallel private(nThreads, threadId) + { + threadId = omp_get_thread_num(); + nThreads = omp_get_num_threads(); + + // Printf rather than cout to ensure that it emits in one go + printf("Called from thread = %d\n", threadId); + + // Master thread + if (threadId == 0) + { + // Printf rather than cout to ensure that it emits in one go + printf("Number of threads = %d\n", nThreads); + } + } +#else + std::cout << "Compiled without openmp!\n"; +#endif + + return 0; +} + + +// ************************************************************************* // diff --git a/etc/config.sh/kahip b/etc/config.sh/kahip index 21d7a8a84a5..42557831c34 100644 --- a/etc/config.sh/kahip +++ b/etc/config.sh/kahip @@ -42,18 +42,11 @@ # An Int64 OpenFOAM version can use it, but the mesh size is limited # accordingly. # -# If KaHIP was compiled with openmp, you may need additional -# compile or link flags in KAHIP_COMP_FLAGS KAHIP_LINK_FLAGS -# #------------------------------------------------------------------------------ # USER EDITABLE PART: Changes made here may be lost with the next upgrade KAHIP_VERSION=kahip-2.00 export KAHIP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$KAHIP_VERSION -# Adjust as required -# export KAHIP_COMP_FLAGS="-fopenmp" -export KAHIP_LINK_FLAGS="-lgomp" - # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 39c8f109a50..f3711333487 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -33,7 +33,6 @@ hasKahip() local header label settings unset KAHIP_ARCH_PATH KAHIP_VERSION - unset KAHIP_COMP_FLAGS KAHIP_LINK_FLAGS settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip) || { echo "$warning (no config.sh/kahip settings)" return 1 diff --git a/src/parallel/decompose/kahipDecomp/Make/options b/src/parallel/decompose/kahipDecomp/Make/options index 9c746b309c7..fcd1c5d268a 100644 --- a/src/parallel/decompose/kahipDecomp/Make/options +++ b/src/parallel/decompose/kahipDecomp/Make/options @@ -1,13 +1,15 @@ EXE_INC = \ -I$(KAHIP_ARCH_PATH)/include \ - -I../decompositionMethods/lnInclude \ - $(KAHIP_COMP_FLAGS) + -I../decompositionMethods/lnInclude /* * The $(KAHIP_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided - * to support central, non-thirdparty installations + * to support central, non-thirdparty installations. + * + * KaHIP is often compiled with openmp, but may be missing the + * link dependency for openmp. */ LIB_LIBS = \ -L$(KAHIP_ARCH_PATH)/lib \ -L$(KAHIP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ - -L$(FOAM_EXT_LIBBIN) $(KAHIP_LINK_FLAGS) -lkahip + -L$(FOAM_EXT_LIBBIN) $(LINK_OPENMP) -lkahip diff --git a/wmake/rules/linux64Clang/general b/wmake/rules/linux64Clang/general index 1002cb169b5..d83a18b000b 100644 --- a/wmake/rules/linux64Clang/general +++ b/wmake/rules/linux64Clang/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Clang/openmp b/wmake/rules/linux64Clang/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linux64Clang/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Gcc/general b/wmake/rules/linux64Gcc/general index 1002cb169b5..d83a18b000b 100644 --- a/wmake/rules/linux64Gcc/general +++ b/wmake/rules/linux64Gcc/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Gcc/openmp b/wmake/rules/linux64Gcc/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linux64Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64GccKNL/general b/wmake/rules/linux64GccKNL/general index 1002cb169b5..d83a18b000b 100644 --- a/wmake/rules/linux64GccKNL/general +++ b/wmake/rules/linux64GccKNL/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64GccKNL/openmp b/wmake/rules/linux64GccKNL/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linux64GccKNL/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Icc/general b/wmake/rules/linux64Icc/general index 52b0e177d7a..eb3898f709e 100644 --- a/wmake/rules/linux64Icc/general +++ b/wmake/rules/linux64Icc/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Icc/openmp b/wmake/rules/linux64Icc/openmp new file mode 100644 index 00000000000..154c9e5743d --- /dev/null +++ b/wmake/rules/linux64Icc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -qopenmp +LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linux64IccKNL/openmp b/wmake/rules/linux64IccKNL/openmp new file mode 100644 index 00000000000..154c9e5743d --- /dev/null +++ b/wmake/rules/linux64IccKNL/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -qopenmp +LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxARM7Gcc/general b/wmake/rules/linuxARM7Gcc/general index 1e51dcc403c..4fc50267edb 100644 --- a/wmake/rules/linuxARM7Gcc/general +++ b/wmake/rules/linuxARM7Gcc/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxARM7Gcc/openmp b/wmake/rules/linuxARM7Gcc/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linuxARM7Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxClang/general b/wmake/rules/linuxClang/general index e3427c3181a..eae23e305bd 100644 --- a/wmake/rules/linuxClang/general +++ b/wmake/rules/linuxClang/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxClang/openmp b/wmake/rules/linuxClang/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linuxClang/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxGcc/general b/wmake/rules/linuxGcc/general index e3427c3181a..eae23e305bd 100644 --- a/wmake/rules/linuxGcc/general +++ b/wmake/rules/linuxGcc/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxGcc/openmp b/wmake/rules/linuxGcc/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linuxGcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Gcc/general b/wmake/rules/linuxIA64Gcc/general index 182ee7f9019..d8fb470836e 100644 --- a/wmake/rules/linuxIA64Gcc/general +++ b/wmake/rules/linuxIA64Gcc/general @@ -4,6 +4,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxIA64Gcc/openmp b/wmake/rules/linuxIA64Gcc/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linuxIA64Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Icc/general b/wmake/rules/linuxIA64Icc/general index 09a38966561..c3269860fb8 100644 --- a/wmake/rules/linuxIA64Icc/general +++ b/wmake/rules/linuxIA64Icc/general @@ -4,6 +4,7 @@ GLIBS = include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxIA64Icc/openmp b/wmake/rules/linuxIA64Icc/openmp new file mode 100644 index 00000000000..154c9e5743d --- /dev/null +++ b/wmake/rules/linuxIA64Icc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -qopenmp +LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxIcc/general b/wmake/rules/linuxIcc/general index 5c94cad44af..85f5be51c09 100644 --- a/wmake/rules/linuxIcc/general +++ b/wmake/rules/linuxIcc/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxPPC64Gcc/general b/wmake/rules/linuxPPC64Gcc/general index a590cc29c8d..712516c2681 100644 --- a/wmake/rules/linuxPPC64Gcc/general +++ b/wmake/rules/linuxPPC64Gcc/general @@ -5,6 +5,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxPPC64Gcc/openmp b/wmake/rules/linuxPPC64Gcc/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linuxPPC64Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxPPC64leGcc/general b/wmake/rules/linuxPPC64leGcc/general index 7867cbde8f4..575cadaeee0 100644 --- a/wmake/rules/linuxPPC64leGcc/general +++ b/wmake/rules/linuxPPC64leGcc/general @@ -5,6 +5,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxPPC64leGcc/openmp b/wmake/rules/linuxPPC64leGcc/openmp new file mode 100644 index 00000000000..bcb805f57c6 --- /dev/null +++ b/wmake/rules/linuxPPC64leGcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp -- GitLab From 0adf8d0a7e4b9e1569b31ed4446d19a478b5eba2 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 23 Oct 2017 09:56:34 +0200 Subject: [PATCH 049/126] STYLE: use word methods to obtain IOobject member/group --- src/OpenFOAM/db/IOobject/IOobject.C | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C index 563eb9c5426..d97bc75153d 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.C +++ b/src/OpenFOAM/db/IOobject/IOobject.C @@ -374,31 +374,13 @@ const Foam::fileName& Foam::IOobject::caseName() const Foam::word Foam::IOobject::group() const { - const auto i = name_.rfind('.'); - - if (i == std::string::npos || i == 0) - { - return word::null; - } - else - { - return name_.substr(i+1); - } + return name_.ext(); } Foam::word Foam::IOobject::member() const { - const auto i = name_.rfind('.'); - - if (i == std::string::npos || i == 0) - { - return name_; - } - else - { - return name_.substr(0, i); - } + return name_.lessExt(); } -- GitLab From 2269294d36780f4c024a609ac772a2e834e5851e Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 23 Oct 2017 10:15:50 +0200 Subject: [PATCH 050/126] ENH: use FixedList for dimensionSet storage - makes it easier to transmit or stream as a list of scalars --- src/OpenFOAM/dimensionSet/dimensionSet.C | 60 +++++++++--------- src/OpenFOAM/dimensionSet/dimensionSet.H | 71 +++++++++++----------- src/OpenFOAM/dimensionSet/dimensionSetIO.C | 12 ++-- 3 files changed, 69 insertions(+), 74 deletions(-) diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.C b/src/OpenFOAM/dimensionSet/dimensionSet.C index 269d25282fa..b9c9be7b39d 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSet.C +++ b/src/OpenFOAM/dimensionSet/dimensionSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,23 +59,10 @@ Foam::dimensionSet::dimensionSet } -Foam::dimensionSet::dimensionSet -( - const scalar mass, - const scalar length, - const scalar time, - const scalar temperature, - const scalar moles -) -{ - exponents_[MASS] = mass; - exponents_[LENGTH] = length; - exponents_[TIME] = time; - exponents_[TEMPERATURE] = temperature; - exponents_[MOLES] = moles; - exponents_[CURRENT] = 0; - exponents_[LUMINOUS_INTENSITY] = 0; -} +Foam::dimensionSet::dimensionSet(const FixedList<scalar,7>& dims) +: + exponents_(dims) +{} Foam::dimensionSet::dimensionSet(const dimensionSet& ds) @@ -88,13 +75,13 @@ Foam::dimensionSet::dimensionSet(const dimensionSet& ds) bool Foam::dimensionSet::dimensionless() const { - for (int Dimension=0; Dimension<nDimensions; ++Dimension) + for (int d=0; d<nDimensions; ++d) { - // ie, mag(exponents_[Dimension]) > smallExponent + // ie, mag(exponents_[d]) > smallExponent if ( - exponents_[Dimension] > smallExponent - || exponents_[Dimension] < -smallExponent + exponents_[d] > smallExponent + || exponents_[d] < -smallExponent ) { return false; @@ -105,12 +92,21 @@ bool Foam::dimensionSet::dimensionless() const } +const Foam::FixedList<Foam::scalar,7>& Foam::dimensionSet::values() const +{ + return exponents_; +} + + +Foam::FixedList<Foam::scalar,7>& Foam::dimensionSet::values() +{ + return exponents_; +} + + void Foam::dimensionSet::reset(const dimensionSet& ds) { - for (int Dimension=0; Dimension<nDimensions; ++Dimension) - { - exponents_[Dimension] = ds.exponents_[Dimension]; - } + exponents_ = ds.exponents_; } @@ -142,11 +138,11 @@ Foam::scalar& Foam::dimensionSet::operator[](const label type) bool Foam::dimensionSet::operator==(const dimensionSet& ds) const { - for (int Dimension=0; Dimension < nDimensions; ++Dimension) + for (int d=0; d<nDimensions; ++d) { if ( - mag(exponents_[Dimension] - ds.exponents_[Dimension]) + mag(exponents_[d] - ds.exponents_[d]) > smallExponent ) { @@ -536,9 +532,9 @@ Foam::dimensionSet Foam::operator* { dimensionSet dimProduct(ds1); - for (int Dimension=0; Dimension<dimensionSet::nDimensions; Dimension++) + for (int d=0; d<dimensionSet::nDimensions; ++d) { - dimProduct.exponents_[Dimension] += ds2.exponents_[Dimension]; + dimProduct.exponents_[d] += ds2.exponents_[d]; } return dimProduct; @@ -553,9 +549,9 @@ Foam::dimensionSet Foam::operator/ { dimensionSet dimQuotient(ds1); - for (int Dimension=0; Dimension<dimensionSet::nDimensions; Dimension++) + for (int d=0; d<dimensionSet::nDimensions; ++d) { - dimQuotient.exponents_[Dimension] -= ds2.exponents_[Dimension]; + dimQuotient.exponents_[d] -= ds2.exponents_[d]; } return dimQuotient; diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.H b/src/OpenFOAM/dimensionSet/dimensionSet.H index 94a1608c9ab..ca18178fee6 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSet.H +++ b/src/OpenFOAM/dimensionSet/dimensionSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -120,26 +120,29 @@ Ostream& operator<<(Ostream&, const dimensionSet&); class dimensionSet { - public: + //- The array of dimension exponents + typedef FixedList<scalar,7> list_type; + + // Member constants enum { - nDimensions = 7 // Number of dimensions in SI is 7 + nDimensions = 7 //!< 7 base dimensions }; //- Define an enumeration for the names of the dimension exponents enum dimensionType { - MASS, // kilogram kg - LENGTH, // metre m - TIME, // second s - TEMPERATURE, // Kelvin K - MOLES, // mole mol - CURRENT, // Ampere A - LUMINOUS_INTENSITY // Candela Cd + MASS, //!< kilogram kg + LENGTH, //!< metre m + TIME, //!< second s + TEMPERATURE, //!< Kelvin K + MOLES, //!< mole mol + CURRENT, //!< Ampere A + LUMINOUS_INTENSITY //!< Candela Cd }; @@ -150,6 +153,12 @@ public: private: + // Private data + + //- The array of dimension exponents + list_type exponents_; + + // Private classes class tokeniser @@ -167,17 +176,17 @@ private: // Private Member Functions - void push(const token&); + void push(const token& t); token pop(); - void unpop(const token&); + void unpop(const token& t); public: // Constructors - tokeniser(Istream&); + tokeniser(Istream& is); // Member Functions @@ -212,13 +221,6 @@ private: const HashTable<dimensionedScalar>& ) const; - - // private data - - // dimensionSet stored as an array of dimension exponents - scalar exponents_[nDimensions]; - - public: // Declare name of the class and its debug switch @@ -227,8 +229,7 @@ public: // Constructors - //- Construct given individual dimension exponents for all - // seven dimensions + //- Construct from exponents for the first five or all seven dimensions dimensionSet ( const scalar mass, @@ -236,20 +237,12 @@ public: const scalar time, const scalar temperature, const scalar moles, - const scalar current, - const scalar luminousIntensity + const scalar current = 0, + const scalar luminousIntensity = 0 ); - //- Construct given individual dimension exponents for first - // five dimensions - dimensionSet - ( - const scalar mass, - const scalar length, - const scalar time, - const scalar temperature, - const scalar moles - ); + //- Construct from exponents for all seven dimensions + dimensionSet(const FixedList<scalar,7>& dimensions); //- Copy constructor dimensionSet(const dimensionSet& ds); @@ -261,7 +254,7 @@ public: } //- Construct from Istream - dimensionSet(Istream&); + dimensionSet(Istream& is); // Member functions @@ -269,7 +262,13 @@ public: //- Return true if it is dimensionless bool dimensionless() const; - void reset(const dimensionSet&); + //- Return const access to the exponents as a list + const FixedList<scalar,7>& values() const; + + //- Return non-const access to the exponents as a list + FixedList<scalar,7>& values(); + + void reset(const dimensionSet& ds); // I/O diff --git a/src/OpenFOAM/dimensionSet/dimensionSetIO.C b/src/OpenFOAM/dimensionSet/dimensionSetIO.C index 9fcfd9ee20b..076c7104107 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSetIO.C +++ b/src/OpenFOAM/dimensionSet/dimensionSetIO.C @@ -49,7 +49,7 @@ Foam::dimensionSet::tokeniser::tokeniser(Istream& is) void Foam::dimensionSet::tokeniser::push(const token& t) { - label end = (start_+size_)%tokens_.size(); + const label end = (start_+size_)%tokens_.size(); tokens_[end] = t; if (size_ == tokens_.size()) { @@ -444,9 +444,9 @@ Foam::Istream& Foam::dimensionSet::read { // Read first five dimensions exponents_[dimensionSet::MASS] = nextToken.number(); - for (int Dimension=1; Dimension<dimensionSet::CURRENT; Dimension++) + for (int d=1; d<dimensionSet::CURRENT; ++d) { - is >> exponents_[Dimension]; + is >> exponents_[d]; } // Read next token @@ -681,11 +681,11 @@ Foam::Ostream& Foam::dimensionSet::write } else { - for (int d=0; d<dimensionSet::nDimensions-1; d++) + for (int d=0; d<dimensionSet::nDimensions; ++d) { - os << exponents_[d] << token::SPACE; + if (d) os << token::SPACE; + os << exponents_[d]; } - os << exponents_[dimensionSet::nDimensions-1]; } os << token::END_SQR; -- GitLab From 7e8217fd172a18dd0e19048f70ee7825b4a0b8a5 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 23 Oct 2017 12:06:59 +0200 Subject: [PATCH 051/126] ENH: include memory streams - these provide a similar functionality to string-streams, but operate on a externally provided memory buffer which can be used to reduce the amount of copying. - classes were previously staged as part of the ADIOS community repository. --- applications/test/UIBufStream/Make/files | 3 + applications/test/UIBufStream/Make/options | 2 + .../test/UIBufStream/Test-UIBufStream.C | 88 ++++++ .../db/IOstreams/memory/BufStreamAllocator.H | 266 ++++++++++++++++++ .../db/IOstreams/memory/OCountStream.H | 230 +++++++++++++++ .../db/IOstreams/memory/UIBufStream.H | 168 +++++++++++ .../db/IOstreams/memory/UOBufStream.H | 190 +++++++++++++ 7 files changed, 947 insertions(+) create mode 100644 applications/test/UIBufStream/Make/files create mode 100644 applications/test/UIBufStream/Make/options create mode 100644 applications/test/UIBufStream/Test-UIBufStream.C create mode 100644 src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H create mode 100644 src/OpenFOAM/db/IOstreams/memory/OCountStream.H create mode 100644 src/OpenFOAM/db/IOstreams/memory/UIBufStream.H create mode 100644 src/OpenFOAM/db/IOstreams/memory/UOBufStream.H diff --git a/applications/test/UIBufStream/Make/files b/applications/test/UIBufStream/Make/files new file mode 100644 index 00000000000..611f5337be7 --- /dev/null +++ b/applications/test/UIBufStream/Make/files @@ -0,0 +1,3 @@ +Test-UIBufStream.C + +EXE = $(FOAM_USER_APPBIN)/Test-UIBufStream diff --git a/applications/test/UIBufStream/Make/options b/applications/test/UIBufStream/Make/options new file mode 100644 index 00000000000..4e772fdf9d7 --- /dev/null +++ b/applications/test/UIBufStream/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ +/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/UIBufStream/Test-UIBufStream.C b/applications/test/UIBufStream/Test-UIBufStream.C new file mode 100644 index 00000000000..f183d623ab7 --- /dev/null +++ b/applications/test/UIBufStream/Test-UIBufStream.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + +\*---------------------------------------------------------------------------*/ + +#include "UIBufStream.H" +#include "UOBufStream.H" +#include "wordList.H" +#include "IOstreams.H" +#include "argList.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + // Buffer storage + DynamicList<char> storage(1000); + + UOBufStream obuf(storage); + obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n"; + + Info<<"formatted: " << obuf.size() << " chars" << endl; + + // Match size + storage.resize(obuf.size()); + + Info<<"as string: " << string(storage.cdata(), storage.size()) << endl; + + // Attach input buffer - could also do without previous resize + + UIBufStream ibuf(storage, storage.size()); + + token t; + + while (ibuf.good()) + { + ibuf >> t; + if (t.good()) + { + Info<<"token: " << t << endl; + } + } + + Info<< nl << "Repeat..." << endl; + ibuf.rewind(); + + while (ibuf.good()) + { + ibuf >> t; + if (t.good()) + { + Info<<"token: " << t << endl; + } + } + + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H b/src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H new file mode 100644 index 00000000000..0696e1a9430 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H @@ -0,0 +1,266 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::BufStreamAllocator + +Description + Helper for memory buffer streams such as UIBufStream, UOBufStream + +\*---------------------------------------------------------------------------*/ + +#ifndef BufStreamAllocator_H +#define BufStreamAllocator_H + +#include <type_traits> +#include <sstream> + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class memorybuf Declaration +\*---------------------------------------------------------------------------*/ + +//- A streambuf class for using externally allocated memory for its buffer +class memorybuf +: + public std::streambuf +{ +protected: + + // Protected members + + //- Set position pointer to relative position + virtual std::streampos seekoff + ( + std::streamoff off, + std::ios_base::seekdir way, + std::ios_base::openmode which = std::ios_base::in|std::ios_base::out + ) + { + const bool testin = which & std::ios_base::in; + const bool testout = which & std::ios_base::out; + + if (way == std::ios_base::beg) + { + if (testin) + { + setg(eback(), eback(), egptr()); + gbump(off); + } + if (testout) + { + setp(pbase(), epptr()); + pbump(off); + } + + return off; + } + + if (way == std::ios_base::cur) + { + if (testin) + { + gbump(off); + } + if (testout) + { + pbump(off); + } + } + else if (way == std::ios_base::end) + { + if (testin) + { + gbump(off); + } + if (testout) + { + pbump(off); + } + } + + if (testin) + { + return gptr() - eback(); + } + if (testout) + { + return pptr() - pbase(); + } + + return -1; + } + + + //- Set position pointer to absolute position + virtual std::streampos seekpos + ( + std::streampos pos, + std::ios_base::openmode which = std::ios_base::in|std::ios_base::out + ) + { + return seekoff(pos, std::ios_base::beg, which); + } + + + //- Get sequence of characters + virtual std::streamsize xsgetn(char* s, std::streamsize n) + { + std::streamsize count = 0; + + // some optimization could be possible here + while (count < n && gptr() < egptr()) + { + *(s + count++) = *(gptr()); + gbump(1); + } + + return count; + } + + + //- Put sequence of characters + virtual std::streamsize xsputn(const char* s, std::streamsize n) + { + std::streamsize count = 0; + + // some optimization could be possible here + while (count < n && pptr() < epptr()) + { + *(pptr()) = *(s + count++); + pbump(1); + } + + return count; + } + + +public: + + // Constructors + + //- Construct for specified buffer + memorybuf(char* buffer, std::streamsize num) + { + setg(buffer, buffer, buffer + num); + setp(buffer, buffer + num); + } + +}; + + +/*---------------------------------------------------------------------------*\ + Class BufStreamAllocator Declaration +\*---------------------------------------------------------------------------*/ + +//- An stream/stream-buffer allocator for external buffers +template<class StreamType, bool Manage=false> +class BufStreamAllocator +{ + // Private data + + //- Storage + char *storage_; + + //- The number of bytes in the storage + std::streamsize len_; + + //- Reference to the underlying buffer + memorybuf buf_; + +protected: + + // Protected data + + typedef StreamType stream_type; + + //- The stream pointer + stream_type stream_; + + + // Constructors + + //- Construct with buffer and number of bytes + BufStreamAllocator(char *buffer, size_t nbytes) + : + storage_(buffer), + len_(nbytes), + buf_(storage_, len_), + stream_(&buf_) + {} + + + //- Destructor + ~BufStreamAllocator() + { + // Possible cleanup of storage + if (Manage && storage_) + { + delete storage_; + storage_ = nullptr; + } + } + + + // Protected Member Functions + + + //- Position of the get buffer + std::streampos tellg() const + { + return const_cast<stream_type&>(stream_).tellg(); + } + + //- Position of the put buffer + std::streampos tellp() const + { + return const_cast<stream_type&>(stream_).tellp(); + } + + +public: + + // Public Member Functions + + //- Move to buffer start, clear errors + void rewind() + { + stream_.rdbuf()->pubseekpos(0); + stream_.clear(); // for safety, clear any old errors + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/OCountStream.H b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H new file mode 100644 index 00000000000..b3ce64b1695 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H @@ -0,0 +1,230 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::OSCountStream + +Description + An output stream for calculating byte counts. + +\*---------------------------------------------------------------------------*/ + +#ifndef OScountStream_H +#define OScountStream_H + +#include "OSstream.H" +#include <iostream> + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class countstreambuf Declaration +\*---------------------------------------------------------------------------*/ + +//- A streambuf class for determining byte counts +class countstreambuf +: + public std::streambuf +{ + // Private data + + //- The number of bytes + std::streamsize n_; + +protected: + // Protected members + + //- Put sequence of characters + virtual std::streamsize xsputn(const char* s, std::streamsize num) + { + n_ += num; + return num; + } + + + //- Set position pointer to absolute position + // For the counter, any positioning is ignored and it always acts like + // seekpos(0), which resets the count. + virtual std::streampos seekpos + ( + std::streampos sp, + std::ios_base::openmode which = std::ios_base::in|std::ios_base::out + ) + { + n_ = 0; + return 0; + } + + +public: + + // Constructors + + //- Construct null + countstreambuf() + : + n_(0) + {} + + + // Access + + //- Get number of bytes counted + std::streamsize size() const + { + return n_; + } +}; + + +/*---------------------------------------------------------------------------*\ + Class ocountstream Declaration +\*---------------------------------------------------------------------------*/ + +//- Trivial output stream for calculating byte counts +// Since all output values are discarded, it can also be used as a /dev/null +// output buffer as well +class ocountstream +: + virtual public std::ios, + public std::ostream +{ + // Private data + + countstreambuf buf_; + +public: + + // Constructors + + //- Construct null + ocountstream() + : + std::ostream(&buf_) + {} + + + // Member Functions + + // Access + + //- This hides both signatures of std::basic_ios::rdbuf() + countstreambuf* rdbuf() + { + return &buf_; + } + + + //- Get number of bytes counted + std::streamsize size() const + { + return buf_.size(); + } + + + //- Rewind the stream, reset the count + void rewind() + { + buf_.pubseekpos(0); + clear(); // for safety, clear any old errors + } +}; + + +/*---------------------------------------------------------------------------*\ + Class OCountStream Declaration +\*---------------------------------------------------------------------------*/ + +//- An output stream for calculating byte counts +class OCountStream +: + private ocountstream, + public OSstream +{ + + // Private Member Functions + + //- Disallow default bitwise copy construct + OCountStream(const OCountStream&) = delete; + + //- Disallow default bitwise assignment + void operator=(const OCountStream&) = delete; + +public: + + // Constructors + + //- Construct and set stream status + OCountStream + ( + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + ocountstream(), + OSstream + ( + static_cast<ocountstream&>(*this), + "output", + format, + version + ) + {} + + + //- Destructor + ~OCountStream() + {} + + + // Member functions + + // Access + + //- Return the number of bytes counted + using ocountstream::size; + + + // Edit + + //- Rewind the stream, reset the count, clearing any old errors + void rewind() + { + ocountstream::rewind(); + setGood(); // resynchronize with internal state + } + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/UIBufStream.H b/src/OpenFOAM/db/IOstreams/memory/UIBufStream.H new file mode 100644 index 00000000000..e02929f181f --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/UIBufStream.H @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::UIBufStream + +Description + Similar to IStringStream but using an externally managed buffer for its + input. This allows the input buffer to be filled (and refilled) from + various sources. + + Note that this stream will normally be used as a "one-shot" reader. + Caution must be exercised that the referenced buffer remains valid and + without any intermediate resizing for the duration of the stream's use. + + An example of possible use: + \code + DynamicList<char> buffer(4096); // allocate some large buffer + + nread = something.read(buffer.data(),1024); // fill with content + buffer.setSize(nread); // content size + + // construct dictionary, or something else + UIBufStream is(buffer) + dictionary dict1(is); + + // sometime later + nread = something.read(buffer.data(),2048); // fill with content + buffer.setSize(nread); // content size + + // without intermediate variable + dictionary dict2(UIBufStream(buffer)()); + \endcode + +\*---------------------------------------------------------------------------*/ + +#ifndef UIBufStream_H +#define UIBufStream_H + +#include "BufStreamAllocator.H" +#include "ISstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class UIBufStream Declaration +\*---------------------------------------------------------------------------*/ + +class UIBufStream +: + public BufStreamAllocator<std::istream,false>, + public ISstream +{ + typedef BufStreamAllocator<std::istream,false> allocator_type; + +public: + + // Constructors + + //- Construct using specified buffer and number of bytes + UIBufStream + ( + const char* buffer, + size_t nbytes, + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + allocator_type(const_cast<char*>(buffer), nbytes), + ISstream(stream_, name, format, version) + {} + + + //- Construct using data area from a List and number of bytes + UIBufStream + ( + const UList<char>& buffer, + label size, + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + UIBufStream(buffer.cdata(), size, format,version,name) + {} + + + //- Construct using data area from a List and its inherent storage size + // Uses addressed size, thus no special treatment for a DynamicList + UIBufStream + ( + const UList<char>& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + UIBufStream(buffer.cdata(), buffer.size(), format,version,name) + {} + + + //- Destructor + ~UIBufStream() + {} + + + // Member functions + + //- Return the current get position in the buffer + std::streampos pos() const + { + return allocator_type::tellg(); + } + + + //- Rewind the stream, clearing any old errors + virtual void rewind() + { + allocator_type::rewind(); + setGood(); // resynchronize with internal state + } + + + // Member operators + + //- A non-const reference to const Istream + // Needed for read-constructors where the stream argument is temporary + Istream& operator()() const + { + return const_cast<Istream&>(static_cast<const Istream&>(*this)); + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/UOBufStream.H b/src/OpenFOAM/db/IOstreams/memory/UOBufStream.H new file mode 100644 index 00000000000..6a8df54e7ae --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/UOBufStream.H @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::UOBufStream + +Description + Similar to OStringStream but using an externally managed buffer for + its output. + + This allows the output buffer to be reused and can make it easier when + writing out data. It is the user's responsibility to ensure proper + synchronization in the sizes. Provided that the external buffer is large + enough that overflow does not occur, the following usage pattern + works. + + \code + DynamicList<char> buffer(4096); // allocate some large buffer + + { + UOBufStream os(buffer); + os << "content1" << " and more content"; + buffer.setSize(os.size()); // synchronize sizes + } + + something.write(buffer, buffer.size()); + \endcode + + Although the UOBufStream is quite lightweight, there may be cases + where it is preferable to reuse the stream as well. + \code + DynamicList<char> buffer(4096); // allocate some large buffer + + UOBufStream os(buffer); + os << "content1" << " and more content"; + buffer.setSize(os.size()); // synchronize sizes + + something.write(buffer, buffer.size()); + + os.rewind(); + os << "content2"; + buffer.setSize(os.size()); // synchronize sizes + + something.write(buffer, buffer.size()); + + // or simply using the output size directly (without sync) + os.rewind(); + os << "content3"; + + something.write(buffer, os.size()); + \endcode + +\*---------------------------------------------------------------------------*/ + +#ifndef UOBufStream_H +#define UOBufStream_H + +#include "BufStreamAllocator.H" +#include "OSstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration +template<class T, int SizeMin> class DynamicList; + + +/*---------------------------------------------------------------------------*\ + Class UOBufStream Declaration +\*---------------------------------------------------------------------------*/ + +//- An OSstream attached to an unallocated external buffer +class UOBufStream +: + public BufStreamAllocator<std::ostream,false>, + public OSstream +{ + typedef BufStreamAllocator<std::ostream,false> allocator_type; + +public: + + // Constructors + + //- Construct using specified buffer and number of bytes + UOBufStream + ( + char* buffer, + size_t nbytes, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + allocator_type(buffer, nbytes), + OSstream(stream_, "output", format,version) + {} + + + //- Construct using data area from a List and number of bytes + UOBufStream + ( + UList<char>& buffer, + size_t size, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + UOBufStream(buffer.data(), size, format,version) + {} + + + //- Construct using data area from a List and its inherent storage size + UOBufStream + ( + UList<char>& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + UOBufStream(buffer.data(), buffer.size(), format,version) + {} + + + //- Construct using data area from a DynamicList and its capacity + template<int SizeMin> + UOBufStream + ( + DynamicList<char,SizeMin>& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + UOBufStream(buffer.data(), buffer.capacity(), format,version) + {} + + + //- Destructor + ~UOBufStream() + {} + + + // Member functions + + //- Return the current output position in the buffer + std::streampos size() const + { + return allocator_type::tellp(); + } + + + //- Rewind the stream, clearing any old errors + void rewind() + { + allocator_type::rewind(); + setGood(); // resynchronize with internal state + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab From 3cbf399470dca841282a9fde45df376b003b9071 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 24 Oct 2017 10:29:09 +0200 Subject: [PATCH 052/126] BUG: failed swap/transfer for DynamicList with different sizing parameters - now use public functions instead of direct access of private 'capacity_' information --- .../test/DynamicList/Test-DynamicList.C | 29 +++++++++ .../Lists/DynamicList/DynamicList.H | 8 +++ .../Lists/DynamicList/DynamicListI.H | 59 ++++++++++++++++--- .../fields/Fields/DynamicField/DynamicField.H | 34 +++++------ 4 files changed, 106 insertions(+), 24 deletions(-) diff --git a/applications/test/DynamicList/Test-DynamicList.C b/applications/test/DynamicList/Test-DynamicList.C index ca3f4fc7872..11111aad004 100644 --- a/applications/test/DynamicList/Test-DynamicList.C +++ b/applications/test/DynamicList/Test-DynamicList.C @@ -46,6 +46,14 @@ void printInfo if (showSize) { Info<< " size=\"" << lst.size() << "\""; + if (lst.cdata()) + { + Info<< " ptr=\"" << long(lst.cdata()) << "\""; + } + else + { + Info<< " ptr=\"nullptr\""; + } } Info<< ">" << nl << flatOutput(lst) << nl << "</" << tag << ">" << endl; } @@ -64,6 +72,14 @@ void printInfo { Info<< " size=\"" << lst.size() << "\" capacity=\"" << lst.capacity() << "\""; + if (lst.cdata()) + { + Info<< " ptr=\"" << long(lst.cdata()) << "\""; + } + else + { + Info<< " ptr=\"nullptr\""; + } } Info<< ">" << nl << flatOutput(lst) << nl << "</" << tag << ">" << endl; } @@ -284,6 +300,19 @@ int main(int argc, char *argv[]) << flatOutput(input1) << " / " << flatOutput(input2) << nl; + Info<< "test move dissimilar sizing:" << nl; + list1 = list2; + list1.reserve(100); + + // DynamicList<label,1000> list3; // (std::move(list1)); + DynamicList<label,1000> list3(std::move(list1)); + Info<< "orig: " << flatOutput(list1) << nl; + + // list3.swap(list1); + // list3 = std::move(list1); + + printInfo("input", list1, true); + printInfo("output", list3, true); input1 = list2; diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 4dae845ed31..a5fe88bd503 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -158,6 +158,10 @@ public: //- Move construct. inline DynamicList(DynamicList<T, SizeMin>&& lst); + //- Move construct with different sizing parameters + template<int AnySizeMin> + inline DynamicList(DynamicList<T, AnySizeMin>&& lst); + //- Move construct from List inline DynamicList(List<T>&& lst); @@ -212,6 +216,10 @@ public: //- Clear the list and delete storage. inline void clearStorage(); + //- Expand the addressable size to fit the allocated capacity. + // Returns the previous addressable size. + inline label expandStorage(); + //- Shrink the allocated space to the number of elements used. // Returns a reference to the DynamicList. inline DynamicList<T, SizeMin>& shrink(); diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index a41f284f639..2fcfc660628 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -206,6 +206,19 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList } +template<class T, int SizeMin> +template<int AnySizeMin> +inline Foam::DynamicList<T, SizeMin>::DynamicList +( + DynamicList<T, AnySizeMin>&& lst +) +: + capacity_(0) +{ + transfer(lst); +} + + template<class T, int SizeMin> inline Foam::DynamicList<T, SizeMin>::DynamicList ( @@ -360,6 +373,18 @@ inline void Foam::DynamicList<T, SizeMin>::clearStorage() } +template<class T, int SizeMin> +inline Foam::label Foam::DynamicList<T, SizeMin>::expandStorage() +{ + const label nextFree = List<T>::size(); + + // Allow addressing into the entire list + List<T>::size(capacity_); + + return nextFree; +} + + template<class T, int SizeMin> inline Foam::DynamicList<T, SizeMin>& Foam::DynamicList<T, SizeMin>::shrink() @@ -386,8 +411,26 @@ inline void Foam::DynamicList<T, SizeMin>::swap DynamicList<T, AnySizeMin>& lst ) { - Foam::Swap(static_cast<UList<T>&>(*this), static_cast<UList<T>&>(lst)); - Foam::Swap(capacity_, lst.capacity_); + DynamicList<T, SizeMin>& cur = *this; + + // Make addressable size identical to the allocated capacity + const label oldSize1 = cur.expandStorage(); + const label oldSize2 = lst.expandStorage(); + + // Swap storage + Foam::Swap + ( + static_cast<UList<T>&>(cur), + static_cast<UList<T>&>(lst) + ); + + // Match capacity to the underlying allocated list size + cur.setCapacity(cur.size()); + lst.setCapacity(lst.size()); + + // Set addressable size + cur.setSize(oldSize2); + lst.setSize(oldSize1); } @@ -409,10 +452,12 @@ Foam::DynamicList<T, SizeMin>::transfer DynamicList<T, AnySizeMin>& lst ) { - // Take over storage as-is (without shrink), clear addressing for lst. - capacity_ = lst.capacity_; - lst.capacity_ = 0; + // Take over storage as-is (without shrink, without using SizeMin) + // clear addressing and storage for old lst. + capacity_ = lst.capacity(); + List<T>::transfer(static_cast<List<T>&>(lst)); + lst.clearStorage(); // Ensure capacity=0 } @@ -565,7 +610,7 @@ Foam::DynamicList<T, SizeMin>::append ) { append(std::move(static_cast<List<T>&>(lst))); - lst.clearStorage(); // Ensure capacity=0 too + lst.clearStorage(); // Ensure capacity=0 return *this; } @@ -579,7 +624,7 @@ Foam::DynamicList<T, SizeMin>::append ) { append(std::move(static_cast<List<T>&>(lst))); - lst.clearStorage(); // Ensure capacity=0 too + lst.clearStorage(); // Ensure capacity=0 return *this; } diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H index fd5b3a5486f..ea2f2a7e5b5 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H @@ -103,17 +103,17 @@ public: inline DynamicField(); //- Construct given size. - explicit inline DynamicField(const label); + explicit inline DynamicField(const label nElem); //- Construct from UList. Size set to UList size. // Also constructs from DynamicField with different sizing parameters. - explicit inline DynamicField(const UList<T>&); + explicit inline DynamicField(const UList<T>& lst); //- Construct by transferring the parameter contents - explicit inline DynamicField(const Xfer<List<T>>&); + explicit inline DynamicField(const Xfer<List<T>>& lst); //- Construct by transferring the parameter contents - explicit inline DynamicField(const Xfer<Field<T>>&); + explicit inline DynamicField(const Xfer<Field<T>>& lst); //- Construct by 1 to 1 mapping from the given field inline DynamicField @@ -138,16 +138,16 @@ public: ); //- Construct copy - inline DynamicField(const DynamicField<T, SizeMin>&); + inline DynamicField(const DynamicField<T, SizeMin>& lst); //- Construct by transferring the Field contents inline DynamicField ( - const Xfer<DynamicField<T, SizeMin>>& + const Xfer<DynamicField<T, SizeMin>>& lst ); //- Construct from Istream. Size set to size of list read. - explicit DynamicField(Istream&); + explicit DynamicField(Istream& is); //- Clone tmp<DynamicField<T, SizeMin>> clone() const; @@ -166,31 +166,31 @@ public: // The addressed size will be truncated if needed to fit, but will // remain otherwise untouched. // Use this or reserve() in combination with append(). - inline void setCapacity(const label); + inline void setCapacity(const label nElem); //- Alter the addressed list size. // New space will be allocated if required. // Use this to resize the list prior to using the operator[] for // setting values (as per List usage). - inline void setSize(const label); + inline void setSize(const label nElem); //- Alter the addressed list size and fill new space with a // constant. - inline void setSize(const label, const T&); + inline void setSize(const label nElem, const T& val); //- Alter the addressed list size. // New space will be allocated if required. // Use this to resize the list prior to using the operator[] for // setting values (as per List usage). - inline void resize(const label); + inline void resize(const label nElem); //- Alter the addressed list size and fill new space with a // constant. - inline void resize(const label, const T& val); + inline void resize(const label nElem, const T& val); //- Reserve allocation space for at least this size. // Never shrinks the allocated size, use setCapacity() for that. - inline void reserve(const label); + inline void reserve(const label nElem); //- Clear the addressed list, i.e. set the size to zero. // Allocated size does not change @@ -222,19 +222,19 @@ public: //- Return non-const access to an element, resizing list if // necessary - inline T& operator()(const label); + inline T& operator()(const label elemI); //- Assignment of all addressed entries to the given value - inline void operator=(const T&); + inline void operator=(const T& val); //- Assignment to DynamicField inline void operator= ( - const DynamicField<T, SizeMin>& + const DynamicField<T, SizeMin>& lst ); //- Assignment to UList - inline void operator=(const UList<T>&); + inline void operator=(const UList<T>& lst); }; -- GitLab From 88bb403fe022ee2da41f17bc48f4f57c99a4a6c9 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 24 Oct 2017 11:59:11 +0200 Subject: [PATCH 053/126] ENH: new stream output: OListStream - an output stream to a DynamicList --- applications/test/OListStream/Make/files | 3 + applications/test/OListStream/Make/options | 2 + .../test/OListStream/Test-OListStream.C | 79 ++++ .../db/IOstreams/memory/OListStream.H | 416 ++++++++++++++++++ 4 files changed, 500 insertions(+) create mode 100644 applications/test/OListStream/Make/files create mode 100644 applications/test/OListStream/Make/options create mode 100644 applications/test/OListStream/Test-OListStream.C create mode 100644 src/OpenFOAM/db/IOstreams/memory/OListStream.H diff --git a/applications/test/OListStream/Make/files b/applications/test/OListStream/Make/files new file mode 100644 index 00000000000..583b8e7f069 --- /dev/null +++ b/applications/test/OListStream/Make/files @@ -0,0 +1,3 @@ +Test-OListStream.C + +EXE = $(FOAM_USER_APPBIN)/Test-OListStream diff --git a/applications/test/OListStream/Make/options b/applications/test/OListStream/Make/options new file mode 100644 index 00000000000..4e772fdf9d7 --- /dev/null +++ b/applications/test/OListStream/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ +/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/OListStream/Test-OListStream.C b/applications/test/OListStream/Test-OListStream.C new file mode 100644 index 00000000000..adbbc722d59 --- /dev/null +++ b/applications/test/OListStream/Test-OListStream.C @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + +\*---------------------------------------------------------------------------*/ + +#include "OListStream.H" +#include "wordList.H" +#include "IOstreams.H" +#include "argList.H" + +using namespace Foam; + +Ostream& toString(Ostream& os, const UList<char>& list) +{ + os << '"'; + for (const char c : list) + { + os << c; + } + os << '"'; + + return os; +} + + +void printInfo(const OListStream& buf) +{ + Info<< nl << buf.size() << " chars (" << buf.capacity() << " capacity) "; + toString(Info, buf.list()) << endl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + // Buffer storage + DynamicList<char> storage(8); + + OListStream obuf(std::move(storage)); + obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n"; + + printInfo(obuf); + + obuf.rewind(); + obuf << 100; + + printInfo(obuf); + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/OListStream.H b/src/OpenFOAM/db/IOstreams/memory/OListStream.H new file mode 100644 index 00000000000..b76b7f6f7fa --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/OListStream.H @@ -0,0 +1,416 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::OListStream + +Description + An output stream that writes to a DynamicList. + +\*---------------------------------------------------------------------------*/ + +#ifndef OListStream_H +#define OListStream_H + +#include <sstream> +#include "DynamicList.H" +#include "OSstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration +class OListStreamAllocator; + +/*---------------------------------------------------------------------------*\ + Class OListStreamAllocator Declaration +\*---------------------------------------------------------------------------*/ + +//- An stream/stream-buffer allocator for external buffers +class OListStreamAllocator +{ + //- A streambuf adapter to output to a DynamicList + class olistbuf + : + public std::streambuf + { + friend OListStreamAllocator; + + //- Underlying list storage + DynamicList<char,512> storage_; + + + //- Adjust buffer pointers to agree with list sizes + inline void syncBufferPointers() + { + setp(storage_.data(), storage_.data() + storage_.capacity()); + pbump(storage_.size()); + } + + //- Adjust addressed list size to agree with buffer pointers + inline void syncListSize() + { + storage_.setSize(pptr() - pbase()); + } + + + protected: + + // Protected members + + //- Set position pointer to relative position + virtual std::streampos seekoff + ( + std::streamoff off, + std::ios_base::seekdir way, + std::ios_base::openmode which = std::ios_base::out + ) + { + const bool testout = which & std::ios_base::out; + + if (way == std::ios_base::beg) + { + if (testout) + { + setp(pbase(), epptr()); + pbump(off); + } + + return off; + } + + if (way == std::ios_base::cur) + { + if (testout) + { + pbump(off); + } + } + else if (way == std::ios_base::end) + { + if (testout) + { + pbump(off); + } + } + + if (testout) + { + return pptr() - pbase(); + } + + return -1; + } + + + //- Set position pointer to absolute position + virtual std::streampos seekpos + ( + std::streampos pos, + std::ios_base::openmode which = std::ios_base::out + ) + { + if (which & std::ios_base::out) + { + setp(pbase(), epptr()); + pbump(pos); + + return pptr() - pbase(); + } + + return -1; + } + + + //- Put sequence of characters + virtual std::streamsize xsputn(const char* s, std::streamsize n) + { + const std::streamsize newlen = n + storage_.size(); + + if (newlen > storage_.capacity()) + { + // Either use reserve(), or setCapacity() directly + // with finer control over growth + storage_.reserve(newlen); + syncBufferPointers(); + } + + std::streamsize count = 0; + while (count < n && pptr() < epptr()) + { + *(pptr()) = *(s + count++); + pbump(1); + } + + // Synchronize list size with output + syncListSize(); + + return count; + } + + + public: + + // Constructors + + //- Construct with an empty list + olistbuf() + : + storage_(1024) + { + syncBufferPointers(); + } + + + //- Construct with a specified number of reserved bytes + olistbuf(size_t nbytes) + : + storage_() + { + storage_.reserve(std::max(label(nbytes),1024)); + syncBufferPointers(); + } + + + //- Move construct from an existing List + olistbuf(List<char>&& buffer) + : + storage_(std::move(buffer)) + { + syncBufferPointers(); + } + + + //- Move construct from an existing DynamicList + template<int AnySize> + olistbuf(DynamicList<char,AnySize>&& buffer) + : + storage_(std::move(buffer)) + { + syncBufferPointers(); + } + }; + + + // Private data + + //- Reference to the underlying buffer + olistbuf buf_; + + +protected: + + // Protected data + + typedef std::ostream stream_type; + + //- The output stream + stream_type stream_; + + + // Constructors + + //- Construct with an empty list + OListStreamAllocator() + : + buf_(), + stream_(&buf_) + {} + + + //- Construct with a specified number of reserved bytes + OListStreamAllocator(size_t nbytes) + : + buf_(nbytes), + stream_(&buf_) + {} + + + //- Move construct from an existing List + OListStreamAllocator(List<char>&& buffer) + : + buf_(std::move(buffer)), + stream_(&buf_) + {} + + + //- Move construct from an existing DynamicList + template<int SizeMin> + OListStreamAllocator(DynamicList<char,SizeMin>&& buffer) + : + buf_(std::move(buffer)), + stream_(&buf_) + {} + + + //- Destructor + ~OListStreamAllocator() + {} + + +public: + + // Member Functions + + //- Content as a list of characters + UList<char> list() const + { + return UList<char> + ( + const_cast<char*>(buf_.storage_.cdata()), + buf_.storage_.size() + ); + } + + + //- Content as a list of characters + UList<char>& list() + { + return static_cast<UList<char>&>(buf_.storage_); + } + + //- Return the current list capacity + inline label capacity() const + { + return buf_.storage_.capacity(); + } + + + //- Reserve allocation space for at least this size. + inline void reserve(const label nElem) + { + buf_.storage_.reserve(nElem); + buf_.syncBufferPointers(); + } + + + //- Return the current output position in the buffer + // The same as the DynamicList::size() + std::streampos size() const + { + return const_cast<stream_type&>(stream_).tellp(); + } + + + //- Move to buffer start, clear errors + void rewind() + { + buf_.storage_.clear(); + buf_.syncBufferPointers(); + stream_.clear(); // for safety, clear any old errors + } +}; + + +/*---------------------------------------------------------------------------*\ + Class OListStream Declaration +\*----------------------------------------------d-----------------------------*/ + +//- An OSstream attached a DynamicList +class OListStream +: + public OListStreamAllocator, + public OSstream +{ + typedef OListStreamAllocator allocator_type; + +public: + + // Constructors + + //- Construct with an empty list + OListStream + ( + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + allocator_type(), + OSstream(stream_, "output", format,version) + {} + + + //- Construct with a specified number of reserved bytes + OListStream + ( + size_t nbytes, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + allocator_type(nbytes), + OSstream(stream_, "output", format, version) + {} + + + //- Move construct from an existing List + OListStream + ( + List<char>&& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + allocator_type(std::move(buffer)), + OSstream(stream_, "output", format, version) + {} + + + //- Move construct from an existing DynamicList + template<int SizeMin> + OListStream + ( + DynamicList<char,SizeMin>&& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + allocator_type(std::move(buffer)), + OSstream(stream_, "output", format, version) + {} + + + //- Destructor + ~OListStream() + {} + + + // Member functions + + //- Rewind the stream, clearing any old errors + using allocator_type::rewind; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab From 2ab03f7abe1d0c8641c89183c973d6409e7d1a19 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 24 Oct 2017 13:18:01 +0200 Subject: [PATCH 054/126] STYLE: simplify stream types - reduce coding clutter, avoiding allocated pointers when possible. IFstream and OFstream continue to use pointers since they handle compressed files, other streams can do without them. --- .../db/IOstreams/StringStreams/StringStream.H | 69 ++++----- .../db/IOstreams/hashes/OSHA1stream.H | 136 ++++++++---------- 2 files changed, 93 insertions(+), 112 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H index 91b1a7ce34a..cee86b47bb6 100644 --- a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H +++ b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H @@ -56,8 +56,11 @@ protected: // Member Data - //- The allocated stream pointer. - StreamType* allocatedPtr_; + //- The stream type + typedef StreamType stream_type; + + //- The input/output stream. + stream_type stream_; // Constructors @@ -65,56 +68,36 @@ protected: //- Construct null StringStreamAllocator() : - allocatedPtr_(new StreamType()) + stream_() {} - //- Construct from pointer, taking ownership - StringStreamAllocator(StreamType* ptr) - : - allocatedPtr_(ptr) - {} - //- Construct from string + //- Copy construct from string StringStreamAllocator(const std::string& buffer) : - allocatedPtr_(new StreamType(buffer)) + stream_(buffer) {} //- Destructor ~StringStreamAllocator() - { - deallocate(); - } - - - // Protected Member Functions - - //- Delete the stream pointer - void deallocate() - { - if (allocatedPtr_) - { - delete allocatedPtr_; - allocatedPtr_ = nullptr; - } - } + {} public: // Public Member Functions - //- Get the string + //- Get the string - as Foam::string rather than std::string Foam::string str() const { - return allocatedPtr_->str(); + return Foam::string(stream_.str()); } //- Set the string void str(const std::string& s) { - allocatedPtr_->str(s); + stream_.str(s); } }; @@ -143,7 +126,7 @@ public: ) : StringStreamAllocator<std::istringstream>(buffer), - ISstream(*allocatedPtr_, name, format, version) + ISstream(stream_, name, format, version) {} @@ -157,7 +140,15 @@ public: ) : StringStreamAllocator<std::istringstream>(buffer), - ISstream(*allocatedPtr_, name, format, version) + ISstream(stream_, name, format, version) + {} + + + //- Construct as copy of content + IStringStream(const IStringStream& str) + : + StringStreamAllocator<std::istringstream>(str.str()), + ISstream(stream_, str.name(), str.format(), str.version()) {} @@ -182,8 +173,7 @@ public: // Member operators //- Return a non-const reference to const Istream - // Needed for read-constructors where the stream argument is temporary: - // e.g. thing thisThing(IFstream("thingFileName")()); + // Needed for read-constructors where the stream argument is temporary. Istream& operator()() const { return const_cast<IStringStream&>(*this); @@ -214,14 +204,15 @@ public: ) : StringStreamAllocator<std::ostringstream>(), - OSstream(*allocatedPtr_, "output", format, version) + OSstream(stream_, "output", format, version) {} - //- Construct as copy - OStringStream(const OStringStream& oss) + + //- Construct as copy of content + OStringStream(const OStringStream& str) : - StringStreamAllocator<std::ostringstream>(oss.str()), - OSstream(*allocatedPtr_, oss.name(), oss.format(), oss.version()) + StringStreamAllocator<std::ostringstream>(str.str()), + OSstream(stream_, str.name(), str.format(), str.version()) {} @@ -243,7 +234,7 @@ public: void rewind() { // pubseekpos() instead of seekp() for symmetry with other classes - allocatedPtr_->rdbuf()->pubseekpos(0, std::ios_base::out); + stream_.rdbuf()->pubseekpos(0, std::ios_base::out); } //- Print description to Ostream diff --git a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H index 8a43d3d7b15..414259c7951 100644 --- a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H +++ b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H @@ -47,55 +47,57 @@ class osha1stream; class OSHA1stream; /*---------------------------------------------------------------------------*\ - Class sha1streambuf Declaration + Class osha1stream Declaration \*---------------------------------------------------------------------------*/ -//- A streambuf class for calculating SHA1 digests -class sha1streambuf +//- A basic output stream for calculating SHA1 digests +class osha1stream : - public std::streambuf + virtual public std::ios, + public std::ostream { - // Private data + //- A streambuf class for calculating SHA1 digests + class sha1buf + : + public std::streambuf + { + //- This does all the work and has its own buffering + SHA1 sha1_; - //- This does all the work and has its own buffering - SHA1 sha1_; + protected: + // Protected members - friend class osha1stream; + //- Put sequence of characters + virtual std::streamsize xsputn(const char* str, std::streamsize n) + { + sha1_.append(str, n); + return n; + } -public: - // Constructors + public: - //- Construct null - sha1streambuf() - {} + // Constructors - // Member Functions + //- Construct null + sha1buf() + {} - // Write - //- Process unbuffered - virtual std::streamsize xsputn(const char* str, std::streamsize n) - { - sha1_.append(str, n); - return n; - } -}; + // Public member functions + //- Full access to the sha1 + inline SHA1& sha1() + { + return sha1_; + } + }; -/*---------------------------------------------------------------------------*\ - Class osha1stream Declaration -\*---------------------------------------------------------------------------*/ -//- A basic output stream for calculating SHA1 digests -class osha1stream -: - virtual public std::ios, - public std::ostream -{ // Private data - sha1streambuf sbuf_; + //- Reference to the underlying buffer + sha1buf buf_; public: @@ -104,23 +106,24 @@ public: //- Construct null osha1stream() : - std::ostream(&sbuf_) + std::ostream(&buf_) {} + // Member Functions // Access //- This hides both signatures of std::basic_ios::rdbuf() - sha1streambuf* rdbuf() + sha1buf* rdbuf() { - return &sbuf_; + return &buf_; } //- Full access to the sha1 SHA1& sha1() { - return sbuf_.sha1_; + return buf_.sha1(); } }; @@ -135,10 +138,12 @@ class OSHA1streamAllocator { protected: - // Member data + // Protected data + + typedef osha1stream stream_type; - //- The allocated stream pointer - osha1stream* allocatedPtr_; + //- The output stream + stream_type stream_; // Constructors @@ -146,36 +151,37 @@ protected: //- Construct null OSHA1streamAllocator() : - allocatedPtr_(new osha1stream()) + stream_() {} //- Destructor ~OSHA1streamAllocator() - { - deallocate(); - } + {} +public: + // Member Functions - //- Delete the stream pointer - void deallocate() + //- Full access to the sha1 + SHA1& sha1() { - if (allocatedPtr_) - { - delete allocatedPtr_; - allocatedPtr_ = nullptr; - } + return stream_.sha1(); } -public: + //- Return SHA1::Digest for the data processed until now + SHA1Digest digest() + { + return stream_.sha1().digest(); + } - //- Full access to the sha1 - SHA1& sha1() + + //- Clear the SHA1 calculation + void reset() { - return allocatedPtr_->sha1(); + return stream_.sha1().clear(); } }; @@ -191,6 +197,7 @@ class OSHA1stream public OSHA1streamAllocator, public OSstream { + typedef OSHA1streamAllocator allocator_type; // Private Member Functions @@ -211,8 +218,8 @@ public: versionNumber version=currentVersion ) : - OSHA1streamAllocator(), - OSstream(*allocatedPtr_, "OSHA1stream", format, version) + allocator_type(), + OSstream(stream_, "sha1", format, version) {} @@ -223,23 +230,6 @@ public: // Member functions - // Access - - //- Return SHA1::Digest for the data processed until now - SHA1Digest digest() - { - return sha1().digest(); - } - - - // Edit - - //- Clear the SHA1 calculation - void reset() - { - sha1().clear(); - } - //- Clear the SHA1 calculation // \deprecated use reset instead (deprecated Jul 2017) void rewind() -- GitLab From 7d7b0bfe847ed054582b5332503284f8134e1ecc Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 24 Oct 2017 19:07:34 +0200 Subject: [PATCH 055/126] STYLE: use list methods find/found instead of findIndex function --- .../Test-checkDecomposePar.C | 2 +- .../test/decomposePar/Test-decomposePar.C | 2 +- .../mesh/advanced/modifyMesh/cellSplitter.C | 12 ++-- .../mesh/advanced/splitCells/splitCells.C | 4 +- .../mesh/conversion/gmshToFoam/gmshToFoam.C | 4 +- .../ideasUnvToFoam/ideasUnvToFoam.C | 4 +- .../extrudeMesh/extrudedMesh/extrudedMesh.C | 2 +- .../extrudeToRegionMesh/extrudeToRegionMesh.C | 10 +-- .../patchToPoly2DMesh/patchToPoly2DMesh.C | 4 +- .../conformalVoronoiMesh.C | 2 +- .../conformalVoronoiMeshCalcDualMesh.C | 4 +- .../conformalVoronoiMeshI.H | 4 +- .../conformalVoronoiMeshIO.C | 2 +- .../conformalVoronoiMeshZones.C | 2 +- .../foamyQuadMesh/shortEdgeFilter2D.C | 2 +- .../mesh/manipulation/autoPatch/autoPatch.C | 2 +- .../manipulation/polyDualMesh/meshDualiser.C | 22 +++--- .../splitMeshRegions/splitMeshRegions.C | 4 +- .../foamFormatConvert/foamFormatConvert.C | 2 +- .../miscellaneous/patchSummary/patchSummary.C | 2 +- .../decomposePar/decomposePar.C | 2 +- .../decomposePar/lagrangianFieldDecomposer.C | 7 +- .../reconstructPar/reconstructPar.C | 2 +- .../parLagrangianRedistributor.C | 2 +- .../redistributePar/redistributePar.C | 2 +- .../foamToTecplot360/tecplotWriter.C | 2 +- .../changeDictionary/changeDictionary.C | 2 +- .../surfaceBooleanFeatures.C | 2 +- .../surface/surfaceClean/collapseBase.C | 18 ++--- .../surface/surfaceHookUp/surfaceHookUp.C | 13 ++-- .../surface/surfaceInflate/surfaceInflate.C | 4 +- .../surfaceSplitNonManifolds.C | 8 +-- .../containers/Lists/ListOps/ListOps.H | 1 + .../Lists/ListOps/ListOpsTemplates.C | 2 +- src/OpenFOAM/containers/Lists/UList/UList.C | 21 ++---- src/OpenFOAM/containers/Lists/UList/UList.H | 9 ++- .../IOdictionary/unwatchedIOdictionary.C | 4 +- src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C | 6 +- .../GAMGAgglomerateLduAddressing.C | 8 +-- .../GAMGAgglomeration/GAMGAgglomeration.C | 4 +- .../manualGAMGProcAgglomeration.C | 13 ++-- .../Identifiers/patch/coupleGroupIdentifier.C | 2 +- .../Identifiers/patch/patchIdentifier.C | 2 +- .../meshes/lduMesh/lduPrimitiveMesh.C | 11 ++- .../polyMesh/globalMeshData/globalMeshData.C | 21 +++--- .../polyMesh/globalMeshData/globalPoints.C | 8 +-- .../mapDistribute/mapDistributeBase.C | 2 +- .../polyBoundaryMesh/polyBoundaryMesh.H | 4 +- .../meshes/polyMesh/polyMeshFromShapeMesh.C | 4 +- .../constraint/processor/processorPolyPatch.C | 4 +- .../polyPatches/derived/wall/wallPolyPatch.C | 4 +- .../polyPatches/polyPatch/polyPatch.C | 4 +- .../PatchTools/PatchToolsSortPoints.C | 2 +- .../PrimitivePatch/PrimitivePatchCheck.C | 4 +- .../primitiveMesh/primitiveMeshCellEdges.C | 4 +- .../primitiveMeshCheck/primitiveMeshCheck.C | 2 +- .../meshes/primitiveMesh/primitiveMeshEdges.C | 2 +- .../primitiveMesh/primitivePatch/walkPatch.C | 2 +- .../globalIndexAndTransform.C | 2 +- src/conversion/ccm/reader/ccmReaderMesh.C | 6 +- src/conversion/ccm/writer/ccmWriterMesh.C | 2 +- src/conversion/polyDualMesh/polyDualMesh.C | 8 +-- src/conversion/starcd/STARCDMeshWriter.C | 2 +- .../createShellMesh/createShellMesh.C | 16 ++--- .../fvMeshDistribute/fvMeshDistribute.C | 2 +- src/dynamicMesh/meshCut/cellCuts/cellCuts.C | 42 ++++------- .../meshCut/cellLooper/cellLooper.C | 2 +- .../meshCut/cellLooper/geomCellLooper.C | 2 +- .../meshCut/cellLooper/topoCellLooper.C | 26 ++----- .../directions/directionInfo/directionInfo.C | 12 ++-- .../boundaryCutter/boundaryCutter.C | 4 +- .../meshCutAndRemove/meshCutAndRemove.C | 8 +-- .../meshModifiers/meshCutter/meshCutter.C | 8 +-- .../multiDirRefinement/multiDirRefinement.C | 2 +- .../polyMeshAdder/faceCoupleInfo.C | 2 +- src/dynamicMesh/polyMeshAdder/polyMeshAdder.C | 18 ++--- .../polyTopoChange/addPatchCellLayer.C | 4 +- .../polyTopoChange/addPatchCellLayer.H | 2 +- .../polyTopoChange/combineFaces.C | 8 +-- .../polyTopoChange/duplicatePoints.C | 2 +- .../polyTopoChange/edgeCollapser.C | 6 +- .../polyTopoChange/hexRef8/hexRef8.C | 18 ++--- .../hexRef8/refinementHistory.C | 2 +- .../polyTopoChange/polyTopoChange.C | 2 +- .../polyTopoChange/removeFaces.C | 4 +- .../polyTopoChange/tetDecomposer.C | 2 +- .../cfdTools/general/fvOptions/fvOption.C | 2 +- .../CFCFaceToCellStencil.C | 4 +- .../fieldValueDelta/fieldValueDelta.C | 2 +- .../field/streamLine/streamLineBase.C | 2 +- .../wallBoundedParticle.C | 10 +-- .../clouds/Templates/DSMCCloud/DSMCCloud.C | 4 +- .../FreeStream/FreeStream.C | 2 +- .../molecule/molecule/moleculeI.H | 9 ++- .../molecule/moleculeCloud/moleculeCloud.C | 69 ++++++++----------- .../potential/potential/potential.C | 14 ++-- .../tetherPotentialList/tetherPotentialList.C | 2 +- .../meshRefinement/meshRefinement.C | 4 +- .../meshRefinement/meshRefinementBaffles.C | 6 +- .../snappyHexMeshDriver/snappyLayerDriver.C | 4 +- .../snappySnapDriverFeature.C | 2 +- .../AMIInterpolation/AMIInterpolation.C | 4 +- .../AMIInterpolationParallelOps.C | 2 +- .../AMIMethod/mapNearestAMI/mapNearestAMI.C | 4 +- .../PatchEdgeFaceWave/patchEdgeFaceRegionsI.H | 12 ++-- src/meshTools/cellFeatures/cellFeatures.C | 4 +- .../edgeFaceCirculator/edgeFaceCirculatorI.H | 2 +- .../extendedEdgeMeshTemplates.C | 2 +- .../extendedFeatureEdgeMeshTemplates.C | 2 +- .../indexedOctree/treeDataPrimitivePatch.C | 4 +- .../mappedPolyPatch/mappedPolyPatch.C | 4 +- .../mappedPolyPatch/mappedWallPolyPatch.C | 4 +- src/meshTools/meshTools/meshTools.C | 4 +- src/meshTools/regionSplit/localPointRegion.C | 4 +- .../searchableSurfaces/searchableSurfaces.C | 10 +-- .../triSurfaceMesh/triSurfaceMesh.C | 2 +- .../intersectedSurface/intersectedSurface.C | 2 +- .../surfaceFeatures/surfaceFeatures.C | 4 +- .../triSurfaceSearch/triSurfaceRegionSearch.C | 2 +- .../triSurfaceTools/triSurfaceCurvature.C | 2 +- .../triSurfaceTools/triSurfaceTools.C | 10 +-- .../cellCellStencil/cellCellStencil.C | 2 +- .../oversetPolyPatch/oversetPolyPatch.C | 4 +- .../decompositionMethod/decompositionMethod.C | 20 +++--- .../distributedTriSurfaceMesh.C | 2 +- .../noiseModels/surfaceNoise/surfaceNoise.C | 2 +- .../regionModel/regionModel/regionModel.C | 2 +- .../calcMethod/mapNearest/mapNearestMethod.C | 4 +- .../meshToMeshMethod/meshToMeshMethod.C | 8 +-- .../meshToMesh/meshToMeshParallelOps.C | 2 +- .../sampledPlane/sampledPlane.C | 4 +- .../plane/surfMeshPlaneSampler.C | 4 +- src/sampling/surface/isoSurface/isoSurface.C | 2 +- .../surface/isoSurface/isoSurfaceCell.C | 10 +-- .../isoSurface/isoSurfaceCellTemplates.C | 2 +- .../radiationModels/solarLoad/solarLoad.C | 2 +- 136 files changed, 369 insertions(+), 441 deletions(-) diff --git a/applications/test/checkDecomposePar/Test-checkDecomposePar.C b/applications/test/checkDecomposePar/Test-checkDecomposePar.C index fc6aa405da2..b88e92d25ec 100644 --- a/applications/test/checkDecomposePar/Test-checkDecomposePar.C +++ b/applications/test/checkDecomposePar/Test-checkDecomposePar.C @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) const wordList& regions = iter(); forAll(regions, i) { - if (findIndex(regionNames, regions[i]) == -1) + if (!regionNames.found(regions[i])) { regionNames.append(regions[i]); } diff --git a/applications/test/decomposePar/Test-decomposePar.C b/applications/test/decomposePar/Test-decomposePar.C index 7ad717f7421..c90b5b52d73 100644 --- a/applications/test/decomposePar/Test-decomposePar.C +++ b/applications/test/decomposePar/Test-decomposePar.C @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) const wordList& regions = iter(); forAll(regions, i) { - if (findIndex(regionNames, regions[i]) == -1) + if (!regionNames.found(regions[i])) { regionNames.append(regions[i]); } diff --git a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C index 0a2434e987d..d6a7cffa96e 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C +++ b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C @@ -97,7 +97,7 @@ Foam::label Foam::cellSplitter::newOwner const cell& cFaces = mesh_.cells()[oldOwn]; - return newCells[findIndex(cFaces, facei)]; + return newCells[cFaces.find(facei)]; } } @@ -125,7 +125,7 @@ Foam::label Foam::cellSplitter::newNeighbour const cell& cFaces = mesh_.cells()[oldNbr]; - return newCells[findIndex(cFaces, facei)]; + return newCells[cFaces.find(facei)]; } } @@ -261,8 +261,8 @@ void Foam::cellSplitter::setRefinement // (since newly created cells are stored in cFaces order) const labelList& newCells = cellToCells[celli]; - label cell0 = newCells[findIndex(cFaces, face0)]; - label cell1 = newCells[findIndex(cFaces, face1)]; + label cell0 = newCells[cFaces.find(face0)]; + label cell1 = newCells[cFaces.find(face1)]; if (cell0 < cell1) { @@ -271,7 +271,7 @@ void Foam::cellSplitter::setRefinement const face& f0 = mesh_.faces()[face0]; - label index = findIndex(f0, e[0]); + label index = f0.find(e[0]); bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]); @@ -317,7 +317,7 @@ void Foam::cellSplitter::setRefinement const face& f1 = mesh_.faces()[face1]; - label index = findIndex(f1, e[0]); + label index = f1.find(e[0]); bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]); diff --git a/applications/utilities/mesh/advanced/splitCells/splitCells.C b/applications/utilities/mesh/advanced/splitCells/splitCells.C index aecc10d2a1c..8cc704243da 100644 --- a/applications/utilities/mesh/advanced/splitCells/splitCells.C +++ b/applications/utilities/mesh/advanced/splitCells/splitCells.C @@ -225,8 +225,8 @@ bool splitHex const face& f = faces[facei]; - label fp0 = findIndex(f, e[0]); - label fp1 = findIndex(f, e[1]); + label fp0 = f.find(e[0]); + label fp1 = f.find(e[1]); if (fp0 == -1) { diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index cf878490790..ac8a33bcabd 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -136,7 +136,7 @@ label findFace(const primitivePatch& pp, const labelList& meshF) forAll(f, fp) { - if (findIndex(meshF, f[fp]) != -1) + if (meshF.found(f[fp])) { nMatched++; } @@ -168,7 +168,7 @@ label findInternalFace(const primitiveMesh& mesh, const labelList& meshF) forAll(f, fp) { - if (findIndex(meshF, f[fp]) != -1) + if (meshF.found(f[fp])) { nMatched++; } diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 0309bd6c747..7e09194c379 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -806,7 +806,7 @@ int main(int argc, char *argv[]) ) ); - if (findIndex(foamVerts, -1) != -1) + if (foamVerts.found(-1)) { FatalErrorInFunction << "Cell " << celli @@ -825,7 +825,7 @@ int main(int argc, char *argv[]) { labelList foamVerts(renumber(unvToFoam, boundaryFaces[bFacei])); - if (findIndex(foamVerts, -1) != -1) + if (foamVerts.found(-1)) { FatalErrorInFunction << "Boundary face " << bFacei diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C index fbcfe5c9082..5ba1afc722b 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C @@ -29,7 +29,7 @@ License bool Foam::extrudedMesh::sameOrder(const face& f, const edge& e) { - label i = findIndex(f, e[0]); + label i = f.find(e[0]); label nextI = (i == f.size()-1 ? 0 : i+1); diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index 2bbbf4a9f93..c36844e47dd 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -464,7 +464,7 @@ public: { forAll(y, yi) { - if (findIndex(x, y[yi]) == -1) + if (!x.found(y[yi])) { label sz = x.size(); x.setSize(sz+1); @@ -2488,14 +2488,14 @@ int main(int argc, char *argv[]) if (isA<mappedWallPolyPatch>(pp)) { - if (findIndex(interRegionTopPatch, patchi) != -1) + if (interRegionTopPatch.found(patchi)) { - label zoneI = findIndex(interRegionTopPatch, patchi); + label zoneI = interRegionTopPatch.find(patchi); topOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp); } - else if (findIndex(interRegionBottomPatch, patchi) != -1) + else if (interRegionBottomPatch.found(patchi)) { - label zoneI = findIndex(interRegionBottomPatch, patchi); + label zoneI = interRegionBottomPatch.find(patchi); bottomOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp); } } diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C index 20ebc345168..dc6a68444fc 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C @@ -45,7 +45,7 @@ void Foam::patchToPoly2DMesh::flipFaceOrder() const face& f = localFaces[edgeOwner]; - label fp = findIndex(f, e[0]); + label fp = f.find(e[0]); if (f.nextLabel(fp) != e[1]) { @@ -207,7 +207,7 @@ void Foam::patchToPoly2DMesh::addPatchFacesToOwner() { const face& f = faces[owner_[bEdgeI]]; - label fp = findIndex(f, e[0]); + label fp = f.find(e[0]); newOwner[bFacei] = owner_[bEdgeI]; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 141f36b9337..cc87adcb702 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -660,7 +660,7 @@ Foam::face Foam::conformalVoronoiMesh::buildDualFace if (cc1I != cc2I) { - if (findIndex(verticesOnFace, cc1I) == -1) + if (!verticesOnFace.found(cc1I)) { nUniqueVertices++; } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index eb3ab47806c..97e07605575 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -2119,8 +2119,8 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches patchIndex = max ( - findIndex(procNeighbours, vA->procIndex()), - findIndex(procNeighbours, vB->procIndex()) + procNeighbours.find(vA->procIndex()), + procNeighbours.find(vB->procIndex()) ); // The lower processor index is the owner of the diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index 929eeb306b3..7f458dbed69 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -465,12 +465,12 @@ inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached forAll(c1Procs, aPI) { - if (findIndex(procsAttached, c1Procs[aPI] == -1)) + if (!procsAttached.found(c1Procs[aPI])) { procsAttached.append(c1Procs[aPI]); } - if (findIndex(procsAttached, c2Procs[aPI] == -1)) + if (!procsAttached.found(c2Procs[aPI])) { procsAttached.append(c2Procs[aPI]); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index ea6efff4f52..c589f071d85 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -306,7 +306,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance) // )() // ); // -// label pointi = findIndex(pointDualAddressing, -1); +// label pointi = pointDualAddressing.find(-1); // if (pointi != -1) // { // WarningInFunction diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C index 99f28712983..1f42b3e429d 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C @@ -471,7 +471,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones // a faceZone if (surfHit.size() == 1 && surfHit[0].hit()) { - if (findIndex(unclosedSurfaces, hitSurface[0]) != -1) + if (unclosedSurfaces.found(hitSurface[0])) { vectorField norm; geometryToConformTo().getNormal diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C index 0e8d4963a56..1e198578e90 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C @@ -43,7 +43,7 @@ void Foam::shortEdgeFilter2D::addRegion { bPointRegions.append(regionI); } - else if (findIndex(bPointRegions, regionI) == -1) + else if (!bPointRegions.found(regionI)) { bPointRegions.append(regionI); } diff --git a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C index e813382bbec..b90b4e28128 100644 --- a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C +++ b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) while (true) { // Find first unset face. - label unsetFacei = findIndex(patchIDs, -1); + label unsetFacei = patchIDs.find(-1); if (unsetFacei == -1) { diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C index 01c5f5b3f1d..52198fb3053 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C @@ -137,7 +137,7 @@ Foam::label Foam::meshDualiser::findDualCell } else { - label index = findIndex(mesh_.pointCells()[pointi], celli); + label index = mesh_.pointCells()[pointi].find(celli); return dualCells[index]; } @@ -421,7 +421,7 @@ void Foam::meshDualiser::createFacesAroundEdge } if (faceToDualPoint_[ie.faceLabel()] != -1) { - doneEFaces[findIndex(eFaces, ie.faceLabel())] = true; + doneEFaces[eFaces.find(ie.faceLabel())] = true; verts.append(faceToDualPoint_[ie.faceLabel()]); } if (cellToDualPoint_[ie.cellLabel()] != -1) @@ -439,7 +439,7 @@ void Foam::meshDualiser::createFacesAroundEdge label facei = ie.faceLabel(); // Mark face as visited. - doneEFaces[findIndex(eFaces, facei)] = true; + doneEFaces[eFaces.find(facei)] = true; if (faceToDualPoint_[facei] != -1) { @@ -513,7 +513,7 @@ void Foam::meshDualiser::createFacesAroundEdge { label startDual = faceToDualPoint_[startFaceLabel]; - if (startDual != -1 && findIndex(verts, startDual) == -1) + if (startDual != -1 && !verts.found(startDual)) { verts.append(startDual); } @@ -666,7 +666,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint while (true) { - label index = findIndex(pFaces, facei-pp.start()); + label index = pFaces.find(facei-pp.start()); // Has face been visited already? if (donePFaces[index]) @@ -682,7 +682,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint // Get the edge before the patchPointi const face& f = mesh_.faces()[facei]; - label fp = findIndex(f, pointi); + label fp = f.find(pointi); label prevFp = f.rcIndex(fp); label edgeI = mesh_.faceEdges()[facei][prevFp]; @@ -763,7 +763,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint // Find edge between pointi and next point on face. const labelList& fEdges = mesh_.faceEdges()[facei]; - label nextEdgeI = fEdges[findIndex(mesh_.faces()[facei], pointi)]; + label nextEdgeI = fEdges[mesh_.faces()[facei].find(pointi)]; if (edgeToDualPoint_[nextEdgeI] != -1) { verts.append(edgeToDualPoint_[nextEdgeI]); @@ -771,7 +771,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint do { - label index = findIndex(pFaces, facei-pp.start()); + label index = pFaces.find(facei-pp.start()); // Has face been visited already? if (donePFaces[index]) @@ -786,7 +786,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint // Find edge before pointi on facei const labelList& fEdges = mesh_.faceEdges()[facei]; const face& f = mesh_.faces()[facei]; - label prevFp = f.rcIndex(findIndex(f, pointi)); + label prevFp = f.rcIndex(f.find(pointi)); label edgeI = fEdges[prevFp]; if (edgeToDualPoint_[edgeI] != -1) @@ -912,7 +912,7 @@ void Foam::meshDualiser::setRefinement { featureFaceSet[featureFaces[i]] = true; } - label facei = findIndex(featureFaceSet, false); + label facei = featureFaceSet.find(false); if (facei != -1) { @@ -929,7 +929,7 @@ void Foam::meshDualiser::setRefinement { featureEdgeSet[featureEdges[i]] = true; } - label edgeI = findIndex(featureEdgeSet, false); + label edgeI = featureEdgeSet.find(false); if (edgeI != -1) { diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index 0e1f3c253c7..14692cac4c2 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -1574,7 +1574,7 @@ int main(int argc, char *argv[]) << " This requires all" << " cells to be in one and only one cellZone." << nl << endl; - label unzonedCelli = findIndex(zoneID, -1); + label unzonedCelli = zoneID.find(-1); if (unzonedCelli != -1) { FatalErrorInFunction @@ -1623,7 +1623,7 @@ int main(int argc, char *argv[]) labelList newNeiZoneID(mesh.nFaces()-mesh.nInternalFaces()); getZoneID(mesh, newCellZones, newZoneID, newNeiZoneID); - label unzonedCelli = findIndex(newZoneID, -1); + label unzonedCelli = newZoneID.find(-1); if (unzonedCelli != -1) { FatalErrorInFunction diff --git a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C index 7a8e25a5b64..f405e232ffe 100644 --- a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C +++ b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C @@ -179,7 +179,7 @@ class uniqueEqOp } forAll(y, i) { - if (!y[i].empty() && findIndex(x, y[i]) == -1) + if (!y[i].empty() && !x.found(y[i])) { newX[n++] = y[i]; } diff --git a/applications/utilities/miscellaneous/patchSummary/patchSummary.C b/applications/utilities/miscellaneous/patchSummary/patchSummary.C index 6eb763747fe..b5ebfe0806c 100644 --- a/applications/utilities/miscellaneous/patchSummary/patchSummary.C +++ b/applications/utilities/miscellaneous/patchSummary/patchSummary.C @@ -173,7 +173,7 @@ int main(int argc, char *argv[]) collectFieldList(psytf, patchi, fieldToType); collectFieldList(ptf, patchi, fieldToType); - label groupI = findIndex(fieldToTypes, fieldToType); + label groupI = fieldToTypes.find(fieldToType); if (groupI == -1) { DynamicList<label> group(1); diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index b1d04b6d9ba..50a70387ee6 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -306,7 +306,7 @@ int main(int argc, char *argv[]) const wordList& regions = iter(); forAll(regions, i) { - if (findIndex(regionNames, regions[i]) == -1) + if (!regionNames.found(regions[i])) { regionNames.append(regions[i]); } diff --git a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C index 98457dc2b4e..b475216f273 100644 --- a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C +++ b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C @@ -67,11 +67,8 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer const indexedParticle& ppi = *iter(); particleIndices_[pi++] = ppi.index(); - label mappedTetFace = findIndex - ( - decodedProcFaceAddressing, - ppi.tetFace() - ); + const label mappedTetFace = + decodedProcFaceAddressing.find(ppi.tetFace()); if (mappedTetFace == -1) { diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 131598746a7..efc5f9b0f35 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -189,7 +189,7 @@ int main(int argc, char *argv[]) const wordList& regions = iter(); forAll(regions, i) { - if (findIndex(regionNames, regions[i]) == -1) + if (!regionNames.found(regions[i])) { regionNames.append(regions[i]); } diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C index e35562b6951..ed6c7579b25 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C @@ -105,7 +105,7 @@ void Foam::parLagrangianRedistributor::findClouds // One of the objects is coordinates/positions so must be valid // cloud - label cloudI = findIndex(cloudNames, localCloudDirs[i]); + label cloudI = cloudNames.find(localCloudDirs[i]); objectNames[cloudI].setSize(sprayObjs.size()); label objectI = 0; diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index ca116ce38e5..e0ba52f7a7d 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -857,7 +857,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite // processors autoPtr<fvMeshSubset> subsetterPtr; - const bool allHaveMesh = (findIndex(haveMesh, false) == -1); + const bool allHaveMesh = !haveMesh.found(false); if (!allHaveMesh) { // Find last non-processor patch. diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C index 317010c0de2..3475cb24cf6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C @@ -412,7 +412,7 @@ void Foam::tecplotWriter::writeConnectivity // The face that uses the vertices of e in increasing order // is the left face. - const label fp = findIndex(f0, e[0]); + const label fp = f0.find(e[0]); const bool f0IsLeft = (f0.nextLabel(fp) == e[1]); if (f0IsLeft) diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index 62442c9ca39..c6ef4bd6ff9 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -206,7 +206,7 @@ labelList findMatches const wordList& keys = shortcuts[name]; forAll(keys, j) { - label index = findIndex(thisKeys, keys[j]); + label index = thisKeys.find(keys[j]); if (index != -1) { matches.append(index); diff --git a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C index 6dca6415bff..6588632eb9e 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C +++ b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C @@ -416,7 +416,7 @@ void visitPointRegion - label index = findIndex(s.pointFaces()[pointI], nextFaceI); + label index = s.pointFaces()[pointI].find(nextFaceI); if (pFacesZone[index] == -1) { diff --git a/applications/utilities/surface/surfaceClean/collapseBase.C b/applications/utilities/surface/surfaceClean/collapseBase.C index 17152e6a91f..a1037613978 100644 --- a/applications/utilities/surface/surfaceClean/collapseBase.C +++ b/applications/utilities/surface/surfaceClean/collapseBase.C @@ -99,7 +99,7 @@ static void splitTri { //label oldNTris = tris.size(); - label fp = findIndex(f, e[0]); + label fp = f.find(e[0]); label fp1 = f.fcIndex(fp); label fp2 = f.fcIndex(fp1); @@ -204,7 +204,7 @@ static bool insertSorted scalarField& sortedWeights ) { - if (findIndex(sortedVerts, vertI) != -1) + if (sortedVerts.found(vertI)) { FatalErrorInFunction << " which is already in list of sorted vertices " @@ -562,7 +562,7 @@ static labelListList getOutsideVerts { label v = e[eI]; - if (findIndex(regionVerts, v) == -1) + if (!regionVerts.found(v)) { label sz = regionVerts.size(); regionVerts.setSize(sz+1); @@ -682,7 +682,7 @@ static void getSplitVerts else { // Copy upto (but not including) e[1] - label i1 = findIndex(orderedVerts, e[1]); + label i1 = orderedVerts.find(e[1]); splitVerts = SubList<label>(orderedVerts, i1, 0); splitWeights = SubList<scalar>(orderedWeights, i1, 0); } @@ -703,7 +703,7 @@ static void getSplitVerts { // Copy downto (but not including) e[1] - label i1 = findIndex(orderedVerts, e[1]); + label i1 = orderedVerts.find(e[1]); splitVerts = SubList<label>(orderedVerts, sz-(i1+1), i1+1); reverse(splitVerts); splitWeights = SubList<scalar>(orderedWeights, sz-(i1+1), i1+1); @@ -716,7 +716,7 @@ static void getSplitVerts // Copy upto (but not including) e[0] - label i0 = findIndex(orderedVerts, e[0]); + label i0 = orderedVerts.find(e[0]); splitVerts = SubList<label>(orderedVerts, i0, 0); reverse(splitVerts); splitWeights = SubList<scalar>(orderedWeights, i0, 0); @@ -726,14 +726,14 @@ static void getSplitVerts { // Copy from (but not including) e[0] to end - label i0 = findIndex(orderedVerts, e[0]); + label i0 = orderedVerts.find(e[0]); splitVerts = SubList<label>(orderedVerts, sz-(i0+1), i0+1); splitWeights = SubList<scalar>(orderedWeights, sz-(i0+1), i0+1); } else { - label i0 = findIndex(orderedVerts, e[0]); - label i1 = findIndex(orderedVerts, e[1]); + label i0 = orderedVerts.find(e[0]); + label i1 = orderedVerts.find(e[1]); if (i0 == -1 || i1 == -1) { diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C index 57351df046e..4b8dbe71473 100644 --- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C +++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C @@ -63,7 +63,7 @@ void greenRefine // Find index of edge in face. - label fp0 = findIndex(f, e[0]); + label fp0 = f.find(e[0]); label fp1 = f.fcIndex(fp0); label fp2 = f.fcIndex(fp1); @@ -235,16 +235,11 @@ public: { const treeDataEdge& shape = tree_.shapes(); - forAll(indices, i) + for (const label index : indices) { - const label index = indices[i]; const label edgeIndex = shape.edgeLabels()[index]; - if - ( - !shapeMask_.empty() - && findIndex(shapeMask_, edgeIndex) != -1 - ) + if (shapeMask_.found(edgeIndex)) { continue; } @@ -256,7 +251,7 @@ public: // Only register hit if closest point is not an edge point if (nearHit.hit()) { - scalar distSqr = sqr(nearHit.distance()); + const scalar distSqr = sqr(nearHit.distance()); if (distSqr < nearestDistSqr) { diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C index 3cfdb743bed..fe34422582d 100644 --- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C +++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C @@ -70,7 +70,7 @@ scalar calcVertexNormalWeight const pointField& points ) { - label index = findIndex(f, pI); + label index = f.find(pI); if (index == -1) { @@ -292,7 +292,7 @@ label detectIntersectionPoints if ( hits[pointI].hit() - && findIndex(localFaces[hits[pointI].index()], pointI) == -1 + && !localFaces[hits[pointI].index()].found(pointI) ) { scale[pointI] = max(0.0, scale[pointI]-0.2); diff --git a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C index 47a83a09f22..d844e0bb631 100644 --- a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C +++ b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C @@ -154,14 +154,14 @@ void testSortedEdgeFaces(const triSurface& surf) forAll(myFaces, i) { - if (findIndex(sortMyFaces, myFaces[i]) == -1) + if (!sortMyFaces.found(myFaces[i])) { FatalErrorInFunction << abort(FatalError); } } forAll(sortMyFaces, i) { - if (findIndex(myFaces, sortMyFaces[i]) == -1) + if (!myFaces.found(sortMyFaces[i])) { FatalErrorInFunction << abort(FatalError); } @@ -460,7 +460,7 @@ label sharedFace const triSurface::FaceType& f = surf.localFaces()[firstFacei]; - label startIndex = findIndex(f, e.start()); + label startIndex = f.find(e.start()); // points in face in same order as edge bool edgeOrder = (f[f.fcIndex(startIndex)] == e.end()); @@ -471,7 +471,7 @@ label sharedFace const labelList& eFaces = surf.sortedEdgeFaces()[sharedEdgeI]; // Get position of face in sorted edge faces - label faceIndex = findIndex(eFaces, firstFacei); + label faceIndex = eFaces.find(firstFacei); if (edgeOrder) { diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index c3a6406da9e..98267e1c415 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -246,6 +246,7 @@ labelList identity(const label len); //- Find first occurence of given element and return index, // return -1 if not found. Linear search. +// \deprecated prefer UList find/found methods (deprecated Oct 2017) template<class ListType> label findIndex ( diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index a55b8c714cd..45f28b9ef9b 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -858,7 +858,7 @@ void Foam::ListUniqueEqOp<T>::operator()(List<T>& x, const List<T>& y) const { forAll(y, i) { - if (findIndex(x, y[i]) == -1) + if (!x.found(y[i])) { x.append(y[i]); } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index 9258fbf637a..24cf28a27f9 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -240,12 +240,12 @@ std::streamsize Foam::UList<T>::byteSize() const template<class T> Foam::label Foam::UList<T>::find(const T& val, const label start) const { - if (start >= 0) + const label len = this->size(); + + if (start >= 0 && len) { List_CONST_ACCESS(T, (*this), vp); - const label len = this->size(); - for (label i = start; i < len; ++i) { if (vp[i] == val) @@ -264,17 +264,10 @@ Foam::label Foam::UList<T>::rfind(const T& val, const label pos) const { List_CONST_ACCESS(T, (*this), vp); - for - ( - label i = - ( - pos < 0 - ? (this->size()-1) - : min(pos, this->size()-1) - ); - i >= 0; - --i - ) + const label len1 = (this->size()-1); + + // pos == -1 has same meaning as std::string::npos - search from end + for (label i = ((pos >= 0 && pos < len1) ? pos : len1); i >= 0; --i) { if (vp[i] == val) { diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index fcdbd7c0da0..19257b6b551 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -252,16 +252,19 @@ public: //- Find index of the first occurence of the value. // When start is specified, any occurences before start are ignored. // Linear search. - // \return -1 if not found. + // \return position in list or -1 if not found. label find(const T& val, const label start=0) const; //- Find index of the last occurence of the value. // When pos is specified, any occurences after pos are ignored. // Linear search. - // \return -1 if not found. + // \return position in list or -1 if not found. label rfind(const T& val, const label pos=-1) const; - //- True if the value if found in the list. Linear search. + //- True if the value if found in the list. + // When start is specified, any occurences before start are ignored. + // Linear search. + // \return true if found. inline bool found(const T& val, const label start=0) const; diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C index 6e460ff9f96..3f6d1c5ec9f 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C @@ -93,7 +93,7 @@ Foam::label Foam::unwatchedIOdictionary::addWatch(const fileName& f) if (readOpt() == MUST_READ_IF_MODIFIED) { - index = findIndex(files_, f); + index = files_.find(f); if (index == -1) { @@ -117,7 +117,7 @@ void Foam::unwatchedIOdictionary::addWatch() f = objectPath(); } - if (findIndex(files_, f) != -1) + if (files_.found(f)) { FatalErrorInFunction << "Object " << objectPath() << " of type " << type() diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C index 9bd97a13499..4c72c28cc20 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C @@ -219,12 +219,12 @@ Foam::label Foam::UPstream::procNo(const label myComm, const int baseProcID) if (parentComm == -1) { - return findIndex(parentRanks, baseProcID); + return parentRanks.find(baseProcID); } else { - label parentRank = procNo(parentComm, baseProcID); - return findIndex(parentRanks, parentRank); + const label parentRank = procNo(parentComm, baseProcID); + return parentRanks.find(parentRank); } } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C index 321e8f3d3df..4e402464c31 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C @@ -704,11 +704,9 @@ void Foam::GAMGAgglomeration::calculateRegionMaster // processor agglomProcIDs = findIndices(procAgglomMap, myAgglom); // Make sure the master is the first element. - label index = findIndex - ( - agglomProcIDs, - agglomToMaster[myAgglom] - ); + const label index = + agglomProcIDs.find(agglomToMaster[myAgglom]); + Swap(agglomProcIDs[0], agglomProcIDs[index]); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C index 5095e2be6f8..ee20d9b461b 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C @@ -634,7 +634,7 @@ bool Foam::GAMGAgglomeration::checkRestriction { labelList& masters = coarseToMasters[restrict[celli]]; - if (findIndex(masters, master[celli]) == -1) + if (!masters.found(master[celli])) { masters.append(master[celli]); nNewCoarse++; @@ -672,7 +672,7 @@ bool Foam::GAMGAgglomeration::checkRestriction { label coarseI = restrict[celli]; - label index = findIndex(coarseToMasters[coarseI], master[celli]); + label index = coarseToMasters[coarseI].find(master[celli]); newRestrict[celli] = coarseToNewCoarse[coarseI][index]; } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C index 4c64f2dbfae..21cb8365d54 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C @@ -133,11 +133,8 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate() procAgglomMap[cluster[i]] = coarseI; } - label masterIndex = findIndex - ( - cluster, - coarseToMaster[coarseI] - ); + const label masterIndex = + cluster.find(coarseToMaster[coarseI]); if (masterIndex == -1) { @@ -150,7 +147,7 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate() << exit(FatalError); } - if (findIndex(cluster, myProcID) != -1) + if (cluster.found(myProcID)) { // This is my cluster. Make sure master index is // first @@ -161,12 +158,12 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate() // Check that we've done all processors - if (findIndex(procAgglomMap, -1) != -1) + if (procAgglomMap.found(-1)) { FatalErrorInFunction << "At level " << fineLevelIndex << " processor " - << findIndex(procAgglomMap, -1) + << procAgglomMap.find(-1) << " is not in any cluster" << exit(FatalError); } diff --git a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C index e68137a628f..0f9a8c11143 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C @@ -82,7 +82,7 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID return -1; } - label index = findIndex(patchIDs, thisPatch.index()); + label index = patchIDs.find(thisPatch.index()); if (index == -1) { diff --git a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C index c535e5b0bf6..274549fb3c7 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C @@ -82,7 +82,7 @@ Foam::patchIdentifier::~patchIdentifier() bool Foam::patchIdentifier::inGroup(const word& name) const { - return findIndex(inGroups_, name) != -1; + return inGroups_.found(name); } diff --git a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C index bdd63ab0356..3475700bc92 100644 --- a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C +++ b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C @@ -426,11 +426,8 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh << endl; } - label nbrProcMeshI = findIndex - ( - procIDs, - pldui.neighbProcNo() - ); + const label nbrProcMeshI = + procIDs.find(pldui.neighbProcNo()); if (procMeshI < nbrProcMeshI) { @@ -625,7 +622,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh // Look up corresponding interfaces label myP = pldui.myProcNo(); label nbrP = pldui.neighbProcNo(); - label nbrProcMeshI = findIndex(procIDs, nbrP); + label nbrProcMeshI = procIDs.find(nbrP); if (procMeshI < nbrProcMeshI) { @@ -1052,7 +1049,7 @@ void Foam::lduPrimitiveMesh::gather ); } } - else if (findIndex(procIDs, Pstream::myProcNo(comm)) != -1) + else if (procIDs.found(Pstream::myProcNo(comm))) { // Send to master diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 81dbaf798d8..8a693b037ac 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -1395,10 +1395,9 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const // Add all slaveBFaces. Note that need to check for // uniqueness only in case of cyclics. - forAll(slaveBFaces, j) + for (const label slave : slaveBFaces) { - label slave = slaveBFaces[j]; - if (findIndex(SubList<label>(myBFaces, sz), slave) == -1) + if (!SubList<label>(myBFaces, sz).found(slave)) { myBFaces[n++] = slave; } @@ -1434,11 +1433,10 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const const labelList& slaveBFaces = globalPointBoundaryFaces[transformedSlaves[i]]; - forAll(slaveBFaces, j) + for (const label slave : slaveBFaces) { - label slave = slaveBFaces[j]; // Check that same face not already present untransformed - if (findIndex(untrafoFaces, slave)== -1) + if (!untrafoFaces.found(slave)) { label proci = globalIndices.whichProcID(slave); label facei = globalIndices.toLocal(proci, slave); @@ -1624,10 +1622,9 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const // Add all slaveBCells. Note that need to check for // uniqueness only in case of cyclics. - forAll(slaveBCells, j) + for (const label slave : slaveBCells) { - label slave = slaveBCells[j]; - if (findIndex(SubList<label>(myBCells, sz), slave) == -1) + if (!SubList<label>(myBCells, sz).found(slave)) { myBCells[n++] = slave; } @@ -1663,12 +1660,10 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const const labelList& slaveBCells = globalPointBoundaryCells[transformedSlaves[i]]; - forAll(slaveBCells, j) + for (const label slave : slaveBCells) { - label slave = slaveBCells[j]; - // Check that same cell not already present untransformed - if (findIndex(untrafoCells, slave)== -1) + if (!untrafoCells.found(slave)) { label proci = globalIndices.whichProcID(slave); label celli = globalIndices.toLocal(proci, slave); diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C index 2cace80f4b5..9ddd3502634 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C @@ -138,20 +138,18 @@ void Foam::globalPoints::addToSend // information is the patch faces using the point and the relative position // of the point in the face) - label meshPointi = pp.meshPoints()[patchPointi]; + const label meshPointi = pp.meshPoints()[patchPointi]; // Add all faces using the point so we are sure we find it on the // other side. const labelList& pFaces = pp.pointFaces()[patchPointi]; - forAll(pFaces, i) + for (const label patchFacei : pFaces) { - label patchFacei = pFaces[i]; - const face& f = pp[patchFacei]; patchFaces.append(patchFacei); - indexInFace.append(findIndex(f, meshPointi)); + indexInFace.append(f.find(meshPointi)); // Add patch transformation allInfo.append(addSendTransform(pp.index(), knownInfo)); diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C index fce5b416c3c..67c436c4b89 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C @@ -89,7 +89,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule forAll(nbrData, i) { - if (findIndex(allComms, nbrData[i]) == -1) + if (!allComms.found(nbrData[i])) { label sz = allComms.size(); allComms.setSize(sz+1); diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 32ad8ee6344..b0bfc8d5857 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -163,12 +163,12 @@ public: //- Return patch indices for all matches. Optionally matches patchGroups labelList findIndices ( - const keyType&, + const keyType& key, const bool usePatchGroups = true ) const; //- Return patch index for the first match, return -1 if not found - label findIndex(const keyType&) const; + label findIndex(const keyType& key) const; //- Find patch index given a name label findPatchID diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index 5603bda172b..65eeb613a44 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -593,7 +593,7 @@ Foam::polyMesh::polyMesh // Check if there already exists a defaultFaces patch as last patch // and reuse it. - label patchi = findIndex(boundaryPatchNames, defaultBoundaryPatchName); + label patchi = boundaryPatchNames.find(defaultBoundaryPatchName); if (patchi != -1) { @@ -866,7 +866,7 @@ Foam::polyMesh::polyMesh // Check if there already exists a defaultFaces patch as last patch // and reuse it. - label patchi = findIndex(boundaryPatchNames, defaultBoundaryPatchName); + label patchi = boundaryPatchNames.find(defaultBoundaryPatchName); if (patchi != -1) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index bf58d1a4074..0ad36956cbd 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -362,7 +362,7 @@ void Foam::processorPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) const face& f = localFaces()[facei]; - pointIndex[patchPointi] = findIndex(f, patchPointi); + pointIndex[patchPointi] = f.find(patchPointi); } // Express all edges as patch face and index in face. @@ -377,7 +377,7 @@ void Foam::processorPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) const labelList& fEdges = faceEdges()[facei]; - edgeIndex[patchEdgeI] = findIndex(fEdges, patchEdgeI); + edgeIndex[patchEdgeI] = fEdges.find(patchEdgeI); } UOPstream toNeighbProc(neighbProcNo(), pBufs); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C index 9263609ee5c..d4ddce3424e 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C @@ -51,7 +51,7 @@ Foam::wallPolyPatch::wallPolyPatch polyPatch(name, size, start, index, bm, patchType) { // wall is not constraint type so add wall group explicitly - if (findIndex(inGroups(), typeName) == -1) + if (!inGroups().found(typeName)) { inGroups().append(typeName); } @@ -70,7 +70,7 @@ Foam::wallPolyPatch::wallPolyPatch polyPatch(name, dict, index, bm, patchType) { // wall is not constraint type so add wall group explicitly - if (findIndex(inGroups(), typeName) == -1) + if (!inGroups().found(typeName)) { inGroups().append(typeName); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index bd14deffc6b..1494fb273d5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -99,7 +99,7 @@ Foam::polyPatch::polyPatch ( patchType != word::null && constraintType(patchType) - && findIndex(inGroups(), patchType) == -1 + && !inGroups().found(patchType) ) { inGroups().append(patchType); @@ -160,7 +160,7 @@ Foam::polyPatch::polyPatch ( patchType != word::null && constraintType(patchType) - && findIndex(inGroups(), patchType) == -1 + && !inGroups().found(patchType) ) { inGroups().append(patchType); diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C index 784b78bb44f..2c6d4041717 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C @@ -128,7 +128,7 @@ Foam::PatchTools::sortedPointEdges { forAll(pEdges, eI) { - if (findIndex(newEdgeList, pEdges[eI]) == -1) + if (!newEdgeList.found(pEdges[eI])) { WarningInFunction << "Cannot find all original edges in the new list" diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C index 80cc44a3708..5780089ca30 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C @@ -50,7 +50,7 @@ visitPointRegion boolList& pFacesHad ) const { - label index = findIndex(pFaces, startFacei); + label index = pFaces.find(startFacei); if (!pFacesHad[index]) { @@ -267,7 +267,7 @@ checkPointManifold // After this all faces using pointi should have been visited and // marked off in pFacesHad. - label unset = findIndex(pFacesHad, false); + label unset = pFacesHad.find(false); if (unset != -1) { diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C index f130c8975bb..ed6589ac3a2 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C @@ -77,7 +77,7 @@ void Foam::primitiveMesh::calcCellEdges() const forAll(curEdges, edgeI) { - if (findIndex(curCellEdges, curEdges[edgeI]) == -1) + if (!curCellEdges.found(curEdges[edgeI])) { // Add the edge curCellEdges.append(curEdges[edgeI]); @@ -93,7 +93,7 @@ void Foam::primitiveMesh::calcCellEdges() const forAll(curEdges, edgeI) { - if (findIndex(curCellEdges, curEdges[edgeI]) == -1) + if (!curCellEdges.found(curEdges[edgeI])) { // add the edge curCellEdges.append(curEdges[edgeI]); diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C index 681024b48c8..57a7be528b1 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C @@ -1436,7 +1436,7 @@ bool Foam::primitiveMesh::checkCommonOrder forAll(curFace, fp) { // Get the index in the neighbouring face shared with curFace - label nb = findIndex(nbFace, curFace[fp]); + label nb = nbFace.find(curFace[fp]); if (nb != -1) { diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C index 01c7ec471c6..3cf689595ab 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C @@ -404,7 +404,7 @@ void Foam::primitiveMesh::calcEdges(const bool doFaceEdges) const if (debug) { - label edgeI = findIndex(oldToNew, -1); + label edgeI = oldToNew.find(-1); if (edgeI != -1) { diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C index f2551cfcd83..ade12336956 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C @@ -149,7 +149,7 @@ void Foam::walkPatch::faceToFace const face& f = pp_.localFaces()[facei]; - label fp = findIndex(f, enterVertI); + label fp = f.find(enterVertI); indexInFace_.append(fp); diff --git a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C index b6ca5a26efe..bebceaeeca4 100644 --- a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C +++ b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C @@ -404,7 +404,7 @@ bool Foam::globalIndexAndTransform::uniqueTransform const labelPair& patchTrafo ) const { - if (findIndex(trafos, patchTrafo) == -1) + if (!trafos.found(patchTrafo)) { // New transform. Check if already have 3 if (trafos.size() == 3) diff --git a/src/conversion/ccm/reader/ccmReaderMesh.C b/src/conversion/ccm/reader/ccmReaderMesh.C index 089b3f65bbd..d58016f768b 100644 --- a/src/conversion/ccm/reader/ccmReaderMesh.C +++ b/src/conversion/ccm/reader/ccmReaderMesh.C @@ -1120,7 +1120,7 @@ void Foam::ccm::reader::juggleSolids() // The corresponding Foam patch - const label patchIndex = findIndex(origBndId_, defaultBoundaryRegion); + const label patchIndex = origBndId_.find(defaultBoundaryRegion); const label nPatchFaces = patchSizes_[patchIndex]; labelList patchStarts(patchStartList(nInternalFaces_)); @@ -1828,8 +1828,8 @@ void Foam::ccm::reader::mergeInplaceInterfaces() labelPair patchPair ( - findIndex(origBndId_, ifentry.bnd0), - findIndex(origBndId_, ifentry.bnd1) + origBndId_.find(ifentry.bnd0), + origBndId_.find(ifentry.bnd1) ); if diff --git a/src/conversion/ccm/writer/ccmWriterMesh.C b/src/conversion/ccm/writer/ccmWriterMesh.C index 4ac3c621b82..7b3e275d42d 100644 --- a/src/conversion/ccm/writer/ccmWriterMesh.C +++ b/src/conversion/ccm/writer/ccmWriterMesh.C @@ -39,7 +39,7 @@ Foam::label Foam::ccm::writer::prostarCellFaceId const cellShape& shape = mesh_.cellShapes()[cellId]; const labelList& cFaces = mesh_.cells()[cellId]; - label cellFaceId = findIndex(cFaces, faceI); + label cellFaceId = cFaces.find(faceI); label mapIndex = shape.model().index(); if (ccm::debug > 1) diff --git a/src/conversion/polyDualMesh/polyDualMesh.C b/src/conversion/polyDualMesh/polyDualMesh.C index 8102547c4f9..04b26d29c0c 100644 --- a/src/conversion/polyDualMesh/polyDualMesh.C +++ b/src/conversion/polyDualMesh/polyDualMesh.C @@ -165,7 +165,7 @@ void Foam::polyDualMesh::getPointEdges if (e[0] == pointi) { // One of the edges using pointi. Check which one. - label index = findIndex(f, pointi); + label index = f.find(pointi); if (f.nextLabel(index) == e[1]) { @@ -184,7 +184,7 @@ void Foam::polyDualMesh::getPointEdges else if (e[1] == pointi) { // One of the edges using pointi. Check which one. - label index = findIndex(f, pointi); + label index = f.find(pointi); if (f.nextLabel(index) == e[0]) { @@ -929,7 +929,7 @@ void Foam::polyDualMesh::calcDual label startFacei = -1; label endFacei = -1; - label index = findIndex(f0, neighbour); + label index = f0.find(neighbour); if (f0.nextLabel(index) == owner) { @@ -1062,7 +1062,7 @@ void Foam::polyDualMesh::calcDual // the face uses the owner, neighbour const face& f0 = mesh.faces()[face0]; - label index = findIndex(f0, neighbour); + label index = f0.find(neighbour); bool f0OrderOk = (f0.nextLabel(index) == owner); diff --git a/src/conversion/starcd/STARCDMeshWriter.C b/src/conversion/starcd/STARCDMeshWriter.C index a2e6bdb1ffb..85cba78d595 100644 --- a/src/conversion/starcd/STARCDMeshWriter.C +++ b/src/conversion/starcd/STARCDMeshWriter.C @@ -380,7 +380,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary label cellId = owner[facei]; const labelList& cFaces = cells[cellId]; const cellShape& shape = shapes[cellId]; - label cellFaceId = findIndex(cFaces, facei); + label cellFaceId = cFaces.find(facei); // Info<< "cell " << cellId + 1 << " face " << facei // << " == " << faces[facei] diff --git a/src/dynamicMesh/createShellMesh/createShellMesh.C b/src/dynamicMesh/createShellMesh/createShellMesh.C index 300e7f03a39..76feaaf60a0 100644 --- a/src/dynamicMesh/createShellMesh/createShellMesh.C +++ b/src/dynamicMesh/createShellMesh/createShellMesh.C @@ -226,8 +226,8 @@ void Foam::createShellMesh::calcPointRegions label facei = patch.edgeFaces()[edgeI][0]; const face& f = patch.localFaces()[facei]; - label fp0 = findIndex(f, e[0]); - label fp1 = findIndex(f, e[1]); + label fp0 = f.find(e[0]); + label fp1 = f.find(e[1]); allEdgeData[edgeI] = labelPair ( pointGlobalRegions[facei][fp0], @@ -283,7 +283,7 @@ void Foam::createShellMesh::calcPointRegions const face& f = patch.localFaces()[facei]; // Combine edgeData with face data - label fp0 = findIndex(f, e[0]); + label fp0 = f.find(e[0]); if (pointGlobalRegions[facei][fp0] > edgeData[0]) { pointGlobalRegions[facei][fp0] = edgeData[0]; @@ -294,7 +294,7 @@ void Foam::createShellMesh::calcPointRegions } } - label fp1 = findIndex(f, e[1]); + label fp1 = f.find(e[1]); if (pointGlobalRegions[facei][fp1] > edgeData[1]) { pointGlobalRegions[facei][fp1] = edgeData[1]; @@ -334,9 +334,9 @@ void Foam::createShellMesh::calcPointRegions if (!nonManifoldEdge[edgeI]) { const edge& e = patch.edges()[edgeI]; - label fp0 = findIndex(f, e[0]); + label fp0 = f.find(e[0]); label region0 = pointGlobalRegions[facei][fp0]; - label fp1 = findIndex(f, e[1]); + label fp1 = f.find(e[1]); label region1 = pointGlobalRegions[facei][fp1]; if @@ -696,7 +696,7 @@ void Foam::createShellMesh::setRefinement const face& f = patch_.localFaces()[eFaces[0]]; const edge& e = patch_.edges()[edgeI]; - label fp0 = findIndex(f, e[0]); + label fp0 = f.find(e[0]); label fp1 = f.fcIndex(fp0); if (f[fp1] != e[1]) @@ -815,7 +815,7 @@ void Foam::createShellMesh::setRefinement const face& f = patch_.localFaces()[minFacei]; const edge& e = patch_.edges()[edgeI]; - label fp0 = findIndex(f, e[0]); + label fp0 = f.find(e[0]); label fp1 = f.fcIndex(fp0); if (f[fp1] != e[1]) diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C index 89245c0094c..0e546f1b3ef 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C @@ -656,7 +656,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::repatch if (debug) { - label index = findIndex(map().reverseFaceMap(), -1); + label index = map().reverseFaceMap().find(-1); if (index != -1) { diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C index 5e436c4544d..98347f981bb 100644 --- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C +++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C @@ -189,12 +189,12 @@ void Foam::cellCuts::syncProc() if (isEdge(cuts[i])) { label edgei = getEdge(cuts[i]); - label index = findIndex(fEdges, edgei); + label index = fEdges.find(edgei); relCuts[bFacei][i] = -index-1; } else { - label index = findIndex(f, getVertex(cuts[i])); + label index = f.find(getVertex(cuts[i])); relCuts[bFacei][i] = index+1; } } @@ -390,13 +390,9 @@ Foam::label Foam::cellCuts::edgeEdgeToFace const labelList& fEdges = mesh().faceEdges()[facei]; - if - ( - findIndex(fEdges, edgeA) != -1 - && findIndex(fEdges, edgeB) != -1 - ) + if (fEdges.found(edgeA) && fEdges.found(edgeB)) { - return facei; + return facei; } } @@ -432,13 +428,9 @@ Foam::label Foam::cellCuts::edgeVertexToFace const labelList& fEdges = mesh().faceEdges()[facei]; - if - ( - findIndex(fEdges, edgeI) != -1 - && findIndex(f, vertI) != -1 - ) + if (fEdges.found(edgeI) && f.found(vertI)) { - return facei; + return facei; } } @@ -469,13 +461,9 @@ Foam::label Foam::cellCuts::vertexVertexToFace const face& f = mesh().faces()[facei]; - if - ( - findIndex(f, vertA) != -1 - && findIndex(f, vertB) != -1 - ) + if (f.found(vertA) && f.found(vertB)) { - return facei; + return facei; } } @@ -677,7 +665,7 @@ Foam::label Foam::cellCuts::loopFace if (isEdge(cut)) { - if (findIndex(fEdges, getEdge(cut)) == -1) + if (!fEdges.found(getEdge(cut))) { // Edge not on face. Skip face. allOnFace = false; @@ -686,7 +674,7 @@ Foam::label Foam::cellCuts::loopFace } else { - if (findIndex(f, getVertex(cut)) == -1) + if (!f.found(getVertex(cut))) { // Vertex not on face. Skip face. allOnFace = false; @@ -1333,8 +1321,8 @@ Foam::labelList Foam::cellCuts::nonAnchorPoints if ( - findIndex(anchorPoints, pointi) == -1 - && findIndex(loop, vertToEVert(pointi)) == -1 + !anchorPoints.found(pointi) + && !loop.found(vertToEVert(pointi)) ) { newElems[newElemI++] = pointi; @@ -1826,7 +1814,7 @@ Foam::label Foam::cellCuts::countFaceCuts if ( pointIsCut_[vertI] - || (findIndex(loop, vertToEVert(vertI)) != -1) + || loop.found(vertToEVert(vertI)) ) { nCuts++; @@ -1844,7 +1832,7 @@ Foam::label Foam::cellCuts::countFaceCuts if ( edgeIsCut_[edgeI] - || (findIndex(loop, edgeToEVert(edgeI)) != -1) + || loop.found(edgeToEVert(edgeI)) ) { nCuts++; @@ -2764,7 +2752,7 @@ void Foam::cellCuts::check() const if ( !isEdge(cut) - && findIndex(anchors, getVertex(cut)) != -1 + && anchors.found(getVertex(cut)) ) { FatalErrorInFunction diff --git a/src/dynamicMesh/meshCut/cellLooper/cellLooper.C b/src/dynamicMesh/meshCut/cellLooper/cellLooper.C index 93455382666..45918f8283b 100644 --- a/src/dynamicMesh/meshCut/cellLooper/cellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/cellLooper.C @@ -148,7 +148,7 @@ Foam::labelList Foam::cellLooper::getVertEdgesNonFace if ( - (findIndex(exclEdges, edgeI) == -1) + !exclEdges.found(edgeI) && meshTools::edgeOnCell(mesh(), celli, edgeI) ) { diff --git a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C index 6e0a010cdaf..5528d9dad53 100644 --- a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C @@ -363,7 +363,7 @@ bool Foam::geomCellLooper::cut // endpoint so only insert if unique. label cut = vertToEVert(cutVertI); - if (findIndex(localLoop, cut) == -1) + if (!localLoop.found(cut)) { localLoop.append(vertToEVert(cutVertI)); localLoopWeights.append(-GREAT); diff --git a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C index 70a1347169b..b7637869d60 100644 --- a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C @@ -407,17 +407,8 @@ void Foam::topoCellLooper::walkSplitHex if ( - (vertI != -1) - && ( - (startLoop = - findIndex - ( - loop, - vertToEVert(vertI) - ) - ) - != -1 - ) + vertI != -1 + && (startLoop = loop.find(vertToEVert(vertI))) != -1 ) { // Breaking walk since vertI already cut @@ -430,17 +421,8 @@ void Foam::topoCellLooper::walkSplitHex } if ( - (edgeI != -1) - && ( - (startLoop = - findIndex - ( - loop, - edgeToEVert(edgeI) - ) - ) - != -1 - ) + edgeI != -1 + && (startLoop = loop.find(edgeToEVert(edgeI))) != -1 ) { // Breaking walk since edgeI already cut diff --git a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C index 3ef151d7396..253945632ce 100644 --- a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C +++ b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C @@ -115,8 +115,8 @@ Foam::label Foam::directionInfo::edgeToFaceIndex // - connected (but not in) to face. Return -1. // - in face opposite facei. Convert into index in face. - label fpA = findIndex(f, e.start()); - label fpB = findIndex(f, e.end()); + label fpA = f.find(e.start()); + label fpB = f.find(e.end()); if (fpA != -1) { @@ -158,8 +158,8 @@ Foam::label Foam::directionInfo::edgeToFaceIndex const edge& e0 = mesh.edges()[edge0I]; - fpA = findIndex(f, e0.start()); - fpB = findIndex(f, e0.end()); + fpA = f.find(e0.start()); + fpB = f.find(e0.end()); if ((fpA != -1) && (fpB != -1)) { @@ -176,8 +176,8 @@ Foam::label Foam::directionInfo::edgeToFaceIndex // Check if edge on facei. const edge& e1 = mesh.edges()[edge1I]; - fpA = findIndex(f, e1.start()); - fpB = findIndex(f, e1.end()); + fpA = f.find(e1.start()); + fpB = f.find(e1.end()); if ((fpA != -1) && (fpB != -1)) { diff --git a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C index 8a0f2a16052..982785c18bf 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C +++ b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C @@ -657,8 +657,8 @@ void Foam::boundaryCutter::setRefinement // Split face from one side of diagonal to other. const labelPair& diag = iter(); - label fp0 = findIndex(newFace, f[diag[0]]); - label fp1 = findIndex(newFace, f[diag[1]]); + label fp0 = newFace.find(f[diag[0]]); + label fp1 = newFace.find(f[diag[1]]); if (fp0 == -1 || fp1 == -1 || fp0 == fp1) { diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C index d169c6e56ab..b6549c9dcb3 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C +++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C @@ -54,7 +54,7 @@ Foam::label Foam::meshCutAndRemove::firstCommon { forAll(elems1, elemI) { - label index1 = findIndex(elems2, elems1[elemI]); + label index1 = elems2.find(elems1[elemI]); if (index1 != -1) { @@ -72,7 +72,7 @@ bool Foam::meshCutAndRemove::isIn const labelList& cuts ) { - label index = findIndex(cuts, twoCuts[0]); + label index = cuts.find(twoCuts[0]); if (index == -1) { @@ -434,7 +434,7 @@ void Foam::meshCutAndRemove::splitFace ) const { // Check if we find any new vertex which is part of the splitEdge. - label startFp = findIndex(f, v0); + label startFp = f.find(v0); if (startFp == -1) { @@ -444,7 +444,7 @@ void Foam::meshCutAndRemove::splitFace << abort(FatalError); } - label endFp = findIndex(f, v1); + label endFp = f.find(v1); if (endFp == -1) { diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C index 2cc5833ad41..bae27fde251 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C +++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C @@ -49,7 +49,7 @@ bool Foam::meshCutter::uses(const labelList& elems1, const labelList& elems2) { forAll(elems1, elemI) { - if (findIndex(elems2, elems1[elemI]) != -1) + if (elems2.found(elems1[elemI])) { return true; } @@ -64,7 +64,7 @@ bool Foam::meshCutter::isIn const labelList& cuts ) { - label index = findIndex(cuts, twoCuts[0]); + label index = cuts.find(twoCuts[0]); if (index == -1) { @@ -380,7 +380,7 @@ void Foam::meshCutter::splitFace ) const { // Check if we find any new vertex which is part of the splitEdge. - label startFp = findIndex(f, v0); + label startFp = f.find(v0); if (startFp == -1) { @@ -390,7 +390,7 @@ void Foam::meshCutter::splitFace << abort(FatalError); } - label endFp = findIndex(f, v1); + label endFp = f.find(v1); if (endFp == -1) { diff --git a/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C b/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C index 1ee72682f3b..94e9b2f24c2 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C +++ b/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C @@ -174,7 +174,7 @@ void Foam::multiDirRefinement::addCells added[0] = masterI; added[1] = newCelli; } - else if (findIndex(added, newCelli) == -1) + else if (!added.found(newCelli)) { label sz = added.size(); added.setSize(sz + 1); diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index b4f8f7449f5..79bc1bf6887 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -1290,7 +1290,7 @@ Foam::label Foam::faceCoupleInfo::matchEdgeFaces forAll(masterEFaces, j) { - if (findIndex(masterFaces, masterEFaces[j]) != -1) + if (masterFaces.found(masterEFaces[j])) { newCandidates.append(masterEFaces[j]); } diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C index 0c8a179b57f..edd8818ff6f 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C @@ -51,7 +51,7 @@ Foam::label Foam::polyMeshAdder::patchIndex const word& pType = p.type(); const word& pName = p.name(); - label patchi = findIndex(allPatchNames, pName); + label patchi = allPatchNames.find(pName); if (patchi == -1) { @@ -96,7 +96,7 @@ Foam::label Foam::polyMeshAdder::zoneIndex DynamicList<word>& names ) { - label zoneI = findIndex(names, curName); + label zoneI = names.find(curName); if (zoneI != -1) { @@ -912,7 +912,7 @@ void Foam::polyMeshAdder::mergePointZones else if (pointToZone[allPointi] != zoneI) { labelList& pZones = addPointToZones[allPointi]; - if (findIndex(pZones, zoneI) == -1) + if (!pZones.found(zoneI)) { pZones.append(zoneI); } @@ -938,7 +938,7 @@ void Foam::polyMeshAdder::mergePointZones else if (pointToZone[allPointi] != allZoneI) { labelList& pZones = addPointToZones[allPointi]; - if (findIndex(pZones, allZoneI) == -1) + if (!pZones.found(allZoneI)) { pZones.append(allZoneI); } @@ -1070,7 +1070,7 @@ void Foam::polyMeshAdder::mergeFaceZones labelList& fZones = addFaceToZones[allFacei]; boolList& flipZones = addFaceToFlips[allFacei]; - if (findIndex(fZones, zoneI) == -1) + if (!fZones.found(zoneI)) { fZones.append(zoneI); flipZones.append(flip0); @@ -1113,7 +1113,7 @@ void Foam::polyMeshAdder::mergeFaceZones labelList& fZones = addFaceToZones[allFacei]; boolList& flipZones = addFaceToFlips[allFacei]; - if (findIndex(fZones, allZoneI) == -1) + if (!fZones.found(allZoneI)) { fZones.append(allZoneI); flipZones.append(flip1); @@ -1235,7 +1235,7 @@ void Foam::polyMeshAdder::mergeCellZones else if (cellToZone[cell0] != zoneI) { labelList& cZones = addCellToZones[cell0]; - if (findIndex(cZones, zoneI) == -1) + if (!cZones.found(zoneI)) { cZones.append(zoneI); } @@ -1260,7 +1260,7 @@ void Foam::polyMeshAdder::mergeCellZones else if (cellToZone[allCelli] != allZoneI) { labelList& cZones = addCellToZones[allCelli]; - if (findIndex(cZones, allZoneI) == -1) + if (!cZones.found(allZoneI)) { cZones.append(allZoneI); } @@ -2035,7 +2035,7 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints label sz = connectedPointLabels.size(); // Check just to make sure. - if (findIndex(connectedPointLabels, pointi) != -1) + if (connectedPointLabels.found(pointi)) { FatalErrorInFunction << "Duplicate point in sharedPoint addressing." << endl diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index 536f7296b22..5135d80e982 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -540,7 +540,7 @@ void Foam::addPatchCellLayer::findZoneFace if ( - (findIndex(excludeFaces, faceI) == -1) + !excludeFaces.found(faceI) && ( (mesh.isInternalFace(faceI) && useInternalFaces) || (!mesh.isInternalFace(faceI) && useBoundaryFaces) @@ -749,7 +749,7 @@ void Foam::addPatchCellLayer::calcExtrudeInfo if (otherProci != -1) { - if (findIndex(gd[Pstream::myProcNo()], otherProci) != -1) + if (gd[Pstream::myProcNo()].found(otherProci)) { // There is already a processorPolyPatch to otherProci. // Use it. Note that we can only index procPatchMap diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H index 8a035779ad6..485ee56ee2a 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H @@ -146,7 +146,7 @@ class addPatchCellLayer { forAll(y, yi) { - if (findIndex(x, y[yi]) == -1) + if (!x.found(y[yi])) { label sz = x.size(); x.setSize(sz+1); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C index 9d1140a71ef..10e5ee81c63 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C @@ -254,7 +254,7 @@ bool Foam::combineFaces::faceNeighboursValid if (iter == faceRegion.end()) { - if (findIndex(neighbourFaces, nbrI) == -1) + if (!neighbourFaces.found(nbrI)) { neighbourFaces.append(nbrI); } @@ -453,8 +453,8 @@ Foam::face Foam::combineFaces::getOutsideFace bool edgeLoopConsistent = false; { - label index0 = findIndex(outsideLoop, e[0]); - label index1 = findIndex(outsideLoop, e[1]); + label index0 = outsideLoop.find(e[0]); + label index1 = outsideLoop.find(e[1]); if (index0 == -1 || index1 == -1) { @@ -496,7 +496,7 @@ Foam::face Foam::combineFaces::getOutsideFace { // Find edge in face. - label index = findIndex(fp.faceEdges()[eFaces[0]], bEdgeI); + label index = fp.faceEdges()[eFaces[0]].find(bEdgeI); if (index == -1) { diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C index 15d9df7f3e1..ad9e8dd92e6 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C @@ -135,7 +135,7 @@ void Foam::duplicatePoints::setRefinement const labelList& dupPoints = duplicates_[iter()]; // Look up index of my region in the regions for this point - label index = findIndex(regions, fRegion[fp]); + label index = regions.find(fRegion[fp]); // Get the corresponding added point newFace[fp] = dupPoints[index]; } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C index 83d29c214c9..ce81b0a63de 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C @@ -1138,9 +1138,9 @@ void Foam::edgeCollapser::filterFace // Do we have a local point for this index? if (collapseStrings.found(collapseIndex)) { - label localPointi = collapseStrings[collapseIndex][0]; + const label localPointi = collapseStrings[collapseIndex][0]; - if (findIndex(SubList<label>(f, newFp), localPointi) == -1) + if (!SubList<label>(f, newFp).found(localPointi)) { f[newFp++] = localPointi; } @@ -1176,7 +1176,7 @@ void Foam::edgeCollapser::filterFace label pointi = f[fp]; // Search for previous occurrence. - label index = findIndex(SubList<label>(f, fp), pointi); + const label index = SubList<label>(f, fp).find(pointi); if (index == fp1) { diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C index 38a96855df9..43bb0449672 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C @@ -544,7 +544,7 @@ Foam::label Foam::hexRef8::getAnchorCell { if (cellAnchorPoints[celli].size()) { - label index = findIndex(cellAnchorPoints[celli], pointi); + label index = cellAnchorPoints[celli].find(pointi); if (index != -1) { @@ -559,7 +559,7 @@ Foam::label Foam::hexRef8::getAnchorCell forAll(f, fp) { - label index = findIndex(cellAnchorPoints[celli], f[fp]); + label index = cellAnchorPoints[celli].find(f[fp]); if (index != -1) { @@ -1849,7 +1849,7 @@ bool Foam::hexRef8::matchHexShape if (iter != pointFaces.end()) { labelList& pFaces = iter(); - if (findIndex(pFaces, facei) == -1) + if (!pFaces.found(facei)) { pFaces.append(facei); } @@ -4376,12 +4376,12 @@ void Foam::hexRef8::updateMesh cellLevel_[newCelli] = fnd(); } - //if (findIndex(cellLevel_, -1) != -1) + //if (cellLevel_.found(-1)) //{ // WarningInFunction // << "Problem : " // << "cellLevel_ contains illegal value -1 after mapping - // << " at cell " << findIndex(cellLevel_, -1) << endl + // << " at cell " << cellLevel_.find(-1) << endl // << "This means that another program has inflated cells" // << " (created cells out-of-nothing) and hence we don't know" // << " their cell level. Continuing with illegal value." @@ -4450,12 +4450,12 @@ void Foam::hexRef8::updateMesh pointLevel_[newPointi] = fnd(); } - //if (findIndex(pointLevel_, -1) != -1) + //if (pointLevel_.found(-1)) //{ // WarningInFunction // << "Problem : " // << "pointLevel_ contains illegal value -1 after mapping" - // << " at point" << findIndex(pointLevel_, -1) << endl + // << " at point" << pointLevel_.find(-1) << endl // << "This means that another program has inflated points" // << " (created points out-of-nothing) and hence we don't know" // << " their point level. Continuing with illegal value." @@ -4516,7 +4516,7 @@ void Foam::hexRef8::subset cellLevel_.transfer(newCellLevel); - if (findIndex(cellLevel_, -1) != -1) + if (cellLevel_.found(-1)) { FatalErrorInFunction << "Problem : " @@ -4537,7 +4537,7 @@ void Foam::hexRef8::subset pointLevel_.transfer(newPointLevel); - if (findIndex(pointLevel_, -1) != -1) + if (pointLevel_.found(-1)) { FatalErrorInFunction << "Problem : " diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C index 22599e04531..d772f7c1978 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C @@ -313,7 +313,7 @@ void Foam::refinementHistory::freeSplitCell(const label index) { FixedList<label, 8>& subCells = subCellsPtr(); - label myPos = findIndex(subCells, index); + label myPos = subCells.find(index); if (myPos == -1) { diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index b60301b5034..78e9b7b3091 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -404,7 +404,7 @@ void Foam::polyTopoChange::checkFace } } - if (f.size() < 3 || findIndex(f, -1) != -1) + if (f.size() < 3 || f.found(-1)) { FatalErrorInFunction << "Illegal vertices in face" diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C index 212620862eb..720c109d90c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C @@ -283,12 +283,12 @@ void Foam::removeFaces::mergeFaces const face& f = fp.localFaces()[facei]; - label index1 = findIndex(f, edgeLoop[1]); + label index1 = f.find(edgeLoop[1]); if (index1 != -1) { // Check whether consecutive to edgeLoop[0] - label index0 = findIndex(f, edgeLoop[0]); + label index0 = f.find(edgeLoop[0]); if (index0 != -1) { diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C index 9ea5e44203c..88d9a05a40c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C @@ -596,7 +596,7 @@ void Foam::tetDecomposer::setRefinement // we are looping in the same order the tets added for // otherFacei will be before those of facei - label otherFp = findIndex(otherF, p0); + label otherFp = otherF.find(p0); if (otherF.nextLabel(otherFp) == p1) { // ok. otherFp is first vertex of edge. diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C index 76042ef0241..195d41a6842 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C @@ -112,7 +112,7 @@ bool Foam::fv::option::isActive() Foam::label Foam::fv::option::applyToField(const word& fieldName) const { - return findIndex(fieldNames_, fieldName); + return fieldNames_.find(fieldName); } diff --git a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C index 43e22bb860d..78b2b90247e 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C @@ -179,7 +179,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil label nbrGlobalI = globalNumbering().toGlobal(nbrFacei); // Check if already there. Note:should use hashset? - if (findIndex(allGlobalFaces, nbrGlobalI) == -1) + if (!allGlobalFaces.found(nbrGlobalI)) { allGlobalFaces.append(nbrGlobalI); } @@ -196,7 +196,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil label nbrGlobalI = nbrGlobalFaces[j]; // Check if already there. Note:should use hashset? - if (findIndex(allGlobalFaces, nbrGlobalI) == -1) + if (!allGlobalFaces.found(nbrGlobalI)) { allGlobalFaces.append(nbrGlobalI); } diff --git a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index 68291255d13..21c2cc459c9 100644 --- a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -68,7 +68,7 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::writeFileHeader DynamicList<word> commonFields(fields1.size()); forAll(fields1, fieldi) { - label index = findIndex(fields2, fields1[fieldi]); + label index = fields2.find(fields1[fieldi]); if (index != -1) { commonFields.append(fields1[fieldi]); diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index ac4153db68a..d6a49bcce5b 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -551,7 +551,7 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict) Info<< " Employing velocity field " << UName_ << endl; - if (findIndex(fields_, UName_) == -1) + if (!fields_.found(UName_)) { FatalIOErrorInFunction(dict) << "Velocity field for tracking " << UName_ diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C index 8a21bba8229..89fc0d8b220 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C @@ -129,14 +129,14 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace { // Edge is in the forward circulation of this face, so // work with the start point of the edge - eIndex = findIndex(otherFace, e.start()); + eIndex = otherFace.find(e.start()); } else { // edDir == -1, so the edge is in the reverse // circulation of this face, so work with the end // point of the edge - eIndex = findIndex(otherFace, e.end()); + eIndex = otherFace.find(e.end()); } label tetBasePtI = mesh().tetBasePtIs()[facei]; @@ -194,7 +194,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace(const edge& meshEdge) // And adapt meshEdgeStart_. const Foam::face& f = mesh().faces()[tetFace()]; - label fp = findIndex(f, meshEdge[0]); + label fp = f.find(meshEdge[0]); if (f.nextLabel(fp) == meshEdge[1]) { @@ -371,8 +371,8 @@ bool Foam::wallBoundedParticle::isTriAlongTrack if ( currentE[0] == currentE[1] - || findIndex(triVerts, currentE[0]) == -1 - || findIndex(triVerts, currentE[1]) == -1 + || !triVerts.found(currentE[0]) + || !triVerts.found(currentE[1]) ) { FatalErrorInFunction diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C index 3648d6a0c25..5bdcc7fb1a2 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C @@ -127,7 +127,7 @@ void Foam::DSMCCloud<ParcelType>::initialise { const word& moleculeName(molecules[i]); - label typeId(findIndex(typeIdList_, moleculeName)); + label typeId = typeIdList_.find(moleculeName); if (typeId == -1) { @@ -137,7 +137,7 @@ void Foam::DSMCCloud<ParcelType>::initialise } const typename ParcelType::constantProperties& cP = - constProps(typeId); + constProps(typeId); scalar numberDensity = numberDensities[i]; diff --git a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C index 3b85d705876..154faee32be 100644 --- a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C +++ b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C @@ -93,7 +93,7 @@ Foam::FreeStream<CloudType>::FreeStream numberDensitiesDict.lookup(molecules[i]) ); - moleculeTypeIds_[i] = findIndex(cloud.typeIdList(), molecules[i]); + moleculeTypeIds_[i] = cloud.typeIdList().find(molecules[i]); if (moleculeTypeIds_[i] == -1) { diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H index b1c9a354b4d..947998d4c07 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H +++ b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H @@ -319,10 +319,9 @@ inline void Foam::molecule::constantProperties::setInteracionSiteBools forAll(siteIds_, i) { - const word& id(siteIds[i]); - - pairPotentialSites_[i] = (findIndex(pairPotSiteIds, id) > -1); + const word& id = siteIds[i]; + pairPotentialSites_[i] = pairPotSiteIds.found(id); electrostaticSites_[i] = (mag(siteCharges_[i]) > VSMALL); } } @@ -409,7 +408,7 @@ inline bool Foam::molecule::constantProperties::pairPotentialSite label sId ) const { - label s = findIndex(siteIds_, sId); + label s = siteIds_.find(sId); if (s == -1) { @@ -434,7 +433,7 @@ inline bool Foam::molecule::constantProperties::electrostaticSite label sId ) const { - label s = findIndex(siteIds_, sId); + label s = siteIds_.find(sId); if (s == -1) { diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C index 6952e7ca554..0b41ed96f8f 100644 --- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C +++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C @@ -74,7 +74,7 @@ void Foam::moleculeCloud::buildConstProps() { const word& siteId = siteIdNames[sI]; - siteIds[sI] = findIndex(siteIdList, siteId); + siteIds[sI] = siteIdList.find(siteId); if (siteIds[sI] == -1) { @@ -293,23 +293,22 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps() if (evaluatePotentialLimit(*molI, *molJ)) { - label idI = molI->id(); - - label idJ = molJ->id(); + const label idI = molI->id(); + const label idJ = molJ->id(); if ( idI == idJ - || findIndex(pot_.removalOrder(), idJ) - < findIndex(pot_.removalOrder(), idI) + || pot_.removalOrder().find(idJ) + < pot_.removalOrder().find(idI) ) { - if (findIndex(molsToDelete, molJ) == -1) + if (!molsToDelete.found(molJ)) { molsToDelete.append(molJ); } } - else if (findIndex(molsToDelete, molI) == -1) + else if (!molsToDelete.found(molI)) { molsToDelete.append(molI); } @@ -326,23 +325,22 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps() { if (evaluatePotentialLimit(*molI, *molJ)) { - label idI = molI->id(); - - label idJ = molJ->id(); + const label idI = molI->id(); + const label idJ = molJ->id(); if ( idI == idJ - || findIndex(pot_.removalOrder(), idJ) - < findIndex(pot_.removalOrder(), idI) + || pot_.removalOrder().find(idJ) + < pot_.removalOrder().find(idI) ) { - if (findIndex(molsToDelete, molJ) == -1) + if (!molsToDelete.found(molJ)) { molsToDelete.append(molJ); } } - else if (findIndex(molsToDelete, molI) == -1) + else if (!molsToDelete.found(molI)) { molsToDelete.append(molI); } @@ -405,25 +403,24 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps() if (evaluatePotentialLimit(*molI, *molJ)) { - label idI = molI->id(); - - label idJ = molJ->id(); + const label idI = molI->id(); + const label idJ = molJ->id(); if ( - findIndex(pot_.removalOrder(), idI) - < findIndex(pot_.removalOrder(), idJ) + pot_.removalOrder().find(idI) + < pot_.removalOrder().find(idJ) ) { - if (findIndex(molsToDelete, molI) == -1) + if (!molsToDelete.found(molI)) { molsToDelete.append(molI); } } else if ( - findIndex(pot_.removalOrder(), idI) - == findIndex(pot_.removalOrder(), idJ) + pot_.removalOrder().find(idI) + == pot_.removalOrder().find(idJ) ) { // Remove one of the molecules @@ -433,7 +430,7 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps() if (molI->origId() > molJ->origId()) { - if (findIndex(molsToDelete, molI) == -1) + if (!molsToDelete.found(molI)) { molsToDelete.append(molI); } @@ -566,7 +563,7 @@ void Foam::moleculeCloud::initialiseMolecules forAll(latticeIds, i) { - label id = findIndex(pot_.idList(), latticeIds[i]); + label id = pot_.idList().find(latticeIds[i]); const molecule::constantProperties& cP(constProps(id)); @@ -726,7 +723,7 @@ void Foam::moleculeCloud::initialiseMolecules forAll(latticePositions, p) { - label id = findIndex(pot_.idList(), latticeIds[p]); + label id = pot_.idList().find(latticeIds[p]); const vector& latticePosition = vector @@ -749,7 +746,7 @@ void Foam::moleculeCloud::initialiseMolecules const label cell = mesh_.cellTree().findInside(globalPosition); - if (findIndex(zone, cell) != -1) + if (zone.found(cell)) { createMolecule ( @@ -792,11 +789,8 @@ void Foam::moleculeCloud::initialiseMolecules { forAll(latticePositions, p) { - label id = findIndex - ( - pot_.idList(), - latticeIds[p] - ); + const label id = + pot_.idList().find(latticeIds[p]); const vector& latticePosition = vector @@ -829,7 +823,7 @@ void Foam::moleculeCloud::initialiseMolecules globalPosition ); - if (findIndex(zone, cell) != -1) + if (zone.found(cell)) { createMolecule ( @@ -863,11 +857,8 @@ void Foam::moleculeCloud::initialiseMolecules { forAll(latticePositions, p) { - label id = findIndex - ( - pot_.idList(), - latticeIds[p] - ); + const label id = + pot_.idList().find(latticeIds[p]); const vector& latticePosition = vector @@ -900,7 +891,7 @@ void Foam::moleculeCloud::initialiseMolecules globalPosition ); - if (findIndex(zone, cell) != -1) + if (zone.found(cell)) { createMolecule ( diff --git a/src/lagrangian/molecularDynamics/potential/potential/potential.C b/src/lagrangian/molecularDynamics/potential/potential/potential.C index 8c8b04e8b91..5c120c6e025 100644 --- a/src/lagrangian/molecularDynamics/potential/potential/potential.C +++ b/src/lagrangian/molecularDynamics/potential/potential/potential.C @@ -51,7 +51,7 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict) { const word& siteId = siteIdNames[sI]; - if (findIndex(siteIdList, siteId) == -1) + if (!siteIdList.found(siteId)) { siteIdList.append(siteId); } @@ -63,14 +63,14 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict) { const word& siteId = pairPotSiteIds[sI]; - if (findIndex(siteIdNames, siteId) == -1) + if (!siteIdNames.found(siteId)) { FatalErrorInFunction << siteId << " in pairPotentialSiteIds is not in siteIds: " << siteIdNames << nl << abort(FatalError); } - if (findIndex(pairPotentialSiteIdList, siteId) == -1) + if (!pairPotentialSiteIdList.found(siteId)) { pairPotentialSiteIdList.append(siteId); } @@ -83,7 +83,7 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict) { const word& siteId = siteIdList[aSIN]; - if (findIndex(pairPotentialSiteIdList, siteId) == -1) + if (!pairPotentialSiteIdList.found(siteId)) { pairPotentialSiteIdList.append(siteId); } @@ -169,7 +169,7 @@ void Foam::potential::potential::readPotentialDict() forAll(removalOrder_, rO) { - removalOrder_[rO] = findIndex(idList_, remOrd[rO]); + removalOrder_[rO] = idList_.find(remOrd[rO]); if (removalOrder_[rO] == -1) { @@ -288,7 +288,7 @@ void Foam::potential::potential::readMdInitialiseDict << abort(FatalError); } - if (findIndex(idList,id) == -1) + if (!idList.found(id)) { idList.append(id); } @@ -319,7 +319,7 @@ void Foam::potential::potential::readMdInitialiseDict moleculePropertiesDict.subDict(id).lookup("siteIds") ); - if (findIndex(siteIds, tetherSiteId) != -1) + if (siteIds.found(tetherSiteId)) { idFound = true; } diff --git a/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C b/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C index 8833d793041..545f7a04f51 100644 --- a/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C +++ b/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C @@ -45,7 +45,7 @@ void Foam::tetherPotentialList::readTetherPotentialDict { word tetherPotentialName = tetherSiteIdList[t]; - label tetherId = findIndex(siteIdList, tetherPotentialName); + label tetherId = siteIdList.find(tetherPotentialName); if (tetherId == -1) { diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index 92eedd79ab0..1c90b6a2275 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -2037,7 +2037,7 @@ Foam::label Foam::meshRefinement::addMeshedPatch const dictionary& patchInfo ) { - label meshedi = findIndex(meshedPatches_, name); + label meshedi = meshedPatches_.find(name); if (meshedi != -1) { @@ -2341,7 +2341,7 @@ void Foam::meshRefinement::findRegions { // Do a quick check for locationsOutsideMesh overlapping with // inside ones. - label index = findIndex(insideRegions, regioni); + label index = insideRegions.find(regioni); if (index != -1) { FatalErrorInFunction diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index 66c3723a60a..b18fcdc66d2 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -671,7 +671,7 @@ Foam::labelList Foam::meshRefinement::getZones surfaceZonesInfo::faceZoneType fzType; bool hasInfo = getFaceZoneInfo(fZone.name(), mpI, spI, fzType); - if (hasInfo && findIndex(fzTypes, fzType) != -1) + if (hasInfo && fzTypes.found(fzType)) { zoneIDs.append(zoneI); } @@ -1549,7 +1549,7 @@ void Foam::meshRefinement::findCellZoneGeometric } // Make sure the cellZone originated from a closed surface - label geomSurfI = findIndex(surfaceToCellZone, minZone); + label geomSurfI = surfaceToCellZone.find(minZone); if (geomSurfI != -1) { @@ -1593,7 +1593,7 @@ void Foam::meshRefinement::findCellZoneGeometric } // Make sure the cellZone originated from a closed surface - label geomSurfI = findIndex(surfaceToCellZone, minZone); + label geomSurfI = surfaceToCellZone.find(minZone); if (geomSurfI != -1) { diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index e24f9c54972..8516c3db43c 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -344,7 +344,7 @@ bool Foam::snappyLayerDriver::checkCommonOrder forAll(curFace, fp) { // Get the index in the neighbouring face shared with curFace - const label nb = findIndex(nbFace, curFace[fp]); + const label nb = nbFace.find(curFace[fp]); if (nb != -1) { @@ -1936,7 +1936,7 @@ void Foam::snappyLayerDriver::getVertexString ) const { const labelList& fEdges = pp.faceEdges()[facei]; - label fp = findIndex(fEdges, edgei); + label fp = fEdges.find(edgei); if (fp == -1) { diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index ec9e7f3936d..fb9190add35 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -1703,7 +1703,7 @@ Foam::labelPair Foam::snappySnapDriver::findDiagonalAttraction //forAll(cPoints, i) //{ // label pointi = cPoints[i]; - // if (findIndex(meshF, pointi) == -1) + // if (!meshF.found(pointi)) // { // cc += mesh.points()[pointi]; // } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 6253c95f9be..d0a89190af4 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -473,7 +473,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::agglomerate label elemi = elems[i]; label coarseElemi = tgtCompactMap[elemi]; - label index = findIndex(newElems, coarseElemi); + label index = newElems.find(coarseElemi); if (index == -1) { newElems.append(coarseElemi); @@ -519,7 +519,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::agglomerate label elemi = elems[i]; label coarseElemi = targetRestrictAddressing[elemi]; - label index = findIndex(newElems, coarseElemi); + label index = newElems.find(coarseElemi); if (index == -1) { newElems.append(coarseElemi); diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C index 070a4b70549..051fc0d1881 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C @@ -67,7 +67,7 @@ Foam::label Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcDistribution } else if (nHaveFaces == 1) { - proci = findIndex(facesPresentOnProc, 1); + proci = facesPresentOnProc.find(1); if (debug) { InfoInFunction diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C index 344c92ded1b..badb6a93a6b 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C @@ -137,7 +137,7 @@ Foam::label Foam::mapNearestAMI<SourcePatch, TargetPatch>::findMappedSrcFace // search target tgtFacei neighbours for match with source face label tgtI = testFaces.remove(); - if (findIndex(visitedFaces, tgtI) == -1) + if (!visitedFaces.found(tgtI)) { visitedFaces.append(tgtI); @@ -151,7 +151,7 @@ Foam::label Foam::mapNearestAMI<SourcePatch, TargetPatch>::findMappedSrcFace forAll(nbrFaces, i) { - if (findIndex(visitedFaces, nbrFaces[i]) == -1) + if (!visitedFaces.found(nbrFaces[i])) { testFaces.append(nbrFaces[i]); } diff --git a/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H b/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H index 422b0b2e9e2..07ae3a40877 100644 --- a/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H +++ b/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H @@ -63,7 +63,7 @@ inline const Foam::labelList& Foam::patchEdgeFaceRegions::regions() const template<class TrackingData> inline bool Foam::patchEdgeFaceRegions::valid(TrackingData& td) const { - return regions_.size() && (findIndex(regions_, labelMax) == -1); + return regions_.size() && !regions_.found(labelMax); } @@ -94,7 +94,7 @@ inline bool Foam::patchEdgeFaceRegions::updateEdge const face& f = patch.localFaces()[facei]; const edge& e = patch.edges()[edgeI]; - label index = findIndex(patch.faceEdges()[facei], edgeI); + label index = patch.faceEdges()[facei].find(edgeI); bool sameOrientation = (f[index] == e.start()); // Get information in edge-order @@ -114,7 +114,7 @@ inline bool Foam::patchEdgeFaceRegions::updateEdge << "problem." << abort(FatalError); } - if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1)) + if (orientedInfo.found(-1) || regions_.found(-1)) { // Blocked edge/face return false; @@ -161,7 +161,7 @@ inline bool Foam::patchEdgeFaceRegions::updateEdge << "problem." << abort(FatalError); } - if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1)) + if (orientedInfo.found(-1) || regions_.found(-1)) { // Blocked edge/face return false; @@ -199,7 +199,7 @@ inline bool Foam::patchEdgeFaceRegions::updateFace const edge& e = patch.edges()[edgeI]; // Find starting point of edge on face. - label index0 = findIndex(patch.faceEdges()[facei], edgeI); + label index0 = patch.faceEdges()[facei].find(edgeI); label index1 = f.fcIndex(index0); bool sameOrientation = (f[index0] == e.start()); @@ -221,7 +221,7 @@ inline bool Foam::patchEdgeFaceRegions::updateFace << "problem." << abort(FatalError); } - if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1)) + if (orientedInfo.found(-1) || regions_.found(-1)) { // Blocked edge/face return false; diff --git a/src/meshTools/cellFeatures/cellFeatures.C b/src/meshTools/cellFeatures/cellFeatures.C index b49a6b97261..8ab57513f43 100644 --- a/src/meshTools/cellFeatures/cellFeatures.C +++ b/src/meshTools/cellFeatures/cellFeatures.C @@ -137,12 +137,12 @@ bool Foam::cellFeatures::isCellFeatureEdge const face& f0 = mesh_.faces()[face0]; - label face0Start = findIndex(f0, e.start()); + label face0Start = f0.find(e.start()); label face0End = f0.fcIndex(face0Start); const face& f1 = mesh_.faces()[face1]; - label face1Start = findIndex(f1, e.start()); + label face1Start = f1.find(e.start()); label face1End = f1.fcIndex(face1Start); if diff --git a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H index 23c1f76faf4..1919b48299c 100644 --- a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H +++ b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H @@ -143,7 +143,7 @@ Foam::label Foam::edgeFaceCirculator::getMinIndex const label v1 ) { - label fp = findIndex(f, v0); + label fp = f.find(v0); if (fp != -1) { diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C index 3cb86ec3a62..b5d0fc3617a 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C @@ -379,7 +379,7 @@ void Foam::extendedEdgeMesh::sortPointsAndEdges forAll(ptEdNorms, k) { - if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1) + if (!tmpFtPtNorms.found(ptEdNorms[k])) { bool addNormal = true; diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C index 5b7eec3c5af..e6ef2557c87 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C @@ -379,7 +379,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges forAll(ptEdNorms, k) { - if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1) + if (!tmpFtPtNorms.found(ptEdNorms[k])) { bool addNormal = true; diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C index b4fcf6b974a..04d67382580 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C @@ -532,7 +532,7 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::operator() point& intersectionPoint ) const { - if (findIndex(shapeMask_, index) != -1) + if (shapeMask_.found(index)) { return false; } @@ -564,7 +564,7 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findSelfIntersectOp::operator() const typename PatchType::FaceType& f = patch.localFaces()[index]; const edge& e = patch.edges()[edgeID_]; - if (findIndex(f, e[0]) == -1 && findIndex(f, e[1]) == -1) + if (!f.found(e[0]) && !f.found(e[1])) { return findIntersection(tree_, index, start, end, intersectionPoint); } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C index 6732e5c7b18..db8f9fdb474 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C @@ -53,7 +53,7 @@ Foam::mappedPolyPatch::mappedPolyPatch mappedPatchBase(static_cast<const polyPatch&>(*this)) { // mapped is not constraint type so add mapped group explicitly - if (findIndex(inGroups(), typeName) == -1) + if (!inGroups().found(typeName)) { inGroups().append(typeName); } @@ -123,7 +123,7 @@ Foam::mappedPolyPatch::mappedPolyPatch mappedPatchBase(*this, dict) { // mapped is not constraint type so add mapped group explicitly - if (findIndex(inGroups(), typeName) == -1) + if (!inGroups().found(typeName)) { inGroups().append(typeName); } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C index 243d0a804ae..ab36de56c45 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C @@ -59,7 +59,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch mappedPatchBase(static_cast<const polyPatch&>(*this)) { // mapped is not constraint type so add mapped group explicitly - if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) + if (!inGroups().found(mappedPolyPatch::typeName)) { inGroups().append(mappedPolyPatch::typeName); } @@ -129,7 +129,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch mappedPatchBase(*this, dict) { // mapped is not constraint type so add mapped group explicitly - if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) + if (!inGroups().found(mappedPolyPatch::typeName)) { inGroups().append(mappedPolyPatch::typeName); } diff --git a/src/meshTools/meshTools/meshTools.C b/src/meshTools/meshTools/meshTools.C index 9a9012b925b..dca4246471c 100644 --- a/src/meshTools/meshTools/meshTools.C +++ b/src/meshTools/meshTools/meshTools.C @@ -319,7 +319,7 @@ bool Foam::meshTools::edgeOnCell const label edgeI ) { - return findIndex(mesh.edgeCells(edgeI), celli) != -1; + return mesh.edgeCells(edgeI).found(celli); } @@ -330,7 +330,7 @@ bool Foam::meshTools::edgeOnFace const label edgeI ) { - return findIndex(mesh.faceEdges(facei), edgeI) != -1; + return mesh.faceEdges(facei).found(edgeI); } diff --git a/src/meshTools/regionSplit/localPointRegion.C b/src/meshTools/regionSplit/localPointRegion.C index 9a6cc288e45..38e2331f611 100644 --- a/src/meshTools/regionSplit/localPointRegion.C +++ b/src/meshTools/regionSplit/localPointRegion.C @@ -75,7 +75,7 @@ bool Foam::localPointRegion::isDuplicate return false; } - label fp1 = findIndex(f1, f0[0]); + label fp1 = f1.find(f0[0]); if (fp1 == -1) { @@ -160,7 +160,7 @@ void Foam::localPointRegion::countPointRegions if (iter != meshPointMap_.end()) { labelList& regions = pointRegions[iter()]; - if (findIndex(regions, region) == -1) + if (!regions.found(region)) { label sz = regions.size(); regions.setSize(sz+1); diff --git a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C index 9686901cec1..2783cea76f9 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C @@ -129,7 +129,7 @@ Foam::searchableSurfaces::searchableSurfaces(const label size) // // Get the dictionary for region iter.key() // const dictionary& regionDict = regionsDict.subDict(key); // -// label index = findIndex(localNames, key); +// label index = localNames.find(key); // // if (index == -1) // { @@ -251,7 +251,7 @@ Foam::searchableSurfaces::searchableSurfaces // Get the dictionary for region iter.keyword() const dictionary& regionDict = regionsDict.subDict(key); - label index = findIndex(localNames, key); + label index = localNames.find(key); if (index == -1) { @@ -285,7 +285,7 @@ Foam::label Foam::searchableSurfaces::findSurfaceID const word& wantedName ) const { - return findIndex(names_, wantedName); + return names_.find(wantedName); } @@ -295,9 +295,9 @@ Foam::label Foam::searchableSurfaces::findSurfaceRegionID const word& regionName ) const { - label surfaceIndex = findSurfaceID(surfaceName); + const label surfaceIndex = findSurfaceID(surfaceName); - return findIndex(this->operator[](surfaceIndex).regions(), regionName); + return this->operator[](surfaceIndex).regions().find(regionName); } diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 2aff7124af2..279c75caba8 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -175,7 +175,7 @@ bool Foam::triSurfaceMesh::isSurfaceClosed() const forAll(pFaces, i) { const triSurface::FaceType& f = triSurface::operator[](pFaces[i]); - label fp = findIndex(f, pointi); + label fp = f.find(pointi); // Something weird: if I expand the code of addFaceToEdge in both // below instances it gives a segmentation violation on some diff --git a/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C b/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C index fd9c7a9fd09..a142a37ee6b 100644 --- a/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C +++ b/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C @@ -212,7 +212,7 @@ bool Foam::intersectedSurface::sameEdgeOrder { forAll(fA, fpA) { - label fpB = findIndex(fB, fA[fpA]); + label fpB = fB.find(fA[fpA]); if (fpB != -1) { diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index 7877bdfc2d2..d9ea3c2b8d9 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -392,7 +392,7 @@ Foam::surfaceFeatures::labelScalar Foam::surfaceFeatures::walkSegment label nVisited = 0; - if (findIndex(featurePoints_, startPointi) >= 0) + if (featurePoints_.found(startPointi)) { // Do not walk across feature points @@ -623,7 +623,7 @@ Foam::surfaceFeatures::surfaceFeatures::checkFlatRegionEdge regionAndNormal1[i] = myRegionAndNormal; - label index = findIndex(regionAndNormal, -myRegionAndNormal); + label index = regionAndNormal.find(-myRegionAndNormal); if (index == -1) { // Not found. diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C index f8fd6c096eb..13ba83fb954 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C @@ -205,7 +205,7 @@ void Foam::triSurfaceRegionSearch::findNearest forAll(octrees, treeI) { - if (findIndex(regionIndices, treeI) == -1) + if (!regionIndices.found(treeI)) { continue; } diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C index 2518b095164..f64cb0eea2b 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C @@ -45,7 +45,7 @@ Foam::scalar Foam::triSurfaceTools::vertexNormalWeight const UList<point>& points ) { - label index = findIndex(f, pI); + label index = f.find(pI); if (index == -1) { diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C index d1da45a001c..4f0745a1846 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C @@ -101,7 +101,7 @@ void Foam::triSurfaceTools::greenRefine // Find index of edge in face. - label fp0 = findIndex(f, e[0]); + label fp0 = f.find(e[0]); label fp1 = f.fcIndex(fp0); label fp2 = f.fcIndex(fp1); @@ -881,7 +881,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge { // Excluded point. Test only opposite edge. - label fp0 = findIndex(s.localFaces()[triI], excludePointi); + label fp0 = s.localFaces()[triI].find(excludePointi); if (fp0 == -1) { @@ -1062,7 +1062,7 @@ void Foam::triSurfaceTools::snapToEnd // endpoint on edge; current on triangle const labelList& fEdges = s.faceEdges()[current.index()]; - if (findIndex(fEdges, end.index()) != -1) + if (fEdges.found(end.index())) { //if (debug) //{ @@ -1111,7 +1111,7 @@ void Foam::triSurfaceTools::snapToEnd // endpoint on point; current on triangle const triSurface::FaceType& f = s.localFaces()[current.index()]; - if (findIndex(f, end.index()) != -1) + if (f.found(end.index())) { //if (debug) //{ @@ -1415,7 +1415,7 @@ void Foam::triSurfaceTools::otherEdges { const labelList& eFaces = surf.faceEdges()[facei]; - label i0 = findIndex(eFaces, edgeI); + label i0 = eFaces.find(edgeI); if (i0 == -1) { diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C index 8eb4dca3300..9a2851870d5 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C @@ -256,7 +256,7 @@ void Foam::cellCellStencil::globalCellCells } SubList<label> current(stencil, compacti); - if (findIndex(current, nbrCelli) == -1) + if (!current.found(nbrCelli)) { stencil[compacti] = nbrCelli; stencilPoints[compacti++] = nbrCc; diff --git a/src/overset/oversetPolyPatch/oversetPolyPatch.C b/src/overset/oversetPolyPatch/oversetPolyPatch.C index ddce16ae7c6..1b6e411baf2 100644 --- a/src/overset/oversetPolyPatch/oversetPolyPatch.C +++ b/src/overset/oversetPolyPatch/oversetPolyPatch.C @@ -54,7 +54,7 @@ Foam::oversetPolyPatch::oversetPolyPatch masterPatchID_(-1) { // 'overset' is not constraint type so add to group explicitly - if (findIndex(inGroups(), typeName) == -1) + if (!inGroups().found(typeName)) { inGroups().append(typeName); } @@ -74,7 +74,7 @@ Foam::oversetPolyPatch::oversetPolyPatch masterPatchID_(-1) { // 'overset' is not constraint type so add to group explicitly - if (findIndex(inGroups(), typeName) == -1) + if (!inGroups().found(typeName)) { inGroups().append(typeName); } diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index 2573c9ec78b..c17958367a3 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -96,11 +96,10 @@ Foam::decompositionMethod::decompositionMethod if ( decompositionDict_.found("preserveBaffles") - && findIndex + && !constraintTypes_.found ( - constraintTypes_, decompositionConstraints::preserveBafflesConstraint::typeName - ) == -1 + ) ) { constraints_.append @@ -112,11 +111,10 @@ Foam::decompositionMethod::decompositionMethod if ( decompositionDict_.found("preservePatches") - && findIndex + && !constraintTypes_.found ( - constraintTypes_, decompositionConstraints::preservePatchesConstraint::typeName - ) == -1 + ) ) { const wordReList pNames(decompositionDict_.lookup("preservePatches")); @@ -130,11 +128,10 @@ Foam::decompositionMethod::decompositionMethod if ( decompositionDict_.found("preserveFaceZones") - && findIndex + && !constraintTypes_.found ( - constraintTypes_, decompositionConstraints::preserveFaceZonesConstraint::typeName - ) == -1 + ) ) { const wordReList zNames(decompositionDict_.lookup("preserveFaceZones")); @@ -148,11 +145,10 @@ Foam::decompositionMethod::decompositionMethod if ( decompositionDict_.found("singleProcessorFaceSets") - && findIndex + && !constraintTypes_.found ( - constraintTypes_, decompositionConstraints::preserveFaceZonesConstraint::typeName - ) == -1 + ) ) { const List<Tuple2<word, label>> zNameAndProcs diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index fc7aa24aef3..60ff416676c 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -1147,7 +1147,7 @@ Foam::label Foam::distributedTriSurfaceMesh::findTriangle if (f.region() == otherF.region()) { // Find index of otherF[0] - label fp0 = findIndex(f, otherF[0]); + label fp0 = f.find(otherF[0]); // Check rest of triangle in same order label fp1 = f.fcIndex(fp0); label fp2 = f.fcIndex(fp1); diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C index bc8f2a9c452..367459ce47f 100644 --- a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C +++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C @@ -58,7 +58,7 @@ void surfaceNoise::initialise(const fileName& fName) // Find the index of the pressure data const List<word> fieldNames(readerPtr_->fieldNames(0)); - pIndex_ = findIndex(fieldNames, pName_); + pIndex_ = fieldNames.find(pName_); if (pIndex_ == -1) { FatalErrorInFunction diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C index 6ab4eb18db4..d4bda62d8b2 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.C +++ b/src/regionModels/regionModel/regionModel/regionModel.C @@ -194,7 +194,7 @@ Foam::regionModels::regionModel::interRegionAMI const bool flip ) const { - label nbrRegionID = findIndex(interRegionAMINames_, nbrRegion.name()); + label nbrRegionID = interRegionAMINames_.find(nbrRegion.name()); const fvMesh& nbrRegionMesh = nbrRegion.regionMesh(); diff --git a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C index cd0f2d193ce..267a424952d 100644 --- a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C +++ b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C @@ -297,7 +297,7 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell // search target tgtCelli neighbours for match with source cell label tgtI = testCells.remove(); - if (findIndex(visitedCells, tgtI) == -1) + if (!visitedCells.found(tgtI)) { visitedCells.append(tgtI); @@ -311,7 +311,7 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell forAll(nbrCells, i) { - if (findIndex(visitedCells, nbrCells[i]) == -1) + if (!visitedCells.found(nbrCells[i])) { testCells.append(nbrCells[i]); } diff --git a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C index 9a99aa04e1c..afb6b727dc9 100644 --- a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C +++ b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C @@ -168,14 +168,12 @@ void Foam::meshToMeshMethod::appendNbrCells const labelList& nbrCells = mesh.cellCells()[celli]; // filter out cells already visited from cell neighbours - forAll(nbrCells, i) + for (const label nbrCelli : nbrCells) { - label nbrCelli = nbrCells[i]; - if ( - (findIndex(visitedCells, nbrCelli) == -1) - && (findIndex(nbrCellIDs, nbrCelli) == -1) + !visitedCells.found(nbrCelli) + && !nbrCellIDs.found(nbrCelli) ) { nbrCellIDs.append(nbrCelli); diff --git a/src/sampling/meshToMesh/meshToMeshParallelOps.C b/src/sampling/meshToMesh/meshToMeshParallelOps.C index d0efb5f4f34..6fe60c58e93 100644 --- a/src/sampling/meshToMesh/meshToMeshParallelOps.C +++ b/src/sampling/meshToMesh/meshToMeshParallelOps.C @@ -70,7 +70,7 @@ Foam::label Foam::meshToMesh::calcDistribution } else if (nHaveCells == 1) { - proci = findIndex(cellsPresentOnProc, 1); + proci = cellsPresentOnProc.find(1); if (debug) { InfoInFunction diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C index 85ef3a9d4f7..333bb94527f 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C @@ -55,7 +55,7 @@ Foam::sampledPlane::sampledPlane triangulate_(triangulate), needsUpdate_(true) { - if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) + if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1) { Info<< "cellZone " << zoneKey_ << " not found - using entire mesh" << endl; @@ -91,7 +91,7 @@ Foam::sampledPlane::sampledPlane dict.readIfPresent("zone", zoneKey_); - if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) + if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1) { Info<< "cellZone " << zoneKey_ << " not found - using entire mesh" << endl; diff --git a/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C b/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C index dea10f0fd31..19132b4b9e8 100644 --- a/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C +++ b/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C @@ -73,7 +73,7 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler triangulate_(triangulate), needsUpdate_(true) { - if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) + if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1) { Info<< "cellZone " << zoneKey_ << " not found - using entire mesh" << endl; @@ -109,7 +109,7 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler dict.readIfPresent("zone", zoneKey_); - if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) + if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1) { Info<< "cellZone " << zoneKey_ << " not found - using entire mesh" << endl; diff --git a/src/sampling/surface/isoSurface/isoSurface.C b/src/sampling/surface/isoSurface/isoSurface.C index a2041c100ed..f4e09a4da53 100644 --- a/src/sampling/surface/isoSurface/isoSurface.C +++ b/src/sampling/surface/isoSurface/isoSurface.C @@ -748,7 +748,7 @@ void Foam::isoSurface::calcSnappedPoint FixedList<scalar, 4> s; FixedList<point, 4> pt; - label fp = findIndex(f, pointi); + label fp = f.find(pointi); s[0] = isoFraction(pVals[pointi], cVals[own]); pt[0] = (1.0-s[0])*pts[pointi] + s[0]*cc[own]; diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.C b/src/sampling/surface/isoSurface/isoSurfaceCell.C index 3b22509c38d..ab1e6bfdd42 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/surface/isoSurface/isoSurfaceCell.C @@ -226,12 +226,12 @@ Foam::labelPair Foam::isoSurfaceCell::findCommonPoints labelPair common(-1, -1); label fp0 = 0; - label fp1 = findIndex(tri1, tri0[fp0]); + label fp1 = tri1.find(tri0[fp0]); if (fp1 == -1) { fp0 = 1; - fp1 = findIndex(tri1, tri0[fp0]); + fp1 = tri1.find(tri0[fp0]); } if (fp1 != -1) @@ -553,7 +553,7 @@ void Foam::isoSurfaceCell::genPointTris label nextFp = f.fcIndex(fp); triFace tri(f[fp0], f[fp], f[nextFp]); - label index = findIndex(tri, pointi); + label index = tri.find(pointi); if (index == -1) { @@ -631,7 +631,7 @@ void Foam::isoSurfaceCell::genPointTris { label p1 = f1[fp]; - if (findIndex(f, p1) == -1) + if (!f.found(p1)) { ccPointi = p1; break; @@ -645,7 +645,7 @@ void Foam::isoSurfaceCell::genPointTris // Tet between index..index-1, index..index+1, index..cc - label index = findIndex(f, pointi); + label index = f.find(pointi); label b = f[f.fcIndex(index)]; label c = f[f.rcIndex(index)]; diff --git a/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C b/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C index 521ff41871b..9a2b1834525 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C +++ b/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C @@ -360,7 +360,7 @@ void Foam::isoSurfaceCell::generateTriPoints { oppositeI = f1[fp]; - if (findIndex(f0, oppositeI) == -1) + if (!f0.found(oppositeI)) { break; } diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C index 97069ab988c..0afa3761133 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C @@ -457,7 +457,7 @@ void Foam::radiation::solarLoad::calculateQdiff label faceI = fineFaces[j]; label globalFaceI = faceI + pp.start(); - if (findIndex(hitFacesId, globalFaceI) != -1) + if (hitFacesId.found(globalFaceI)) { fullArea += sf[faceI]; } -- GitLab From ffabc42dbf994cae732354e28dd2265ebd73a00e Mon Sep 17 00:00:00 2001 From: sergio <sergio> Date: Wed, 25 Oct 2017 10:17:55 -0700 Subject: [PATCH 056/126] ENH: Arrhenius viscocity model and energyTransport function-object - Arrhenius viscocity model for incompressible viscocity. - energyTransport FO for incompressible single and multiple phase flows and viscousDissipation fvOption source. - Tutorial to show the use of energyTransport: multiphase/multiphaseInterFoam/laminar/mixerVessel2D - Tutorial to show viscousDissipation: compressible/rhoPimpleFoam/RAS/TJunction --- src/functionObjects/solvers/Make/files | 1 + .../solvers/energyTransport/energyTransport.C | 487 +++ .../solvers/energyTransport/energyTransport.H | 323 ++ src/fvOptions/Make/files | 1 + .../viscousDissipation/viscousDissipation.C | 222 ++ .../viscousDissipation/viscousDissipation.H | 149 + src/transportModels/incompressible/Make/files | 1 + .../viscosityModels/Arrhenius/Arrhenius.C | 93 + .../viscosityModels/Arrhenius/Arrhenius.H | 145 + .../viscosityModels/Arrhenius/Arrheniuss.C | 44 + .../Arrhenius/makeArrheniusTypes.H | 63 + .../viscosityModels/BirdCarreau/BirdCarreau.C | 6 +- .../viscosityModels/BirdCarreau/BirdCarreau.H | 10 +- .../viscosityModels/Casson/Casson.C | 4 +- .../viscosityModels/Casson/Casson.H | 10 +- .../CrossPowerLaw/CrossPowerLaw.C | 4 +- .../CrossPowerLaw/CrossPowerLaw.H | 10 +- .../HerschelBulkley/HerschelBulkley.C | 4 +- .../HerschelBulkley/HerschelBulkley.H | 9 +- .../viscosityModels/Newtonian/Newtonian.C | 2 +- .../viscosityModels/Newtonian/Newtonian.H | 9 +- .../viscosityModels/powerLaw/powerLaw.C | 4 +- .../viscosityModels/powerLaw/powerLaw.H | 9 +- .../strainRateFunction/strainRateFunction.C | 2 +- .../strainRateFunction/strainRateFunction.H | 8 +- .../RAS/TJunction/constant/fvOptions} | 33 +- .../mixerVessel2D/{0/p_rgh => 0.orig/T} | 9 +- .../laminar/mixerVessel2D/0/alpha.air | 3119 ----------------- .../laminar/mixerVessel2D/0/alpha.mercury | 3119 ----------------- .../laminar/mixerVessel2D/0/alpha.oil | 3119 ----------------- .../laminar/mixerVessel2D/0/alpha.water | 3119 ----------------- .../laminar/mixerVessel2D/Allclean | 3 +- .../laminar/mixerVessel2D/Allrun | 4 + .../laminar/mixerVessel2D/makeMesh | 1 - .../laminar/mixerVessel2D/system/controlDict | 59 +- .../laminar/mixerVessel2D/system/fvSchemes | 1 + .../laminar/mixerVessel2D/system/fvSolution | 4 +- 37 files changed, 1668 insertions(+), 12542 deletions(-) create mode 100644 src/functionObjects/solvers/energyTransport/energyTransport.C create mode 100644 src/functionObjects/solvers/energyTransport/energyTransport.H create mode 100644 src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C create mode 100644 src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.H create mode 100644 src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.C create mode 100644 src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H create mode 100644 src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C create mode 100644 src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H rename tutorials/{multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/U => compressible/rhoPimpleFoam/RAS/TJunction/constant/fvOptions} (67%) rename tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/{0/p_rgh => 0.orig/T} (86%) delete mode 100644 tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.air delete mode 100644 tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.mercury delete mode 100644 tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.oil delete mode 100644 tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.water diff --git a/src/functionObjects/solvers/Make/files b/src/functionObjects/solvers/Make/files index 2b8e8f8d8e1..ce5306b1c83 100644 --- a/src/functionObjects/solvers/Make/files +++ b/src/functionObjects/solvers/Make/files @@ -1,3 +1,4 @@ scalarTransport/scalarTransport.C +energyTransport/energyTransport.C LIB = $(FOAM_LIBBIN)/libsolverFunctionObjects diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.C b/src/functionObjects/solvers/energyTransport/energyTransport.C new file mode 100644 index 00000000000..a8870378807 --- /dev/null +++ b/src/functionObjects/solvers/energyTransport/energyTransport.C @@ -0,0 +1,487 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "energyTransport.H" +#include "surfaceFields.H" +#include "fvmDdt.H" +#include "fvmDiv.H" +#include "fvmLaplacian.H" +#include "fvmSup.H" +#include "turbulentTransportModel.H" +#include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(energyTransport, 0); + + addToRunTimeSelectionTable + ( + functionObject, + energyTransport, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::volScalarField& Foam::functionObjects::energyTransport::transportedField() +{ + if (!foundObject<volScalarField>(fieldName_)) + { + tmp<volScalarField> tfldPtr + ( + new volScalarField + ( + IOobject + ( + fieldName_, + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) + ); + store(fieldName_, tfldPtr); + } + + return lookupObjectRef<volScalarField>(fieldName_); +} + + +Foam::tmp<Foam::volScalarField> +Foam::functionObjects::energyTransport::kappaEff() const +{ + // Incompressible + { + typedef incompressible::turbulenceModel turbType; + + const turbType* turbPtr = lookupObjectPtr<turbType> + ( + turbulenceModel::propertiesName + ); + + if (turbPtr) + { + return tmp<volScalarField> + ( + new volScalarField + ( + kappa() + Cp()*turbPtr->nut()*rho()/Prt_ + ) + ); + } + } + + FatalErrorInFunction + << "Turbulence model not found" << exit(FatalError); + return tmp<volScalarField>(); +} + + +Foam::tmp<Foam::volScalarField> +Foam::functionObjects::energyTransport::rho() const +{ + tmp<volScalarField> trho + ( + new volScalarField + ( + IOobject + ( + "trho", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + rho_ + ) + ); + + if (phases_.size()) + { + trho.ref() = lookupObject<volScalarField>(rhoName_); + } + return trho; +} + + +Foam::tmp<Foam::volScalarField> +Foam::functionObjects::energyTransport::Cp() const +{ + if (phases_.size()) + { + tmp<volScalarField> tCp(phases_[0]*Cps_[0]); + + for (label i = 1; i < phases_.size(); i++) + { + tCp.ref() += phases_[i]*Cps_[i]; + } + return tCp; + } + + tmp<volScalarField> tCp + ( + new volScalarField + ( + IOobject + ( + "tCp", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + Cp_ + ) + ); + + return tCp; +} + + +Foam::tmp<Foam::volScalarField> +Foam::functionObjects::energyTransport::kappa() const +{ + if (phases_.size()) + { + tmp<volScalarField> tkappa(phases_[0]*kappas_[0]); + + for (label i = 1; i < phases_.size(); i++) + { + tkappa.ref() += phases_[i]*kappas_[i]; + } + return tkappa; + } + + tmp<volScalarField> tkappa + ( + new volScalarField + ( + IOobject + ( + "tkappa", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + kappa_ + ) + ); + + return tkappa; +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::energyTransport::energyTransport +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + fieldName_(dict.lookupOrDefault<word>("field", "T")), + phiName_(dict.lookupOrDefault<word>("phi", "phi")), + rhoName_(dict.lookupOrDefault<word>("rho", "rho")), + nCorr_(0), + schemesField_("unknown-schemesField"), + fvOptions_(mesh_), + multiphaseThermo_(dict.subOrEmptyDict("phaseThermos")), + Cp_ + ( + dict.lookupOrDefault + ( + "Cp", + dimensionedScalar("Cp", dimEnergy/dimMass/dimTemperature, 0) + ) + ), + kappa_ + ( + dict.lookupOrDefault + ( + "kappa", + dimensionedScalar + ( + "kappa", + dimEnergy/dimTime/dimLength/dimTemperature, + 0 + ) + ) + ), + rho_ + ( + dict.lookupOrDefault("rhoInf", dimensionedScalar("rho", dimDensity, 0)) + ), + Prt_(dict.lookupOrDefault("Prt", dimensionedScalar("Prt", dimless, 1))), + rhoCp_ + ( + IOobject + ( + "rhoCp", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("rhoCp", dimEnergy/dimTemperature/dimVolume, 0.0) + ) +{ + read(dict); + + // If the flow is multiphase + if (!multiphaseThermo_.empty()) + { + Cps_.setSize(multiphaseThermo_.size()); + kappas_.setSize(Cps_.size()); + phaseNames_.setSize(Cps_.size()); + + label phasei = 0; + forAllConstIters(multiphaseThermo_, iter) + { + const word& key = iter().keyword(); + + if (!multiphaseThermo_.isDict(key)) + { + FatalErrorInFunction + << "Found non-dictionary entry " << iter() + << " in top-level dictionary " << multiphaseThermo_ + << exit(FatalError); + } + + const dictionary& dict = multiphaseThermo_.subDict(key); + + phaseNames_[phasei] = key; + + Cps_.set + ( + phasei, + new dimensionedScalar + ( + "Cp", + dimEnergy/dimMass/dimTemperature, + dict.lookup("Cp") + ) + ); + + kappas_.set + ( + phasei, + new dimensionedScalar //[J/m/s/K] + ( + "kappa", + dimEnergy/dimTime/dimLength/dimTemperature, + dict.lookup("kappa") + ) + ); + + ++phasei; + } + + phases_.setSize(phaseNames_.size()); + forAll(phaseNames_, i) + { + phases_.set + ( + i, + mesh_.lookupObjectRefPtr<volScalarField>(phaseNames_[i]) + ); + } + + rhoCp_ = rho()*Cp(); + rhoCp_.oldTime(); + } + else + { + if (Cp_.value() == 0.0 || kappa_.value() == 0.0) + { + FatalErrorInFunction + << " Multiphase thermo dictionary not found and Cp/kappa " + << " for single phase are zero. Please entry either" + << exit(FatalError); + } + + } + + // Force creation of transported field so any BCs using it can + // look it up + volScalarField& s = transportedField(); + s.correctBoundaryConditions(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::energyTransport::~energyTransport() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::energyTransport::read(const dictionary& dict) +{ + fvMeshFunctionObject::read(dict); + + dict.readIfPresent("phi", phiName_); + dict.readIfPresent("rho", rhoName_); + + schemesField_ = dict.lookupOrDefault("schemesField", fieldName_); + + dict.readIfPresent("nCorr", nCorr_); + + if (dict.found("fvOptions")) + { + fvOptions_.reset(dict.subDict("fvOptions")); + } + + return true; +} + + +bool Foam::functionObjects::energyTransport::execute() +{ + volScalarField& s = transportedField(); + + Log << type() << " execute: " << s.name() << endl; + + const surfaceScalarField& phi = + mesh_.lookupObject<surfaceScalarField>(phiName_); + + // Calculate the diffusivity + const volScalarField kappaEff("kappaEff", this->kappaEff()); + + word divScheme("div(phi," + schemesField_ + ")"); + word laplacianScheme + ( + "laplacian(kappaEff," + schemesField_ + ")" + ); + + // Set under-relaxation coeff + scalar relaxCoeff = 0.0; + if (mesh_.relaxEquation(schemesField_)) + { + relaxCoeff = mesh_.equationRelaxationFactor(schemesField_); + } + + if (phi.dimensions() == dimMass/dimTime) + { + rhoCp_ = rho()*Cp(); + const surfaceScalarField rhoCpPhi(fvc::interpolate(Cp())*phi); + + for (label i = 0; i <= nCorr_; i++) + { + fvScalarMatrix sEqn + ( + fvm::ddt(rhoCp_, s) + + fvm::div(rhoCpPhi, s, divScheme) + - fvm::Sp(fvc::ddt(rhoCp_) + fvc::div(rhoCpPhi), s) + - fvm::laplacian(kappaEff, s, laplacianScheme) + == + fvOptions_(rhoCp_, s) + ); + + sEqn.relax(relaxCoeff); + + fvOptions_.constrain(sEqn); + + sEqn.solve(mesh_.solverDict(schemesField_)); + } + } + else if (phi.dimensions() == dimVolume/dimTime) + { + dimensionedScalar rhoCp(rho_*Cp_); + + const surfaceScalarField CpPhi(rhoCp*phi); + + tmp<volScalarField> trhoCp + ( + new volScalarField + ( + IOobject + ( + "trhoCp", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + rhoCp + ) + ); + + for (label i = 0; i <= nCorr_; i++) + { + fvScalarMatrix sEqn + ( + fvm::ddt(rhoCp, s) + + fvm::div(CpPhi, s, divScheme) + - fvm::laplacian(kappaEff, s, laplacianScheme) + == + fvOptions_(trhoCp.ref(), s) + ); + + sEqn.relax(relaxCoeff); + + fvOptions_.constrain(sEqn); + + sEqn.solve(mesh_.solverDict(schemesField_)); + } + } + else + { + FatalErrorInFunction + << "Incompatible dimensions for phi: " << phi.dimensions() << nl + << "Dimensions should be " << dimMass/dimTime << " or " + << dimVolume/dimTime << exit(FatalError); + } + + Log << endl; + + return true; +} + + +bool Foam::functionObjects::energyTransport::write() +{ + return true; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.H b/src/functionObjects/solvers/energyTransport/energyTransport.H new file mode 100644 index 00000000000..07dd407d484 --- /dev/null +++ b/src/functionObjects/solvers/energyTransport/energyTransport.H @@ -0,0 +1,323 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::energyTransport + +Group + grpSolversFunctionObjects + +Description + Evolves a simplified energy transport equation for incompressible flows. + It takes into account the inertia, conduction and convection terms plus + a source. + + - The field name must be temperature and its BC's specified in the time + directory. + - The turbulence model should be incompressible + - In order to use in a incompressible multi phase a list of thermal + properties are needed. See bellow + + +Usage + Example of function object specification to solve a energy transport + equation for a single phase flow plus a source term + \verbatim + functions + { + energy + { + type energyTransport; + libs ("libenergyTransportFunctionObjects.so"); + + enabled true; + writeControl outputTime; + writeInterval 1; + + field T; + + // volumetric Flux + phi phi; + + // Thermal properties + Cp Cp [J/kg/K] 1e3; + kappa kappa [W/m/K] 0.0257; + rhoInf rho [kg/m^3] 1.2; + + write true; + + fvOptions + { + viscousDissipation + { + type viscousDissipation; + enabled true; + + viscousDissipationCoeffs + { + fields (T); + rhoInf $....rhoInf; + } + } + } + } + } + \endverbatim + + Example of function object specification to solve a energy transport + equation for a multiphase phase flow plus a source term + + equation: + \verbatim + functions + { + energy + { + type energyTransport; + libs ("libenergyTransportFunctionObjects.so"); + + enabled true; + writeControl outputTime; + writeInterval 1; + + field T; + + // rho field name + rho rho; + // mass flux for multiphase + phi rhoPhi; + + write true; + + // Thermal properties of the phases + phaseThermos + { + alpha.air + { + Cp 1e3; + kappa 0.0243; + } + alpha.mercury + { + Cp 140; + kappa 8.2; + } + alpha.oil + { + Cp 2e3; + kappa 0.2; + } + alpha.water + { + Cp 4e3; + kappa 0.6; + } + } + + + fvOptions + { + viscousDissipation + { + type viscousDissipation; + enabled true; + + viscousDissipationCoeffs + { + fields (T); + rho rho; //rho Field + } + } + } + } + } + \endverbatim + + Where the entries comprise: + \table + Property | Description | Required | Default value + type | Type name: energyTransport | yes | + field | Name of the scalar field | no | T + phi | Name of flux field | no | phi + rho | Name of density field | no | rho + nCorr | Number of correctors | no | 0 + schemesField | Name of field to specify schemes | no | field name + fvOptions | List of scalar sources | no | + Cp | Heat capacity for single phase | no | 0 + rhoInf | Density for single phase | no | 0 + kappa | Thermal conductivity for single phase | no | 0 + Prt | Turbulent Prandt number | no | 1.0 + phaseThermos | Dictionary for multi-phase thermo |no | null + fvOptions | Opotional extra sources | no | null + \endtable + +See also + Foam::functionObjects::fvMeshFunctionObject + +SourceFiles + energyTransport.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_energyTransport_H +#define functionObjects_energyTransport_H + +#include "fvMeshFunctionObject.H" +#include "volFields.H" +#include "fvOptionList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class energyTransport Declaration +\*---------------------------------------------------------------------------*/ + +class energyTransport +: + public fvMeshFunctionObject +{ + // Private data + + //- Name of the transport field. + word fieldName_; + + //- Name of flux field + word phiName_; + + //- Name of density field + word rhoName_; + + //- Number of corrector iterations (optional) + label nCorr_; + + //- Name of field whose schemes are used (optional) + word schemesField_; + + //- Run-time selectable finite volume options, e.g. sources, constraints + fv::optionList fvOptions_; + + //- Dictionary for multiphase thermos + dictionary multiphaseThermo_; + + //- List of phase names + wordList phaseNames_; + + //- List of phase heat capacities + PtrList<dimensionedScalar> Cps_; + + //- List of phase thermal diffusivity for temperature [J/m/s/K] + PtrList<dimensionedScalar> kappas_; + + //- Unallocated phase list + UPtrList<volScalarField> phases_; + + //- Heat capacity for single phase flows + dimensionedScalar Cp_; + + //- Thermal diffusivity for temperature for single phase flows + dimensionedScalar kappa_; + + //- Density for single phase flows + dimensionedScalar rho_; + + //- Turbulent Prandt number + dimensionedScalar Prt_; + + //- rhoCp + volScalarField rhoCp_; + + + // Private Member Functions + + //- Return reference to registered transported field + volScalarField& transportedField(); + + //- Return the diffusivity field + tmp<volScalarField> kappaEff() const; + + //- Return rho field + tmp<volScalarField> rho() const; + + //- Return Cp + tmp<volScalarField> Cp() const; + + //- Return kappa + tmp<volScalarField> kappa() const; + + //- Disallow default bitwise copy construct + energyTransport(const energyTransport&) = delete; + + //- Disallow default bitwise assignment + void operator=(const energyTransport&) = delete; + + +public: + + //- Runtime type information + TypeName("energyTransport"); + + + // Constructors + + //- Construct from Time and dictionary + energyTransport + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + //- Destructor + virtual ~energyTransport(); + + + // Member Functions + + //- Read the energyTransport data + virtual bool read(const dictionary&); + + //- Calculate the energyTransport + virtual bool execute(); + + //- Do nothing. + // The volScalarField is registered and written automatically + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvOptions/Make/files b/src/fvOptions/Make/files index 9a8376a95cd..18c3d6fcb26 100644 --- a/src/fvOptions/Make/files +++ b/src/fvOptions/Make/files @@ -42,6 +42,7 @@ $(derivedSources)/solidificationMeltingSource/solidificationMeltingSource.C $(derivedSources)/solidificationMeltingSource/solidificationMeltingSourceIO.C $(derivedSources)/tabulatedAccelerationSource/tabulatedAccelerationSource.C $(derivedSources)/tabulatedAccelerationSource/tabulated6DoFAcceleration/tabulated6DoFAcceleration.C +$(derivedSources)/viscousDissipation/viscousDissipation.C interRegion = sources/interRegion $(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C new file mode 100644 index 00000000000..9b4e9800890 --- /dev/null +++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C @@ -0,0 +1,222 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "viscousDissipation.H" +#include "fvMatrices.H" +#include "turbulentTransportModel.H" +#include "turbulentFluidThermoModel.H" +#include "basicThermo.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + defineTypeNameAndDebug(viscousDissipation, 0); + + addToRunTimeSelectionTable + ( + option, + viscousDissipation, + dictionary + ); +} +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> Foam::fv::viscousDissipation::rho() const +{ + tmp<volScalarField> trho + ( + new volScalarField + ( + IOobject + ( + "trho", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + rho_ + ) + ); + + if (rho_.value() > 0) + { + return trho; + } + else if (rhoName_ != "none") + { + trho.ref() = mesh_.lookupObject<volScalarField>(rhoName_); + return trho; + } + + FatalErrorInFunction + << "Neither rhoName nor rho are specified." + << exit(FatalError); + + return tmp<volScalarField>(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fv::viscousDissipation::viscousDissipation +( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + option(sourceName, modelType, dict, mesh), + UName_(coeffs_.lookupOrDefault<word>("U", "U")), + rhoName_(coeffs_.lookupOrDefault<word>("rho", "none")), + rho_ + ( + coeffs_.lookupOrDefault + ( + "rhoInf", + dimensionedScalar("rho", dimDensity, 0) + ) + ) +{ + const basicThermo* thermoPtr = + mesh_.lookupObjectPtr<basicThermo>(basicThermo::dictName); + + if (thermoPtr) + { + fieldNames_.setSize(1, thermoPtr->he().name()); + } + + if (fieldNames_.empty()) + { + coeffs_.lookup("fields") >> fieldNames_; + } + + if (fieldNames_.size() != 1) + { + FatalErrorInFunction + << "settings are:" << fieldNames_ << exit(FatalError); + } + + applied_.setSize(fieldNames_.size(), false); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp<Foam::volSymmTensorField> Foam::fv::viscousDissipation:: +devRhoReff() const +{ + // Incompressible + { + typedef incompressible::turbulenceModel turbType; + + const turbType* turbPtr = + mesh_.lookupObjectPtr<turbType>(turbulenceModel::propertiesName); + + if (turbPtr) + { + return tmp<volSymmTensorField>(rho()*turbPtr->devRhoReff()); + } + } + + // Compressible + { + typedef compressible::turbulenceModel turbType; + + const turbType* turbPtr = + mesh_.lookupObjectPtr<turbType>(turbulenceModel::propertiesName); + + if (turbPtr) + { + return tmp<volSymmTensorField>(turbPtr->devRhoReff()); + } + } + + FatalErrorInFunction + << " The turbulence model is not found in the database." + << exit(FatalError); + + return tmp<volSymmTensorField>(); +} + + +void Foam::fv::viscousDissipation::addSup +( + const volScalarField& rho, + fvMatrix<scalar>& eqn, + const label fieldi +) +{ + typedef typename outerProduct<vector, vector>::type GradType; + typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType; + + word gradUName("grad(" + UName_ + ')'); + + tmp<GradFieldType> tgradU + ( + new GradFieldType + ( + IOobject + ( + "gradU", + mesh_.time().timeName(), + mesh_.time(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedTensor("zero", inv(dimTime) , tensor::zero) + ) + ); + + // Cached? + const GradFieldType* gradUPtr = + mesh_.lookupObjectPtr<GradFieldType>(gradUName); + + if (gradUPtr) + { + tgradU.ref() = *gradUPtr; + } + else + { + const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_); + tgradU.ref() = fvc::grad(U); + } + + const volScalarField D("D", devRhoReff() && tgradU.ref()); + + eqn -= D; +} + + +// ************************************************************************* // diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.H b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.H new file mode 100644 index 00000000000..5902080125e --- /dev/null +++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.H @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::fv::viscousDissipation + +Group + grpFvOptionsSources + +Description + Calculates and applies the viscous dissipation energy source to the energy + equation. + +Usage + Example usage: + \verbatim + fields (h); // Name of energy field + \endverbatim + +SourceFiles + viscousDissipation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef viscousDissipation_H +#define viscousDissipation_H + +#include "fvOption.H" +#include "uniformDimensionedFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class viscousDissipation Declaration +\*---------------------------------------------------------------------------*/ + +class viscousDissipation +: + public option +{ + // Private data + + //- Name of velocity field; default = U + word UName_; + + //- Name of the rho field for incompressible solvers + word rhoName_; + + //- Density for single phase flows + dimensionedScalar rho_; + + + // Private Member Functions + + //- Return the viscosity field + tmp<volSymmTensorField> devRhoReff() const; + + //- Disallow default bitwise copy construct + viscousDissipation(const viscousDissipation&) = delete; + + //- Disallow default bitwise assignment + void operator=(const viscousDissipation&) = delete; + +private: + + // Private member functions + + + //- Return rho field + tmp<volScalarField> rho() const; + + +public: + + //- Runtime type information + TypeName("viscousDissipation"); + + + // Constructors + + //- Construct from explicit source name and mesh + viscousDissipation + ( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh + ); + + + // Member Functions + + // Evaluate + + //- Add explicit contribution to compressible energy equation + virtual void addSup + ( + const volScalarField& rho, + fvMatrix<scalar>& eqn, + const label fieldi + ); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict) + { + return true; + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/transportModels/incompressible/Make/files b/src/transportModels/incompressible/Make/files index b181820bd83..0c349c3bf57 100644 --- a/src/transportModels/incompressible/Make/files +++ b/src/transportModels/incompressible/Make/files @@ -7,6 +7,7 @@ viscosityModels/BirdCarreau/BirdCarreau.C viscosityModels/HerschelBulkley/HerschelBulkley.C viscosityModels/Casson/Casson.C viscosityModels/strainRateFunction/strainRateFunction.C +viscosityModels/Arrhenius/Arrheniuss.C transportModel/transportModel.C singlePhaseTransportModel/singlePhaseTransportModel.C diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.C b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.C new file mode 100644 index 00000000000..2e5014f7497 --- /dev/null +++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.C @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + + +#include "Arrhenius.H" + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template<class ViscousModel> +Foam::tmp<Foam::volScalarField> +Foam::viscosityModels::Arrhenius<ViscousModel>::calcNu +( + const volScalarField& field +) const +{ + return exp(-alpha_*(field - Talpha_)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class ViscousModel> +Foam::viscosityModels::Arrhenius<ViscousModel>::Arrhenius +( + const word& name, + const dictionary& viscosityProperties, + const volVectorField& U, + const surfaceScalarField& phi +) +: + ViscousModel(name, viscosityProperties, U, phi), + ArrheniusCoeffs_ + ( + viscosityProperties.optionalSubDict(typeName + "Coeffs") + ), + alpha_("alpha", inv(dimTemperature), ArrheniusCoeffs_), + Talpha_("Talpha", dimTemperature, ArrheniusCoeffs_), + fieldName_(ArrheniusCoeffs_.lookupOrDefault<word>("field","T")), + mesh_(U.mesh()) +{ + const volScalarField* fieldPtr = + mesh_.lookupObjectPtr<volScalarField>(fieldName_); + + if (fieldPtr) + { + this->nu_ *= calcNu(*fieldPtr); + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template<class ViscousModel> +bool Foam::viscosityModels::Arrhenius<ViscousModel>::read +( + const dictionary& viscosityProperties +) +{ + viscosityModel::read(viscosityProperties); + + ArrheniusCoeffs_ = + viscosityProperties.optionalSubDict(typeName + "Coeffs"); + + ArrheniusCoeffs_.lookup("alpha") >> alpha_; + ArrheniusCoeffs_.lookup("Talpha") >> Talpha_; + + return true; +} + + +// ************************************************************************* // diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H new file mode 100644 index 00000000000..a3b973e6e69 --- /dev/null +++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H @@ -0,0 +1,145 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::viscosityModels::Arrhenius + +Description + Arrhenius type of dependency on a given scalar field name. Most likely + temperature. The expression is as follow: + \verbatim + mu = exp(-alpha_*(T - Talpha_)) + \endverbatim + +SourceFiles + Arrhenius.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Arrhenius_H +#define Arrhenius_H + +#include "viscosityModel.H" +#include "dimensionedScalar.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace viscosityModels +{ + +/*---------------------------------------------------------------------------*\ + Class Arrhenius Declaration +\*---------------------------------------------------------------------------*/ + +template<class ViscousModel> +class Arrhenius +: + public ViscousModel +{ + // Private data + + dictionary ArrheniusCoeffs_; + + // Model coefficients + dimensionedScalar alpha_; + dimensionedScalar Talpha_; + + //- Field used for as temperature + word fieldName_; + + //- Auto pointer for scalar field + autoPtr<volScalarField> field_; + + //- Refernce to mesh + const fvMesh& mesh_; + + + // Private Member Functions + + //- Calculate and return the laminar viscosity + tmp<volScalarField> calcNu(const volScalarField&) const; + + +public: + +// //- Runtime type information + TypeName("Arrhenius"); + + + // Constructors + + //- Construct from components + Arrhenius + ( + const word& name, + const dictionary& viscosityProperties, + const volVectorField& U, + const surfaceScalarField& phi + ); + + + //- Destructor + virtual ~Arrhenius() + {} + + + // Member Functions + + //- Correct the laminar viscosity + virtual void correct() + { + ViscousModel::correct(); + + const volScalarField* fieldPtr = + mesh_.lookupObjectPtr<volScalarField>(fieldName_); + + if (fieldPtr) + { + this->nu_ *= calcNu(*fieldPtr); + } + } + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace viscosityModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "Arrhenius.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C new file mode 100644 index 00000000000..a19e7fa585f --- /dev/null +++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "makeArrheniusTypes.H" + +#include "Arrhenius.H" +#include "BirdCarreau.H" +#include "Casson.H" +#include "CrossPowerLaw.H" +#include "HerschelBulkley.H" +#include "Newtonian.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeArrheniusTypes(Arrhenius, BirdCarreau); +makeArrheniusTypes(Arrhenius, Casson); +makeArrheniusTypes(Arrhenius, CrossPowerLaw); +makeArrheniusTypes(Arrhenius, HerschelBulkley); +makeArrheniusTypes(Arrhenius, Newtonian); + + +// ************************************************************************* // diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H b/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H new file mode 100644 index 00000000000..7be96ecefc8 --- /dev/null +++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef makeArrheniusTypes_H +#define makeArrheniusTypes_H + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeArrheniusTypes(ArrheniusType, visType) \ + \ + namespace Foam \ + { \ + namespace viscosityModels \ + { \ + typedef ArrheniusType<visType> ArrheniusType##visType; \ + \ + addNamedToRunTimeSelectionTable \ + ( \ + viscosityModel, \ + ArrheniusType##visType, \ + dictionary, \ + ArrheniusType##visType \ + ); \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + ArrheniusType##visType, \ + #ArrheniusType"<"#visType">", \ + 0 \ + ); \ + } \ + } + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C index cb486982c67..11c992916ae 100644 --- a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C +++ b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,7 +44,7 @@ namespace viscosityModels } -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::viscosityModels::BirdCarreau::calcNu() const @@ -52,7 +52,7 @@ Foam::viscosityModels::BirdCarreau::calcNu() const return nuInf_ + (nu0_ - nuInf_) - *pow(scalar(1) + pow(k_*strainRate(), a_), (n_ - 1.0)/a_); + * pow(scalar(1) + pow(k_*strainRate(), a_), (n_ - 1.0)/a_); } diff --git a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H index 1a1db601f75..02dc3ebc3c4 100644 --- a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H +++ b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H @@ -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) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,10 +67,14 @@ class BirdCarreau dimensionedScalar n_; dimensionedScalar a_; - volScalarField nu_; +protected: + + // Protected Data + + volScalarField nu_; - // Private Member Functions + // Protected Member Functions //- Calculate and return the laminar viscosity tmp<volScalarField> calcNu() const; diff --git a/src/transportModels/incompressible/viscosityModels/Casson/Casson.C b/src/transportModels/incompressible/viscosityModels/Casson/Casson.C index 43e2807f138..ff75e828d1d 100644 --- a/src/transportModels/incompressible/viscosityModels/Casson/Casson.C +++ b/src/transportModels/incompressible/viscosityModels/Casson/Casson.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,7 +44,7 @@ namespace viscosityModels } -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::viscosityModels::Casson::calcNu() const diff --git a/src/transportModels/incompressible/viscosityModels/Casson/Casson.H b/src/transportModels/incompressible/viscosityModels/Casson/Casson.H index abdfe70beda..865e11ab7a7 100644 --- a/src/transportModels/incompressible/viscosityModels/Casson/Casson.H +++ b/src/transportModels/incompressible/viscosityModels/Casson/Casson.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -90,10 +90,16 @@ class Casson dimensionedScalar nuMin_; dimensionedScalar nuMax_; + + +protected: + + // Protected data + volScalarField nu_; - // Private Member Functions + // Protected Member Functions //- Calculate and return the laminar viscosity tmp<volScalarField> calcNu() const; diff --git a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C index 6b9ac760a78..3f7dbb3ff95 100644 --- a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C +++ b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,7 +45,7 @@ namespace viscosityModels } -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::viscosityModels::CrossPowerLaw::calcNu() const diff --git a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H index a0f9ffe6baf..5b9bd885c19 100644 --- a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H +++ b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H @@ -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) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,9 +63,15 @@ class CrossPowerLaw dimensionedScalar m_; dimensionedScalar n_; + +protected: + + // Protected data + volScalarField nu_; - // Private Member Functions + + // Protected Member Functions //- Calculate and return the laminar viscosity tmp<volScalarField> calcNu() const; diff --git a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C index 8f1656df140..e6af2ad62bd 100644 --- a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C +++ b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,7 +45,7 @@ namespace viscosityModels } -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::viscosityModels::HerschelBulkley::calcNu() const diff --git a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H index df105b5807c..a48eb988a18 100644 --- a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H +++ b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H @@ -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) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,10 +63,15 @@ class HerschelBulkley dimensionedScalar tau0_; dimensionedScalar nu0_; + +protected: + + // Protected data + volScalarField nu_; - // Private Member Functions + // Protected Member Functions //- Calculate and return the laminar viscosity tmp<volScalarField> calcNu() const; diff --git a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C index 2e6fd44423b..b0121ba1c99 100644 --- a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C +++ b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.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) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. diff --git a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H index 481bbf945ec..abe6583fa13 100644 --- a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H +++ b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H @@ -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) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,11 +58,14 @@ class Newtonian dimensionedScalar nu0_; - volScalarField nu_; - public: + // Protected data + + volScalarField nu_; + + //- Runtime type information TypeName("Newtonian"); diff --git a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C index ec84ba20285..ecdc46cc1bc 100644 --- a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C +++ b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,7 +45,7 @@ namespace viscosityModels } -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::viscosityModels::powerLaw::calcNu() const diff --git a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H index e355a319d85..45343178523 100644 --- a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H +++ b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H @@ -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) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,10 +63,15 @@ class powerLaw dimensionedScalar nuMin_; dimensionedScalar nuMax_; + +protected: + + // Protected data + volScalarField nu_; - // Private Member Functions + // Protected Member Functions //- Calculate and return the laminar viscosity tmp<volScalarField> calcNu() const; diff --git a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C index 29e0735bab1..22f117c55bb 100644 --- a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C +++ b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. diff --git a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H index 90c102e322b..d31099f4d0f 100644 --- a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H +++ b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -76,7 +76,11 @@ class strainRateFunction //- Strain-rate function autoPtr<Function1<scalar>> strainRateFunction_; - //- Current viscosity field + +protected: + + // Protected data + volScalarField nu_; diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/U b/tutorials/compressible/rhoPimpleFoam/RAS/TJunction/constant/fvOptions similarity index 67% rename from tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/U rename to tutorials/compressible/rhoPimpleFoam/RAS/TJunction/constant/fvOptions index 2b8e9315bf5..ac606224c7e 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/U +++ b/tutorials/compressible/rhoPimpleFoam/RAS/TJunction/constant/fvOptions @@ -9,35 +9,14 @@ FoamFile { version 2.0; format ascii; - class volVectorField; - location "0"; - object U; + class dictionary; + location "constant"; + object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 1 -1 0 0 0 0]; - -internalField uniform (0 0 0); - -boundaryField +viscousDissipation { - rotor - { - type noSlip; - } - stator - { - type noSlip; - } - front - { - type empty; - } - back - { - type empty; - } + type viscousDissipation; + enabled true; } - - // ************************************************************************* // diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/p_rgh b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0.orig/T similarity index 86% rename from tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/p_rgh rename to tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0.orig/T index 8c6ca7dcf9a..4362683670b 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/p_rgh +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0.orig/T @@ -10,19 +10,20 @@ FoamFile version 2.0; format ascii; class volScalarField; - object p_rgh; + object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -dimensions [1 -1 -2 0 0 0 0]; +dimensions [0 0 0 1 0 0 0]; -internalField uniform 0; +internalField uniform 300; boundaryField { rotor { - type zeroGradient; + type fixedValue; + value uniform 305; } stator diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.air b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.air deleted file mode 100644 index 3e992f20f64..00000000000 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.air +++ /dev/null @@ -1,3119 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class volScalarField; - location "0"; - object alpha.air; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 0 0 0 0 0 0]; - -internalField nonuniform List<scalar> -3072 -( -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -) -; - -boundaryField -{ - rotor - { - type zeroGradient; - } - stator - { - type zeroGradient; - } - front - { - type empty; - } - back - { - type empty; - } -} - - -// ************************************************************************* // diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.mercury b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.mercury deleted file mode 100644 index dfef5159a13..00000000000 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.mercury +++ /dev/null @@ -1,3119 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class volScalarField; - location "0"; - object alpha.mercury; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 0 0 0 0 0 0]; - -internalField nonuniform List<scalar> -3072 -( -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -) -; - -boundaryField -{ - rotor - { - type zeroGradient; - } - stator - { - type zeroGradient; - } - front - { - type empty; - } - back - { - type empty; - } -} - - -// ************************************************************************* // diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.oil b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.oil deleted file mode 100644 index 04a96b44712..00000000000 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.oil +++ /dev/null @@ -1,3119 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class volScalarField; - location "0"; - object alpha.oil; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 0 0 0 0 0 0]; - -internalField nonuniform List<scalar> -3072 -( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -) -; - -boundaryField -{ - rotor - { - type zeroGradient; - } - stator - { - type zeroGradient; - } - front - { - type empty; - } - back - { - type empty; - } -} - - -// ************************************************************************* // diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.water b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.water deleted file mode 100644 index a8704851bf1..00000000000 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.water +++ /dev/null @@ -1,3119 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class volScalarField; - location "0"; - object alpha.water; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 0 0 0 0 0 0]; - -internalField nonuniform List<scalar> -3072 -( -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -) -; - -boundaryField -{ - rotor - { - type zeroGradient; - } - stator - { - type zeroGradient; - } - front - { - type empty; - } - back - { - type empty; - } -} - - -// ************************************************************************* // diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean index feb117fb229..e2f275d9fd6 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean @@ -2,7 +2,6 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions -cleanCase -rm 0/alphas > /dev/null 2>&1 +cleanCase0 #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun index 6aeae155532..69a4d43b491 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun @@ -3,6 +3,10 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions runApplication ./makeMesh +restore0Dir +topoSet +setFields +setsToZones -noFlipMap runApplication $(getApplication) #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh index 4065edb322f..3cb213572c2 100755 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh @@ -5,4 +5,3 @@ blockMesh topoSet setsToZones -noFlipMap -#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict index b36bb2f3081..e983f69bda2 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict @@ -52,5 +52,62 @@ maxAlphaCo 0.5; maxDeltaT 1; - +functions +{ + sTransport + { + type energyTransport; + libs ("libsolverFunctionObjects.so"); + + enabled true; + writeControl outputTime; + writeInterval 1; + + field T; + + rho rho; + phi rhoPhi; + + write true; + + phaseThermos + { + alpha.air + { + Cp 1e3; + kappa 0.0243; + } + alpha.mercury + { + Cp 140; + kappa 8.2; + } + alpha.oil + { + Cp 2e3; + kappa 0.2; + } + alpha.water + { + Cp 4e3; + kappa 0.6; + } + } + + fvOptions + { + viscousDissipation + { + type viscousDissipation; + enabled true; + + viscousDissipationCoeffs + { + fields (T); + rho rho; //rho Field + } + } + } + } +} // ************************************************************************* // diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes index 8cbffcabee2..d333691a533 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes @@ -31,6 +31,7 @@ divSchemes div(phi,alpha) Gauss vanLeer; div(phirb,alpha) Gauss linear; div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; + div(phi,T) Gauss limitedLinear 1; } laplacianSchemes diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution index 29361e67954..c22130bab0d 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution @@ -48,7 +48,7 @@ solvers relTol 0; } - U + "(U|T)" { solver smoothSolver; smoother symGaussSeidel; @@ -71,7 +71,7 @@ relaxationFactors { equations { - "U.*" 1; + ".*" 1; } } -- GitLab From 5c1ec7ecb8ff34b52a083c50dfa796bd4aa1064f Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 25 Oct 2017 08:45:05 +0200 Subject: [PATCH 057/126] ENH: relocate protected List::size(label) to UList (issue #595) - makes it accessible for containers that manage their own storage and derive directly from UList. - DynamicList::min_size() method to access the corresponding SizeMin template parameter. - ensure consistency in the reserve size for the constructor DynamicList<..> lst(N); now has identical sizing as DynamicList<..> lst(); reserve(N); --- .../Lists/DynamicList/DynamicList.H | 16 ++++--- .../Lists/DynamicList/DynamicListI.H | 46 +++++++++---------- src/OpenFOAM/containers/Lists/List/List.H | 11 ----- src/OpenFOAM/containers/Lists/List/ListI.H | 30 ++++-------- src/OpenFOAM/containers/Lists/UList/UList.H | 6 ++- src/OpenFOAM/containers/Lists/UList/UListI.H | 8 ++++ src/OpenFOAM/containers/Lists/UList/UListIO.C | 4 +- .../fields/Fields/DynamicField/DynamicField.H | 6 ++- .../Fields/DynamicField/DynamicFieldI.H | 28 +++++++---- 9 files changed, 82 insertions(+), 73 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index a5fe88bd503..20f9258bda0 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -117,14 +117,14 @@ public: //- Construct null inline DynamicList(); - //- Construct given size. + //- Construct an empty list with given reserve size. explicit inline DynamicList(const label nElem); //- Construct with given size and value for all elements. inline DynamicList(const label nElem, const T& val); //- Construct with given size initializing all elements to zero - inline DynamicList(const label s, const zero); + inline DynamicList(const label nElem, const zero); //- Copy construct. inline DynamicList(const DynamicList<T, SizeMin>& lst); @@ -174,10 +174,14 @@ public: // Member Functions - // Access + // Access + + //- Normal lower capacity limit - the SizeMin template parameter + inline label min_size() const; + + //- Size of the underlying storage. + inline label capacity() const; - //- Size of the underlying storage. - inline label capacity() const; // Edit @@ -311,7 +315,7 @@ public: //- Return non-const access to an element, resizing list if // necessary - inline T& operator()(const label elemI); + inline T& operator()(const label i); //- Assignment of all addressed entries to the given value inline void operator=(const T& val); diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index 2fcfc660628..c6adaec88fe 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -63,17 +63,11 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList() template<class T, int SizeMin> -inline Foam::DynamicList<T, SizeMin>::DynamicList -( - const label nElem -) +inline Foam::DynamicList<T, SizeMin>::DynamicList(const label nElem) : - List<T>(nElem), - capacity_(nElem) + capacity_(0) { - // We could also enforce sizing granularity - - List<T>::size(0); + reserve(nElem); } @@ -85,7 +79,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(nElem, val), - capacity_(nElem) + capacity_(List<T>::size()) {} @@ -97,7 +91,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(nElem, Zero), - capacity_(nElem) + capacity_(List<T>::size()) {} @@ -108,7 +102,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(lst), - capacity_(lst.size()) + capacity_(List<T>::size()) {} @@ -120,7 +114,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(lst), - capacity_(lst.size()) + capacity_(List<T>::size()) {} @@ -131,7 +125,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(lst), - capacity_(lst.size()) + capacity_(List<T>::size()) {} @@ -157,7 +151,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(begIter, endIter), - capacity_(this->size()) + capacity_(List<T>::size()) {} @@ -168,7 +162,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(lst), - capacity_(lst.size()) + capacity_(List<T>::size()) {} @@ -179,7 +173,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList ) : List<T>(lst), - capacity_(lst.size()) + capacity_(List<T>::size()) {} @@ -234,8 +228,14 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class T, int SizeMin> -inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() -const +inline Foam::label Foam::DynamicList<T, SizeMin>::min_size() const +{ + return SizeMin; +} + + +template<class T, int SizeMin> +inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const { return capacity_; } @@ -730,15 +730,15 @@ inline Foam::label Foam::DynamicList<T, SizeMin>::subset template<class T, int SizeMin> inline T& Foam::DynamicList<T, SizeMin>::operator() ( - const label elemI + const label i ) { - if (elemI >= List<T>::size()) + if (i >= List<T>::size()) { - setSize(elemI + 1); + setSize(i + 1); } - return this->operator[](elemI); + return this->operator[](i); } diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index d4ff38d488b..aaacbda88b2 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -111,13 +111,6 @@ class List ); -protected: - - //- Override size to be inconsistent with allocated storage. - // Use with care - inline void size(const label n); - - public: // Static Member Functions @@ -211,10 +204,6 @@ public: // Member Functions - //- Return the number of elements in the UList - inline label size() const; - - // Edit //- Alias for setSize(const label) diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H index d3549e131b1..f93a099bb49 100644 --- a/src/OpenFOAM/containers/Lists/List/ListI.H +++ b/src/OpenFOAM/containers/Lists/List/ListI.H @@ -151,29 +151,17 @@ inline void Foam::List<T>::resize(const label newSize, const T& val) template<class T> inline T& Foam::List<T>::newElmt(const label i) { - if (i >= this->size()) + const label n = this->size(); + + if (i >= n) { - setSize(2*this->size()); + setSize(2*n); } return UList<T>::operator[](i); } -template<class T> -inline void Foam::List<T>::size(const label n) -{ - UList<T>::size_ = n; -} - - -template<class T> -inline Foam::label Foam::List<T>::size() const -{ - return UList<T>::size_; -} - - template<class T> inline Foam::Xfer<Foam::List<T>> Foam::List<T>::xfer() { @@ -184,7 +172,7 @@ inline Foam::Xfer<Foam::List<T>> Foam::List<T>::xfer() template<class T> inline void Foam::List<T>::append(const T& val) { - setSize(size()+1, val); + setSize(this->size()+1, val); } @@ -200,9 +188,9 @@ inline void Foam::List<T>::append(const UList<T>& lst) label nextFree = this->size(); setSize(nextFree + lst.size()); - forAll(lst, elemI) + forAll(lst, i) { - this->operator[](nextFree++) = lst[elemI]; + this->operator[](nextFree++) = lst[i]; } } @@ -213,9 +201,9 @@ inline void Foam::List<T>::append(const UIndirectList<T>& lst) label nextFree = this->size(); setSize(nextFree + lst.size()); - forAll(lst, elemI) + forAll(lst, i) { - this->operator[](nextFree++) = lst[elemI]; + this->operator[](nextFree++) = lst[i]; } } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 23fee6ab040..5c7999e2294 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -102,6 +102,10 @@ protected: // Protected Member Functions + //- Override size to be inconsistent with allocated storage. + // Use with care + inline void size(const label n); + //- Write the UList with its compound type void writeEntry(Ostream& os) const; @@ -465,7 +469,7 @@ public: friend Ostream& operator<< <T> ( Ostream& os, - const UList<T>& L + const UList<T>& lst ); //- Read List contents from Istream. diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index 36c74ee28b5..e8060ac9bda 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -327,6 +327,14 @@ Foam::UList<T>::crend() const return &v_[-1]; } + +template<class T> +inline void Foam::UList<T>::size(const label n) +{ + size_ = n; +} + + template<class T> inline Foam::label Foam::UList<T>::size() const { diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C index 08d18569172..e6f9a97ad54 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListIO.C +++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C @@ -164,9 +164,9 @@ Foam::Ostream& Foam::UList<T>::writeList // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template<class T> -Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L) +Foam::Ostream& Foam::operator<<(Ostream& os, const UList<T>& lst) { - return L.writeList(os, 10); + return lst.writeList(os, 10); } diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H index ea2f2a7e5b5..1d99fcb6b6b 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H @@ -199,6 +199,10 @@ public: //- Clear the list and delete storage. inline void clearStorage(); + //- Expand the addressable size to fit the allocated capacity. + // Returns the previous addressable size. + inline label expandStorage(); + //- Shrink the allocated space to the number of elements used. // Returns a reference to the DynamicField. inline DynamicField<T, SizeMin>& shrink(); @@ -222,7 +226,7 @@ public: //- Return non-const access to an element, resizing list if // necessary - inline T& operator()(const label elemI); + inline T& operator()(const label i); //- Assignment of all addressed entries to the given value inline void operator=(const T& val); diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H index 658c0b9d1cb..782e2c90eef 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H @@ -310,6 +310,18 @@ inline void Foam::DynamicField<T, SizeMin>::clearStorage() } +template<class T, int SizeMin> +inline Foam::label Foam::DynamicField<T, SizeMin>::expandStorage() +{ + const label nextFree = Field<T>::size(); + + // Allow addressing into the entire list + Field<T>::size(capacity_); + + return nextFree; +} + + template<class T, int SizeMin> inline Foam::DynamicField<T, SizeMin>& Foam::DynamicField<T, SizeMin>::shrink() @@ -317,10 +329,10 @@ Foam::DynamicField<T, SizeMin>::shrink() label nextFree = Field<T>::size(); if (capacity_ > nextFree) { - // use the full list when resizing + // Use the full list when resizing Field<T>::size(capacity_); - // the new size + // The new size capacity_ = nextFree; Field<T>::setSize(capacity_); Field<T>::size(nextFree); @@ -368,9 +380,9 @@ Foam::DynamicField<T, SizeMin>::append label nextFree = List<T>::size(); setSize(nextFree + lst.size()); - forAll(lst, elemI) + forAll(lst, i) { - this->operator[](nextFree++) = lst[elemI]; + this->operator[](nextFree++) = lst[i]; } return *this; } @@ -401,15 +413,15 @@ inline T Foam::DynamicField<T, SizeMin>::remove() template<class T, int SizeMin> inline T& Foam::DynamicField<T, SizeMin>::operator() ( - const label elemI + const label i ) { - if (elemI >= Field<T>::size()) + if (i >= Field<T>::size()) { - setSize(elemI + 1); + setSize(i + 1); } - return this->operator[](elemI); + return this->operator[](i); } -- GitLab From f45832b537b3308daf43b39504e960e0cf011bf0 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 25 Oct 2017 15:17:33 +0100 Subject: [PATCH 058/126] COMP: finiteVolume: single precision build --- .../flowRateInletVelocityFvPatchVectorField.C | 2 +- .../flowRateOutletVelocityFvPatchVectorField.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index d42e353b693..2f14a7d2152 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -169,7 +169,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateValues Up -= nUp*n; // Remove any reverse flow - nUp = min(nUp, 0.0); + nUp = min(nUp, scalar(0.0)); const scalar flowRate = flowRate_->value(t); const scalar estimatedFlowRate = -gSum(rho*(this->patch().magSf()*nUp)); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C index cf331d9b7e0..cd06d768953 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C @@ -160,7 +160,7 @@ void Foam::flowRateOutletVelocityFvPatchVectorField::updateValues Up -= nUp*n; // Remove any reverse flow - nUp = max(nUp, 0.0); + nUp = max(nUp, scalar(0.0)); const scalar flowRate = flowRate_->value(t); const scalar estimatedFlowRate = gSum(rho*(this->patch().magSf()*nUp)); -- GitLab From 49bcba2da7ec9ec6b6d8850a12f18f2457af5b11 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 25 Oct 2017 16:22:59 +0100 Subject: [PATCH 059/126] ENH: snappyHexMesh: allow restart through suppression of refinement. Fixes #626. --- .../snappyHexMesh/snappyHexMeshDict | 7 ++- .../snappyHexMeshDriver/snappyRefineDriver.C | 58 ++++++++++++++++++- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index bf257a8ff55..46d570e206f 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -101,8 +101,11 @@ castellatedMeshControls // The surface refinement loop might spend lots of iterations refining just // a few cells. This setting will cause refinement to stop if - // <= minimumRefine cells are selected for refinement. Note: it will - // at least do one iteration (unless the number of cells to refine is 0) + // <= minRefinementCells cells are selected for refinement. Note: it will + // at least do one iteration unless + // a: the number of cells to refine is 0 + // b: minRefinementCells = -1. This is a special value indicating + // no refinement. minRefinementCells 0; // Allow a certain level of imbalance during refining diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C index 1040094bb14..956fb4366f9 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.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 | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,6 +80,13 @@ Foam::label Foam::snappyRefineDriver::featureEdgeRefine const label minRefine ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + addProfiling(edge, "snappyHexMesh::refine::edge"); const fvMesh& mesh = meshRefiner_.mesh(); @@ -190,6 +197,13 @@ Foam::label Foam::snappyRefineDriver::smallFeatureRefine const label maxIter ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + addProfiling(feature, "snappyHexMesh::refine::smallFeature"); const fvMesh& mesh = meshRefiner_.mesh(); @@ -313,6 +327,13 @@ Foam::label Foam::snappyRefineDriver::surfaceOnlyRefine const label maxIter ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + addProfiling(surface, "snappyHexMesh::refine::surface"); const fvMesh& mesh = meshRefiner_.mesh(); @@ -437,6 +458,13 @@ Foam::label Foam::snappyRefineDriver::gapOnlyRefine const label maxIter ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + const fvMesh& mesh = meshRefiner_.mesh(); // Determine the maximum refinement level over all surfaces. This @@ -669,6 +697,13 @@ Foam::label Foam::snappyRefineDriver::bigGapOnlyRefine const label maxIter ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + const fvMesh& mesh = meshRefiner_.mesh(); label iter = 0; @@ -811,6 +846,13 @@ Foam::label Foam::snappyRefineDriver::danglingCellRefine const label maxIter ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + addProfiling(dangling, "snappyHexMesh::refine::danglingCell"); const fvMesh& mesh = meshRefiner_.mesh(); @@ -957,6 +999,13 @@ Foam::label Foam::snappyRefineDriver::refinementInterfaceRefine const label maxIter ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + addProfiling(interface, "snappyHexMesh::refine::transition"); const fvMesh& mesh = meshRefiner_.mesh(); @@ -1348,6 +1397,13 @@ Foam::label Foam::snappyRefineDriver::shellRefine const label maxIter ) { + if (refineParams.minRefineCells() == -1) + { + // Special setting to be able to restart shm on meshes with inconsistent + // cellLevel/pointLevel + return 0; + } + addProfiling(shell, "snappyHexMesh::refine::shell"); const fvMesh& mesh = meshRefiner_.mesh(); -- GitLab From c1c4e91ffb50a68dd9cf8654d52c8813fd7ad70a Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 25 Oct 2017 20:55:37 +0200 Subject: [PATCH 060/126] ENH: handle underflow (rounding) of float/double as zero (issue #625) - The problem occurs when using atof to parse values such as "1e-39" since this is out of range for a float and _can_ set errno to ERANGE. Similar to parsing of integers, now parse with the longest floating point representation "long double" via strtold (guaranteed to be part of C++11) and verify against the respective VGREAT values for overflow. Treat anything smaller than VSMALL to be zero. --- .../test/primitives/Test-primitives.C | 23 ++++++++++-- src/OpenFOAM/primitives/Scalar/Scalar.C | 37 +++++++++++++++---- .../Scalar/doubleScalar/doubleScalar.C | 4 +- .../Scalar/floatScalar/floatScalar.C | 3 +- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/applications/test/primitives/Test-primitives.C b/applications/test/primitives/Test-primitives.C index 219b1ef5ec9..acdb71fb052 100644 --- a/applications/test/primitives/Test-primitives.C +++ b/applications/test/primitives/Test-primitives.C @@ -118,7 +118,8 @@ int main(int argc, char *argv[]) unsigned nFail = 0; { - Info<< nl << "Test readDouble:" << nl; + Info<< nl << "Test readDouble: (small=" << doubleScalarVSMALL + << " great=" << doubleScalarVSMALL << "):" << nl; nFail += testParsing ( &readDouble, @@ -131,12 +132,18 @@ int main(int argc, char *argv[]) { " 3.14159 ", true }, { " 31.4159E-1 " , true }, { " 100E1000 " , false }, + { " 1E-40 " , true }, + { " 1E-305 " , true }, + { " 1E-37 " , true }, + { " 1E-300 " , true }, } ); } { - Info<< nl << "Test readFloat:" << nl; + Info<< nl << "Test readFloat: (small=" << floatScalarVSMALL + << " great=" << floatScalarVGREAT << "):" << nl; + nFail += testParsing ( &readFloat, @@ -145,6 +152,10 @@ int main(int argc, char *argv[]) { " 31.4159E-1 " , true }, { " 31.4159E200 " , false }, { " 31.4159E20 " , true }, + { " 1E-40 " , true }, + { " 1E-305 " , true }, + { " 1E-37 " , true }, + { " 1E-300 " , true }, } ); } @@ -160,12 +171,16 @@ int main(int argc, char *argv[]) { " 314.159-2 " , true }, { " 31.4159E200 " , true }, { " 31.4159E20 " , true }, + { " 1E-40 " , true }, + { " 1E-305 " , true }, + { " 1E-37 " , true }, + { " 1E-300 " , true }, } ); } { - Info<< nl << "Test readInt32 (max= " << INT32_MAX << "):" << nl; + Info<< nl << "Test readInt32 (max=" << INT32_MAX << "):" << nl; nFail += testParsing ( &readInt32, @@ -181,7 +196,7 @@ int main(int argc, char *argv[]) } { - Info<< nl << "Test readUint32 (max= " + Info<< nl << "Test readUint32 (max=" << unsigned(UINT32_MAX) << "):" << nl; nFail += testParsing ( diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.C b/src/OpenFOAM/primitives/Scalar/Scalar.C index 644e9abf12e..d94c3c31c48 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.C +++ b/src/OpenFOAM/primitives/Scalar/Scalar.C @@ -80,10 +80,15 @@ Scalar ScalarRead(const char* buf) { char* endptr = nullptr; errno = 0; + const auto parsed = ScalarConvert(buf, &endptr); - const Scalar val = ScalarConvert(buf, &endptr); + const parsing::errorType err = + ( + (parsed < -ScalarVGREAT || parsed > ScalarVGREAT) + ? parsing::errorType::RANGE + : parsing::checkConversion(buf, endptr) + ); - const parsing::errorType err = parsing::checkConversion(buf, endptr); if (err != parsing::errorType::NONE) { FatalIOErrorInFunction("unknown") @@ -91,7 +96,13 @@ Scalar ScalarRead(const char* buf) << exit(FatalIOError); } - return val; + // Round underflow to zero + return + ( + (parsed > -ScalarVSMALL && parsed < ScalarVSMALL) + ? 0 + : Scalar(parsed) + ); } @@ -99,10 +110,22 @@ bool readScalar(const char* buf, Scalar& val) { char* endptr = nullptr; errno = 0; - - val = ScalarConvert(buf, &endptr); - - return (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE); + const auto parsed = ScalarConvert(buf, &endptr); + + // Round underflow to zero + val = + ( + (parsed > -ScalarVSMALL && parsed < ScalarVSMALL) + ? 0 + : Scalar(parsed) + ); + + return + ( + (parsed < -ScalarVGREAT || parsed > ScalarVGREAT) + ? false + : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE) + ); } diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C index da73874c633..41069b3555a 100644 --- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C +++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C @@ -28,6 +28,7 @@ License #include "parsing.H" #include "IOstreams.H" +#include <cstdlib> #include <sstream> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -40,7 +41,8 @@ License #define ScalarROOTVGREAT doubleScalarROOTVGREAT #define ScalarROOTVSMALL doubleScalarROOTVSMALL #define ScalarRead readDouble -#define ScalarConvert ::strtod +// Convert using larger representation to properly capture underflow +#define ScalarConvert ::strtold #include "Scalar.C" diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C index 94d40441f7a..5a8e0715561 100644 --- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C +++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C @@ -40,7 +40,8 @@ License #define ScalarROOTVGREAT floatScalarROOTVGREAT #define ScalarROOTVSMALL floatScalarROOTVSMALL #define ScalarRead readFloat -#define ScalarConvert ::strtof +// Convert using larger representation to properly capture underflow +#define ScalarConvert ::strtod #include "Scalar.C" -- GitLab From 6fd6610b57d28be20e434c1d7351d6bfb39018ab Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 26 Oct 2017 09:10:21 +0100 Subject: [PATCH 061/126] ENH: redistributePar: create dummy sets on non-existing processors --- .../redistributePar/loadOrCreateMesh.C | 41 ++++++++++++++++++- .../decompositionMethod/decompositionMethod.C | 12 +++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C index b219c65bcbe..b9f55ec82df 100644 --- a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C +++ b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,10 @@ License #include "Time.H" //#include "IOPtrList.H" #include "polyBoundaryMeshEntries.H" +#include "IOobjectList.H" +#include "pointSet.H" +#include "faceSet.H" +#include "cellSet.H" // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // @@ -375,6 +379,41 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh } + // Determine sets + // ~~~~~~~~~~~~~~ + + wordList pointSetNames; + wordList faceSetNames; + wordList cellSetNames; + if (Pstream::master()) + { + // Read sets + IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets"); + pointSetNames = objects.sortedNames(pointSet::typeName); + faceSetNames = objects.sortedNames(faceSet::typeName); + cellSetNames = objects.sortedNames(cellSet::typeName); + } + Pstream::scatter(pointSetNames); + Pstream::scatter(faceSetNames); + Pstream::scatter(cellSetNames); + + if (!haveMesh) + { + forAll(pointSetNames, i) + { + pointSet(mesh, pointSetNames[i], 0).write(); + } + forAll(faceSetNames, i) + { + faceSet(mesh, faceSetNames[i], 0).write(); + } + forAll(cellSetNames, i) + { + cellSet(mesh, cellSetNames[i], 0).write(); + } + } + + // if (!haveMesh) // { // // We created a dummy mesh file above. Delete it. diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index f03667084ed..2573c9ec78b 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.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 | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1348,7 +1348,15 @@ Foam::labelList Foam::decompositionMethod::decompose { // If no processor specified use the one from the // 0th element - proci = finalDecomp[mesh.faceOwner()[set[0]]]; + if (set.size()) + { + proci = finalDecomp[mesh.faceOwner()[set[0]]]; + } + else + { + // Zero-sized processor (e.g. from redistributePar) + proci = 0; + } } forAll(set, fI) -- GitLab From 2bd2f83f6e361f203720f1c60f1c9db42a88d75d Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 26 Oct 2017 12:09:47 +0200 Subject: [PATCH 062/126] ENH: cleanup and rationalize memory-backed streams - more consistent naming: * Versions that hold and manage their own memory: IListStream, OListStream * Versions that reference a fixed size external memory: UIListStream, UOListStream - use List storage instead of DynamicList within OListStream. Avoids duplicate bookkeeping, more direct handling of resizing. --- applications/test/IListStream/Make/files | 3 + applications/test/IListStream/Make/options | 2 + .../test/IListStream/Test-IListStream.C | 151 +++++++ applications/test/OCountStream/Make/files | 3 + applications/test/OCountStream/Make/options | 2 + .../test/OCountStream/Test-OCountStream.C | 61 +++ applications/test/OListStream/Make/options | 4 +- .../test/OListStream/Test-OListStream.C | 143 +++++- applications/test/UIBufStream/Make/files | 3 - applications/test/UIBufStream/Make/options | 2 - applications/test/UIListStream/Make/files | 3 + applications/test/UIListStream/Make/options | 2 + .../Test-UIListStream.C} | 71 ++- src/OpenFOAM/Make/files | 3 + .../db/IOstreams/StringStreams/StringStream.H | 41 +- .../db/IOstreams/hashes/OSHA1stream.H | 12 - .../db/IOstreams/memory/BufStreamAllocator.H | 266 ----------- .../db/IOstreams/memory/IListStream.H | 245 ++++++++++ src/OpenFOAM/db/IOstreams/memory/ListStream.C | 72 +++ src/OpenFOAM/db/IOstreams/memory/ListStream.H | 37 ++ .../db/IOstreams/memory/OCountStream.H | 153 ++++--- .../db/IOstreams/memory/OListStream.H | 424 ++++++++++-------- .../memory/{UIBufStream.H => UIListStream.H} | 186 +++++++- .../db/IOstreams/memory/UListStream.H | 37 ++ .../memory/{UOBufStream.H => UOListStream.H} | 200 +++++++-- .../db/IOstreams/memory/memoryStreamBuffer.H | 224 +++++++++ 26 files changed, 1723 insertions(+), 627 deletions(-) create mode 100644 applications/test/IListStream/Make/files create mode 100644 applications/test/IListStream/Make/options create mode 100644 applications/test/IListStream/Test-IListStream.C create mode 100644 applications/test/OCountStream/Make/files create mode 100644 applications/test/OCountStream/Make/options create mode 100644 applications/test/OCountStream/Test-OCountStream.C delete mode 100644 applications/test/UIBufStream/Make/files delete mode 100644 applications/test/UIBufStream/Make/options create mode 100644 applications/test/UIListStream/Make/files create mode 100644 applications/test/UIListStream/Make/options rename applications/test/{UIBufStream/Test-UIBufStream.C => UIListStream/Test-UIListStream.C} (74%) delete mode 100644 src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H create mode 100644 src/OpenFOAM/db/IOstreams/memory/IListStream.H create mode 100644 src/OpenFOAM/db/IOstreams/memory/ListStream.C create mode 100644 src/OpenFOAM/db/IOstreams/memory/ListStream.H rename src/OpenFOAM/db/IOstreams/memory/{UIBufStream.H => UIListStream.H} (52%) create mode 100644 src/OpenFOAM/db/IOstreams/memory/UListStream.H rename src/OpenFOAM/db/IOstreams/memory/{UOBufStream.H => UOListStream.H} (52%) create mode 100644 src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H diff --git a/applications/test/IListStream/Make/files b/applications/test/IListStream/Make/files new file mode 100644 index 00000000000..7f0914970b1 --- /dev/null +++ b/applications/test/IListStream/Make/files @@ -0,0 +1,3 @@ +Test-IListStream.C + +EXE = $(FOAM_USER_APPBIN)/Test-IListStream diff --git a/applications/test/IListStream/Make/options b/applications/test/IListStream/Make/options new file mode 100644 index 00000000000..18e6fe47afa --- /dev/null +++ b/applications/test/IListStream/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/IListStream/Test-IListStream.C b/applications/test/IListStream/Test-IListStream.C new file mode 100644 index 00000000000..588550a7a95 --- /dev/null +++ b/applications/test/IListStream/Test-IListStream.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + +\*---------------------------------------------------------------------------*/ + +#include "ListStream.H" +#include "UListStream.H" +#include "wordList.H" +#include "IOstreams.H" +#include "argList.H" + +using namespace Foam; + +Ostream& toString(Ostream& os, const UList<char>& list) +{ + os << '"'; + for (const char c : list) + { + os << c; + } + os << '"'; + + return os; +} + + +template<class BufType> +void printInfo(const BufType& buf) +{ + Info<< nl << "=========================" << endl; + buf.print(Info); + toString(Info, buf.list()); + Info<< nl << "=========================" << endl; +} + + +void printTokens(Istream& is) +{ + label count = 0; + token t; + while (is.good()) + { + is >> t; + if (t.good()) + { + ++count; + Info<<"token: " << t << endl; + } + } + + Info<< count << " tokens" << endl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + // Buffer storage + DynamicList<char> storage(16); + + OListStream obuf(std::move(storage)); + obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n"; + + // Move contents to output buffer + printInfo(obuf); + + Info<<nl << "as string: "; + toString(Info, obuf.list()) << endl; + + Info<< "transfer contents to a List" << endl; + + IListStream ibuf(obuf.xfer()); + + Info<< nl; + Info<< nl << "input string:"; + printInfo(ibuf); + + Info<< nl << "orig output:"; + printInfo(obuf); + + printTokens(ibuf); + + Info<<nl << "after:"; + printInfo(ibuf); + + // This should also work + ibuf.list() = 'X'; + + Info<<nl << "overwritten with const value:"; + printInfo(ibuf); + + // Can also change content like this: + { + const int n = min(26, ibuf.size()); + + for (int i=0; i<n; ++i) + { + ibuf.list()[i] = 'A' + i; + } + } + + Info<<nl << "directly written:"; + printInfo(ibuf); + + // But cannot easily swap in/out an entirely new list storage: + // + // List<char> newvalues(52); + // { + // for (int i=0; i<26; ++i) + // { + // newvalues[2*i+0] = char('a' + i); + // newvalues[2*i+1] = char('A' + i); + // } + // } + // ibuf.swap(newvalues); + // + // Info<<nl << "after swap:"; + // printInfo(ibuf); + + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/OCountStream/Make/files b/applications/test/OCountStream/Make/files new file mode 100644 index 00000000000..87df932eeaf --- /dev/null +++ b/applications/test/OCountStream/Make/files @@ -0,0 +1,3 @@ +Test-OCountStream.C + +EXE = $(FOAM_USER_APPBIN)/Test-OCountStream diff --git a/applications/test/OCountStream/Make/options b/applications/test/OCountStream/Make/options new file mode 100644 index 00000000000..18e6fe47afa --- /dev/null +++ b/applications/test/OCountStream/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/OCountStream/Test-OCountStream.C b/applications/test/OCountStream/Test-OCountStream.C new file mode 100644 index 00000000000..0cbaac4a7ef --- /dev/null +++ b/applications/test/OCountStream/Test-OCountStream.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + +\*---------------------------------------------------------------------------*/ + +#include "OCountStream.H" +#include "StringStream.H" +#include "IOstreams.H" +#include "argList.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + OCountStream cnt; + OStringStream str; + + for (label i = 0; i < 50; ++i) + { + str << 1002 << " " << "abcd" << " " + << "def" << " " << 3.14159 << ";\n"; + + cnt << 1002 << " " << "abcd" << " " + << "def" << " " << 3.14159 << ";\n"; + } + + cnt.print(Info); + Info<< "via string-stream: " << str.str().size() << " chars" << endl; + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/OListStream/Make/options b/applications/test/OListStream/Make/options index 4e772fdf9d7..18e6fe47afa 100644 --- a/applications/test/OListStream/Make/options +++ b/applications/test/OListStream/Make/options @@ -1,2 +1,2 @@ -/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ -/* EXE_LIBS = -lfiniteVolume */ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/OListStream/Test-OListStream.C b/applications/test/OListStream/Test-OListStream.C index adbbc722d59..4c3a758f0fc 100644 --- a/applications/test/OListStream/Test-OListStream.C +++ b/applications/test/OListStream/Test-OListStream.C @@ -25,7 +25,7 @@ Description \*---------------------------------------------------------------------------*/ -#include "OListStream.H" +#include "ListStream.H" #include "wordList.H" #include "IOstreams.H" #include "argList.H" @@ -45,10 +45,31 @@ Ostream& toString(Ostream& os, const UList<char>& list) } -void printInfo(const OListStream& buf) +template<class BufType> +void printInfo(const BufType& buf) { - Info<< nl << buf.size() << " chars (" << buf.capacity() << " capacity) "; - toString(Info, buf.list()) << endl; + Info<< nl << "=========================" << endl; + buf.print(Info); + toString(Info, buf.list()); + Info<< nl << "=========================" << endl; +} + + +void printTokens(Istream& is) +{ + label count = 0; + token t; + while (is.good()) + { + is >> t; + if (t.good()) + { + ++count; + Info<<"token: " << t << endl; + } + } + + Info<< count << " tokens" << endl; } @@ -58,18 +79,126 @@ void printInfo(const OListStream& buf) int main(int argc, char *argv[]) { // Buffer storage - DynamicList<char> storage(8); + DynamicList<char> storage(16); OListStream obuf(std::move(storage)); - obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n"; + + obuf.setBlockSize(100); + + printInfo(obuf); + + // Fill with some content + for (label i = 0; i < 50; ++i) + { + obuf<< 1002 << " " << "abcd" << " " + << "def" << " " << 3.14159 << ";\n"; + } printInfo(obuf); obuf.rewind(); - obuf << 100; + printInfo(obuf); + + for (label i=0; i < 10; ++i) + { + obuf << "item" << i << "\n"; + } + + printInfo(obuf); + + obuf.shrink(); + + Info<< "after shrink" << nl; + printInfo(obuf); + + // Add some more + for (label i=10; i < 15; ++i) + { + obuf << "more" << i << nl; + } + Info<< "appended more" << nl; printInfo(obuf); + // Overwrite at some position + obuf.stdStream().rdbuf()->pubseekpos(0.60 * obuf.size()); + obuf << "<" << nl << "OVERWRITE" << nl; + + Info<<"after overwrite" << nl; + printInfo(obuf); + + Info<< "transfer contents to a List or IListStream" << nl; + + IListStream ibuf(obuf.xfer()); + + Info<<"original:"; + printInfo(obuf); + + Info<<"new input:" << nl; + printInfo(ibuf); + + printTokens(ibuf); + + // Create from other storage types + + Info<< nl; + { + Info<<"create std::move(List)" << endl; + List<char> list(16, 'A'); + + Info<<"input:"; + toString(Info, list) << endl; + + OListStream buf1(std::move(list)); + for (label i = 0; i < 26; ++i) + { + buf1 << char('A' +i); + } + for (label i = 0; i < 26; ++i) + { + buf1 << char('a' +i); + } + + Info<<"orig:"; + toString(Info, list) << endl; + + printInfo(buf1); + } + + Info<< nl; + + List<char> written; + { + Info<<"create List.xfer()" << endl; + List<char> list(16, 'B'); + + Info<<"input:"; + toString(Info, list) << endl; + + OListStream buf1(list.xfer()); + for (label i = 0; i < 26; ++i) + { + buf1 << char('A' + i); + } + for (label i = 0; i < 26; ++i) + { + buf1 << char('a' +i); + } + + Info<<"orig:"; + toString(Info, list) << endl; + + printInfo(buf1); + + // Move back to written + written = buf1.xfer(); + + printInfo(buf1); + } + Info<<"'captured' content "; + toString(Info, written); + + Info<< "\nEnd\n" << endl; return 0; diff --git a/applications/test/UIBufStream/Make/files b/applications/test/UIBufStream/Make/files deleted file mode 100644 index 611f5337be7..00000000000 --- a/applications/test/UIBufStream/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -Test-UIBufStream.C - -EXE = $(FOAM_USER_APPBIN)/Test-UIBufStream diff --git a/applications/test/UIBufStream/Make/options b/applications/test/UIBufStream/Make/options deleted file mode 100644 index 4e772fdf9d7..00000000000 --- a/applications/test/UIBufStream/Make/options +++ /dev/null @@ -1,2 +0,0 @@ -/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ -/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/UIListStream/Make/files b/applications/test/UIListStream/Make/files new file mode 100644 index 00000000000..f60abd8967b --- /dev/null +++ b/applications/test/UIListStream/Make/files @@ -0,0 +1,3 @@ +Test-UIListStream.C + +EXE = $(FOAM_USER_APPBIN)/Test-UIListStream diff --git a/applications/test/UIListStream/Make/options b/applications/test/UIListStream/Make/options new file mode 100644 index 00000000000..18e6fe47afa --- /dev/null +++ b/applications/test/UIListStream/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/UIBufStream/Test-UIBufStream.C b/applications/test/UIListStream/Test-UIListStream.C similarity index 74% rename from applications/test/UIBufStream/Test-UIBufStream.C rename to applications/test/UIListStream/Test-UIListStream.C index f183d623ab7..fb0a1f378ce 100644 --- a/applications/test/UIBufStream/Test-UIBufStream.C +++ b/applications/test/UIListStream/Test-UIListStream.C @@ -25,14 +25,54 @@ Description \*---------------------------------------------------------------------------*/ -#include "UIBufStream.H" -#include "UOBufStream.H" +#include "UListStream.H" #include "wordList.H" #include "IOstreams.H" #include "argList.H" using namespace Foam; +Ostream& toString(Ostream& os, const UList<char>& list) +{ + os << '"'; + for (const char c : list) + { + os << c; + } + os << '"'; + + return os; +} + + +template<class BufType> +void printInfo(const BufType& buf) +{ + Info<< nl << "=========================" << endl; + buf.print(Info); + toString(Info, buf.list()); + Info<< nl << "=========================" << endl; +} + + +void printTokens(Istream& is) +{ + label count = 0; + token t; + while (is.good()) + { + is >> t; + if (t.good()) + { + ++count; + Info<<"token: " << t << endl; + } + } + + Info<< count << " tokens" << endl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -41,10 +81,10 @@ int main(int argc, char *argv[]) // Buffer storage DynamicList<char> storage(1000); - UOBufStream obuf(storage); + UOListStream obuf(storage); obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n"; - Info<<"formatted: " << obuf.size() << " chars" << endl; + obuf.print(Info); // Match size storage.resize(obuf.size()); @@ -53,31 +93,14 @@ int main(int argc, char *argv[]) // Attach input buffer - could also do without previous resize - UIBufStream ibuf(storage, storage.size()); + UIListStream ibuf(storage); - token t; - - while (ibuf.good()) - { - ibuf >> t; - if (t.good()) - { - Info<<"token: " << t << endl; - } - } + printTokens(ibuf); Info<< nl << "Repeat..." << endl; ibuf.rewind(); - while (ibuf.good()) - { - ibuf >> t; - if (t.good()) - { - Info<<"token: " << t << endl; - } - } - + printTokens(ibuf); Info<< "\nEnd\n" << endl; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index cc59794bae8..acf60a63d05 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -175,6 +175,9 @@ $(hashes)/base64Layer.C gzstream = $(Streams)/gzstream $(gzstream)/gzstream.C +memstream = $(Streams)/memory +$(memstream)/ListStream.C + Fstreams = $(Streams)/Fstreams $(Fstreams)/IFstream.C $(Fstreams)/OFstream.C diff --git a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H index cee86b47bb6..ab9f3356124 100644 --- a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H +++ b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H @@ -79,11 +79,6 @@ protected: {} - //- Destructor - ~StringStreamAllocator() - {} - - public: // Public Member Functions @@ -112,6 +107,8 @@ class IStringStream public StringStreamAllocator<std::istringstream>, public ISstream { + typedef StringStreamAllocator<std::istringstream> allocator_type; + public: // Constructors @@ -125,7 +122,7 @@ public: const Foam::string& name="input" ) : - StringStreamAllocator<std::istringstream>(buffer), + allocator_type(buffer), ISstream(stream_, name, format, version) {} @@ -139,7 +136,7 @@ public: const Foam::string& name="input" ) : - StringStreamAllocator<std::istringstream>(buffer), + allocator_type(buffer), ISstream(stream_, name, format, version) {} @@ -147,28 +144,23 @@ public: //- Construct as copy of content IStringStream(const IStringStream& str) : - StringStreamAllocator<std::istringstream>(str.str()), + allocator_type(str.str()), ISstream(stream_, str.name(), str.format(), str.version()) {} - //- Destructor - ~IStringStream() - {} - - // Member Functions - //- Print description to Ostream - void print(Ostream& os) const; - //- Reset the input buffer and rewind the stream - void reset(const std::string& s) + virtual void reset(const std::string& s) { this->str(s); this->rewind(); } + //- Print description to Ostream + virtual void print(Ostream& os) const; + // Member operators @@ -192,6 +184,8 @@ class OStringStream public StringStreamAllocator<std::ostringstream>, public OSstream { + typedef StringStreamAllocator<std::ostringstream> allocator_type; + public: // Constructors @@ -203,7 +197,7 @@ public: versionNumber version=currentVersion ) : - StringStreamAllocator<std::ostringstream>(), + allocator_type(), OSstream(stream_, "output", format, version) {} @@ -211,16 +205,11 @@ public: //- Construct as copy of content OStringStream(const OStringStream& str) : - StringStreamAllocator<std::ostringstream>(str.str()), + allocator_type(str.str()), OSstream(stream_, str.name(), str.format(), str.version()) {} - //- Destructor - ~OStringStream() - {} - - // Member Functions //- Reset the output buffer and rewind the stream @@ -231,14 +220,14 @@ public: } //- Rewind the output stream - void rewind() + virtual void rewind() { // pubseekpos() instead of seekp() for symmetry with other classes stream_.rdbuf()->pubseekpos(0, std::ios_base::out); } //- Print description to Ostream - void print(Ostream& os) const; + virtual void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H index 414259c7951..6b9688b73a0 100644 --- a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H +++ b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H @@ -112,8 +112,6 @@ public: // Member Functions - // Access - //- This hides both signatures of std::basic_ios::rdbuf() sha1buf* rdbuf() { @@ -155,11 +153,6 @@ protected: {} - //- Destructor - ~OSHA1streamAllocator() - {} - - public: // Member Functions @@ -223,11 +216,6 @@ public: {} - //- Destructor - ~OSHA1stream() - {} - - // Member functions //- Clear the SHA1 calculation diff --git a/src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H b/src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H deleted file mode 100644 index 0696e1a9430..00000000000 --- a/src/OpenFOAM/db/IOstreams/memory/BufStreamAllocator.H +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>. - -Class - Foam::BufStreamAllocator - -Description - Helper for memory buffer streams such as UIBufStream, UOBufStream - -\*---------------------------------------------------------------------------*/ - -#ifndef BufStreamAllocator_H -#define BufStreamAllocator_H - -#include <type_traits> -#include <sstream> - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class memorybuf Declaration -\*---------------------------------------------------------------------------*/ - -//- A streambuf class for using externally allocated memory for its buffer -class memorybuf -: - public std::streambuf -{ -protected: - - // Protected members - - //- Set position pointer to relative position - virtual std::streampos seekoff - ( - std::streamoff off, - std::ios_base::seekdir way, - std::ios_base::openmode which = std::ios_base::in|std::ios_base::out - ) - { - const bool testin = which & std::ios_base::in; - const bool testout = which & std::ios_base::out; - - if (way == std::ios_base::beg) - { - if (testin) - { - setg(eback(), eback(), egptr()); - gbump(off); - } - if (testout) - { - setp(pbase(), epptr()); - pbump(off); - } - - return off; - } - - if (way == std::ios_base::cur) - { - if (testin) - { - gbump(off); - } - if (testout) - { - pbump(off); - } - } - else if (way == std::ios_base::end) - { - if (testin) - { - gbump(off); - } - if (testout) - { - pbump(off); - } - } - - if (testin) - { - return gptr() - eback(); - } - if (testout) - { - return pptr() - pbase(); - } - - return -1; - } - - - //- Set position pointer to absolute position - virtual std::streampos seekpos - ( - std::streampos pos, - std::ios_base::openmode which = std::ios_base::in|std::ios_base::out - ) - { - return seekoff(pos, std::ios_base::beg, which); - } - - - //- Get sequence of characters - virtual std::streamsize xsgetn(char* s, std::streamsize n) - { - std::streamsize count = 0; - - // some optimization could be possible here - while (count < n && gptr() < egptr()) - { - *(s + count++) = *(gptr()); - gbump(1); - } - - return count; - } - - - //- Put sequence of characters - virtual std::streamsize xsputn(const char* s, std::streamsize n) - { - std::streamsize count = 0; - - // some optimization could be possible here - while (count < n && pptr() < epptr()) - { - *(pptr()) = *(s + count++); - pbump(1); - } - - return count; - } - - -public: - - // Constructors - - //- Construct for specified buffer - memorybuf(char* buffer, std::streamsize num) - { - setg(buffer, buffer, buffer + num); - setp(buffer, buffer + num); - } - -}; - - -/*---------------------------------------------------------------------------*\ - Class BufStreamAllocator Declaration -\*---------------------------------------------------------------------------*/ - -//- An stream/stream-buffer allocator for external buffers -template<class StreamType, bool Manage=false> -class BufStreamAllocator -{ - // Private data - - //- Storage - char *storage_; - - //- The number of bytes in the storage - std::streamsize len_; - - //- Reference to the underlying buffer - memorybuf buf_; - -protected: - - // Protected data - - typedef StreamType stream_type; - - //- The stream pointer - stream_type stream_; - - - // Constructors - - //- Construct with buffer and number of bytes - BufStreamAllocator(char *buffer, size_t nbytes) - : - storage_(buffer), - len_(nbytes), - buf_(storage_, len_), - stream_(&buf_) - {} - - - //- Destructor - ~BufStreamAllocator() - { - // Possible cleanup of storage - if (Manage && storage_) - { - delete storage_; - storage_ = nullptr; - } - } - - - // Protected Member Functions - - - //- Position of the get buffer - std::streampos tellg() const - { - return const_cast<stream_type&>(stream_).tellg(); - } - - //- Position of the put buffer - std::streampos tellp() const - { - return const_cast<stream_type&>(stream_).tellp(); - } - - -public: - - // Public Member Functions - - //- Move to buffer start, clear errors - void rewind() - { - stream_.rdbuf()->pubseekpos(0); - stream_.clear(); // for safety, clear any old errors - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/IListStream.H b/src/OpenFOAM/db/IOstreams/memory/IListStream.H new file mode 100644 index 00000000000..553a803bc3c --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/IListStream.H @@ -0,0 +1,245 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::IListStream + +Description + An input stream that reads from a List and manages the List storage. + Similar to IStringStream but with a List for its storage instead of + as string to allow reuse of List contents without copying. + +See Also + Foam::OListStream + Foam::UIListStream + Foam::UOListStream + +\*---------------------------------------------------------------------------*/ + +#ifndef IListStream_H +#define IListStream_H + +#include "List.H" +#include "UIListStream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class IListStreamAllocator Declaration +\*---------------------------------------------------------------------------*/ + +//- An stream/stream-buffer input allocator for with List storage +class IListStreamAllocator +: + private List<char>, + public UIListStreamAllocator +{ +protected: + + // Constructors + + //- Construct with an empty list + IListStreamAllocator() + : + List<char>(), + UIListStreamAllocator(list_storage()) + {} + + //- Move construct from an existing List + IListStreamAllocator(List<char>&& buffer) + : + List<char>(std::move(buffer)), + UIListStreamAllocator(list_storage()) + {} + + + //- Move construct from an existing DynamicList + template<int SizeMin> + IListStreamAllocator(DynamicList<char,SizeMin>&& buffer) + : + List<char>(std::move(buffer)), + UIListStreamAllocator(list_storage()) + {} + + //- Transfer (move) construct + IListStreamAllocator(const Xfer<List<char>>& buffer) + : + List<char>(buffer), + UIListStreamAllocator(list_storage()) + {} + + + // Protected Member Functions + + //- Convenience method to address the underlying List storage + inline List<char>& list_storage() + { + return static_cast<List<char>&>(*this); + } + +public: + + // Member Functions + + //- The current get position in the buffer + using UIListStreamAllocator::size; + + //- Clear storage + inline void clearStorage() + { + list_storage().clear(); + sync_gbuffer_to_list(); + } + + //- Transfer contents to the Xfer container as a plain List + inline Xfer<List<char>> xfer() + { + Xfer<List<char>> moved = list_storage().xfer(); + + // Update buffer pointers for remaining (zero) size list + sync_gbuffer_to_list(); // or rewind + + return moved; + } +}; + + +/*---------------------------------------------------------------------------*\ + Class IListStream Declaration +\*----------------------------------------------d-----------------------------*/ + +//- An ISstream with internal List storage +class IListStream +: + public IListStreamAllocator, + public ISstream +{ + typedef IListStreamAllocator allocator_type; + +public: + + // Constructors + + //- Construct with an empty list + IListStream + ( + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + allocator_type(), + ISstream(stream_, name, format, version) + {} + + + //- Move construct from an existing List + IListStream + ( + List<char>&& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + allocator_type(std::move(buffer)), + ISstream(stream_, name, format, version) + {} + + + //- Move construct from an existing DynamicList + template<int SizeMin> + IListStream + ( + DynamicList<char,SizeMin>&& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + allocator_type(std::move(buffer)), + ISstream(stream_, name, format, version) + {} + + + //- Transfer (move) construct + IListStream + ( + const Xfer<List<char>>& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + allocator_type(buffer), + ISstream(stream_, name, format, version) + {} + + + // Member functions + + //- The current get position in the buffer + using allocator_type::size; + + + //- Return the current get position in the buffer + std::streampos pos() const + { + return allocator_type::tellg(); + } + + //- Rewind the stream, clearing any old errors + virtual void rewind() + { + allocator_type::rewind(); + setGood(); // resynchronize with internal state + } + + + //- Print description to Ostream + virtual void print(Ostream& os) const; + + + // Member operators + + //- A non-const reference to const Istream + // Needed for read-constructors where the stream argument is temporary + Istream& operator()() const + { + return const_cast<Istream&>(static_cast<const Istream&>(*this)); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/ListStream.C b/src/OpenFOAM/db/IOstreams/memory/ListStream.C new file mode 100644 index 00000000000..02750001774 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/ListStream.C @@ -0,0 +1,72 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "UListStream.H" +#include "ListStream.H" +#include "OCountStream.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::IListStream::print(Ostream& os) const +{ + os << "IListStream: "; + printBufInfo(os); + os << Foam::endl; +} + + +void Foam::UIListStream::print(Ostream& os) const +{ + os << "UIListStream: "; + printBufInfo(os); + os << Foam::endl; +} + + +void Foam::OListStream::print(Ostream& os) const +{ + os << "OListStream: "; + printBufInfo(os); + os << Foam::endl; +} + + +void Foam::UOListStream::print(Ostream& os) const +{ + os << "UOListStream: "; + printBufInfo(os); + os << Foam::endl; +} + + +void Foam::OCountStream::print(Ostream& os) const +{ + os << "OCountStream: "; + printBufInfo(os); + os << Foam::endl; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/ListStream.H b/src/OpenFOAM/db/IOstreams/memory/ListStream.H new file mode 100644 index 00000000000..6ef7518ca07 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/ListStream.H @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + Input/output streams with managed List storage. + +\*---------------------------------------------------------------------------*/ + +#ifndef ListStream_H +#define ListStream_H + +#include "IListStream.H" +#include "OListStream.H" + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/OCountStream.H b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H index b3ce64b1695..3ae0311667f 100644 --- a/src/OpenFOAM/db/IOstreams/memory/OCountStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H @@ -52,50 +52,51 @@ class countstreambuf // Private data //- The number of bytes - std::streamsize n_; + std::streamsize size_; protected: - // Protected members - //- Put sequence of characters - virtual std::streamsize xsputn(const char* s, std::streamsize num) + //- Simply handle output counting via overflow + virtual int overflow(int c = EOF) + { + if (c != EOF) { - n_ += num; - return num; - } - - - //- Set position pointer to absolute position - // For the counter, any positioning is ignored and it always acts like - // seekpos(0), which resets the count. - virtual std::streampos seekpos - ( - std::streampos sp, - std::ios_base::openmode which = std::ios_base::in|std::ios_base::out - ) - { - n_ = 0; - return 0; + ++size_; } + return c; + } + + //- Set position pointer to absolute position + // For the counter, any positioning is ignored and it always acts like + // seekpos(0), which resets the count. + virtual std::streampos seekpos + ( + std::streampos, + std::ios_base::openmode which = std::ios_base::in|std::ios_base::out + ) + { + size_ = 0; + return 0; + } public: // Constructors - //- Construct null - countstreambuf() + //- Construct null, or with precount size + countstreambuf(std::streamsize precount=0) : - n_(0) + size_(precount) {} // Access - //- Get number of bytes counted + //- Number of bytes counted std::streamsize size() const { - return n_; + return size_; } }; @@ -154,6 +155,62 @@ public: }; +/*---------------------------------------------------------------------------*\ + Class OCountStreamAllocator Declaration +\*---------------------------------------------------------------------------*/ + +//- An stream/stream-buffer allocator for counting +class OCountStreamAllocator +{ +protected: + + // Protected data + + typedef std::ostream stream_type; + + //- The stream buffer + countstreambuf buf_; + + //- The output stream + stream_type stream_; + + + // Constructors + + //- Construct null, or with precount size + OCountStreamAllocator(std::streamsize precount=0) + : + buf_(precount), + stream_(&buf_) + {} + + + // Protected Member Functions + + void printBufInfo(Ostream& os) const + { + os << "count=" << buf_.size(); + } + +public: + + // Member Functions + + //- The number of bytes counted + std::streamsize size() const + { + return buf_.size(); + } + + //- Rewind the stream, reset the count + void rewind() + { + buf_.pubseekpos(0); + stream_.clear(); // for safety, clear any old errors + } +}; + + /*---------------------------------------------------------------------------*\ Class OCountStream Declaration \*---------------------------------------------------------------------------*/ @@ -161,17 +218,10 @@ public: //- An output stream for calculating byte counts class OCountStream : - private ocountstream, + public OCountStreamAllocator, public OSstream { - - // Private Member Functions - - //- Disallow default bitwise copy construct - OCountStream(const OCountStream&) = delete; - - //- Disallow default bitwise assignment - void operator=(const OCountStream&) = delete; + typedef OCountStreamAllocator allocator_type; public: @@ -184,39 +234,30 @@ public: versionNumber version=currentVersion ) : - ocountstream(), - OSstream - ( - static_cast<ocountstream&>(*this), - "output", - format, - version - ) + allocator_type(), + OSstream(stream_, "output", format, version) {} - - //- Destructor - ~OCountStream() - {} + //- Copy construct + OCountStream(const OCountStream& os) + : + allocator_type(os.size()), + OSstream(stream_, os.name(), os.format(), os.version()) + {} // Member functions - // Access - - //- Return the number of bytes counted - using ocountstream::size; - - - // Edit - //- Rewind the stream, reset the count, clearing any old errors - void rewind() + virtual void rewind() { - ocountstream::rewind(); + allocator_type::rewind(); setGood(); // resynchronize with internal state } + //- Print description to Ostream + virtual void print(Ostream& os) const; + }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/IOstreams/memory/OListStream.H b/src/OpenFOAM/db/IOstreams/memory/OListStream.H index b76b7f6f7fa..756394e6fa2 100644 --- a/src/OpenFOAM/db/IOstreams/memory/OListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/OListStream.H @@ -25,16 +25,27 @@ Class Foam::OListStream Description - An output stream that writes to a DynamicList. + An output stream that writes to a List and manages the List storage. + Similar to OStringStream but with a List for its storage instead of + as string to allow reuse of List contents without copying. + + The default list size is 512 with a 256 byte block increment. + These values can be changed on construction of via the + reserve() and setBlockSize() methods. + +See Also + Foam::IListStream + Foam::UOListStream + Foam::UIListStream \*---------------------------------------------------------------------------*/ #ifndef OListStream_H #define OListStream_H -#include <sstream> #include "DynamicList.H" #include "OSstream.H" +#include "memoryStreamBuffer.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,177 +59,187 @@ class OListStreamAllocator; Class OListStreamAllocator Declaration \*---------------------------------------------------------------------------*/ -//- An stream/stream-buffer allocator for external buffers +//- An stream/stream-buffer output allocator for lists class OListStreamAllocator { - //- A streambuf adapter to output to a DynamicList - class olistbuf + //- A streambuf adapter to output to a List + class listbuf : - public std::streambuf + public memorybuf::output { friend OListStreamAllocator; - //- Underlying list storage - DynamicList<char,512> storage_; - - - //- Adjust buffer pointers to agree with list sizes - inline void syncBufferPointers() + //- Helper for setting the block size. + // Small list minimum of 64 bytes. + static int min_size(int n) { - setp(storage_.data(), storage_.data() + storage_.capacity()); - pbump(storage_.size()); + return max(64, n); } - //- Adjust addressed list size to agree with buffer pointers - inline void syncListSize() - { - storage_.setSize(pptr() - pbase()); - } + //- Block size when resizing the list + int block_ = 256; + //- Underlying list storage. + // Internally manage like a DynamicList, but the addressable size + // is known through the stream pointers. + List<char> storage_; - protected: - // Protected members + protected: - //- Set position pointer to relative position - virtual std::streampos seekoff - ( - std::streamoff off, - std::ios_base::seekdir way, - std::ios_base::openmode which = std::ios_base::out - ) + //- Increment capacity directly and + // adjust buffer pointers to agree with list dimensions + inline void minCapacity + ( + const std::streamsize n, + const std::streamsize cur = 0 + ) + { + const auto newEnd = n + cur; + if (newEnd > storage_.size()) { - const bool testout = which & std::ios_base::out; - - if (way == std::ios_base::beg) - { - if (testout) - { - setp(pbase(), epptr()); - pbump(off); - } - - return off; - } + auto newCapacity = + ( + (storage_.size() + block_) + - (storage_.size() % block_) + ); - if (way == std::ios_base::cur) - { - if (testout) - { - pbump(off); - } - } - else if (way == std::ios_base::end) + while (newCapacity < newEnd) { - if (testout) - { - pbump(off); - } + newCapacity += block_; } - if (testout) - { - return pptr() - pbase(); - } + // Info<<"request:" << newEnd + // << " cur cap:" << storage_.size() + // << " new cap:" << newCapacity + // << " pos:" << cur + // << " incr:" << incr << endl; - return -1; + storage_.setSize(newCapacity); + sync_pbuffer_to_list(); + pbump(cur); } + } + //- Define new increment + inline void setBlockSize(const int i) + { + const auto prev = block_; + block_ = min_size(i); - //- Set position pointer to absolute position - virtual std::streampos seekpos - ( - std::streampos pos, - std::ios_base::openmode which = std::ios_base::out - ) + if (block_ > prev) { - if (which & std::ios_base::out) - { - setp(pbase(), epptr()); - pbump(pos); - - return pptr() - pbase(); - } - - return -1; + minCapacity(0, tellp()); } + } - - //- Put sequence of characters - virtual std::streamsize xsputn(const char* s, std::streamsize n) + //- Handle overflow + virtual int overflow(int c = EOF) + { + if (c != EOF) { - const std::streamsize newlen = n + storage_.size(); + // Need another output block + minCapacity(block_, tellp()); - if (newlen > storage_.capacity()) - { - // Either use reserve(), or setCapacity() directly - // with finer control over growth - storage_.reserve(newlen); - syncBufferPointers(); - } + *(pptr()) = c; + pbump(1); + } + return c; + } - std::streamsize count = 0; - while (count < n && pptr() < epptr()) - { - *(pptr()) = *(s + count++); - pbump(1); - } - // Synchronize list size with output - syncListSize(); + //- Put sequence of characters + virtual std::streamsize xsputn(const char* s, std::streamsize n) + { + // Enough space so that appends work without problem + minCapacity(n, tellp()); - return count; + std::streamsize count = 0; + while (count < n && pptr() < epptr()) + { + *(pptr()) = *(s + count++); + pbump(1); } + return count; + } - public: + //- Initialize put buffer + void init_pbuffer(const std::streamsize n) + { + set_pbuffer(storage_); + minCapacity(n); + } - // Constructors - //- Construct with an empty list - olistbuf() - : - storage_(1024) - { - syncBufferPointers(); - } + public: + // Constructors - //- Construct with a specified number of reserved bytes - olistbuf(size_t nbytes) - : - storage_() - { - storage_.reserve(std::max(label(nbytes),1024)); - syncBufferPointers(); - } + //- Construct with an empty list, or specified number of reserved bytes + listbuf(size_t nbytes = 512) + : + storage_() + { + init_pbuffer(min_size(nbytes)); + } + //- Move construct content from an existing List + listbuf(List<char>&& buffer) + : + storage_(std::move(buffer)) + { + init_pbuffer(block_); + } - //- Move construct from an existing List - olistbuf(List<char>&& buffer) - : - storage_(std::move(buffer)) - { - syncBufferPointers(); - } + //- Move construct content from an existing DynamicList + template<int AnySize> + listbuf(DynamicList<char,AnySize>&& buffer) + : + storage_(std::move(buffer)) + { + init_pbuffer(block_); + } + + //- Transfer (move) construct + listbuf(const Xfer<List<char>>& buffer) + : + storage_(buffer) + { + init_pbuffer(block_); + } - //- Move construct from an existing DynamicList - template<int AnySize> - olistbuf(DynamicList<char,AnySize>&& buffer) - : - storage_(std::move(buffer)) - { - syncBufferPointers(); - } - }; + // Member Functions + //- Return the current list output capacity + inline label capacity() const + { + return storage_.size(); + } - // Private data + //- Sync put buffer pointers to agree with list dimensions + inline void sync_pbuffer_to_list() + { + set_pbuffer(storage_); + } - //- Reference to the underlying buffer - olistbuf buf_; + //- Clear storage + inline void clearStorage() + { + storage_.clear(); + sync_pbuffer_to_list(); + } + //- Shrink to addressed storage + inline void shrink() + { + const auto cur = tellp(); + storage_.setSize(cur); + sync_pbuffer_to_list(); + pbump(cur); + } + }; protected: @@ -226,28 +247,22 @@ protected: typedef std::ostream stream_type; - //- The output stream + //- The stream buffer + listbuf buf_; + + //- The stream stream_type stream_; // Constructors - //- Construct with an empty list - OListStreamAllocator() - : - buf_(), - stream_(&buf_) - {} - - - //- Construct with a specified number of reserved bytes - OListStreamAllocator(size_t nbytes) + //- Construct with an empty list or specified number of reserved bytes + OListStreamAllocator(size_t nbytes = 512) : buf_(nbytes), stream_(&buf_) {} - //- Move construct from an existing List OListStreamAllocator(List<char>&& buffer) : @@ -255,7 +270,6 @@ protected: stream_(&buf_) {} - //- Move construct from an existing DynamicList template<int SizeMin> OListStreamAllocator(DynamicList<char,SizeMin>&& buffer) @@ -264,71 +278,117 @@ protected: stream_(&buf_) {} + //- Transfer (move) construct + OListStreamAllocator(const Xfer<List<char>>& buffer) + : + buf_(buffer), + stream_(&buf_) + {} - //- Destructor - ~OListStreamAllocator() - {} + // Protected Member Functions + + void printBufInfo(Ostream& os) const + { + os << "pos=" << buf_.tellp() + << " capacity=" << buf_.capacity() + << " block=" << buf_.block_; + } public: // Member Functions - //- Content as a list of characters - UList<char> list() const + //- The current list output capacity + inline label capacity() const { - return UList<char> - ( - const_cast<char*>(buf_.storage_.cdata()), - buf_.storage_.size() - ); + return buf_.capacity(); } - //- Content as a list of characters - UList<char>& list() + //- Reserve output space for at least this amount. + inline void reserve(const std::streamsize n) { - return static_cast<UList<char>&>(buf_.storage_); + // Also maintain current position when resizing + const auto cur = buf_.tellp(); + if (n > cur) + { + buf_.minCapacity(n - cur, cur); + } } - //- Return the current list capacity - inline label capacity() const + + //- Adjust block size for output + inline void setBlockSize(int n) { - return buf_.storage_.capacity(); + return buf_.setBlockSize(n); } - //- Reserve allocation space for at least this size. - inline void reserve(const label nElem) + //- The current output position in the buffer, + // which is also the addressed list size + inline label size() const { - buf_.storage_.reserve(nElem); - buf_.syncBufferPointers(); + return buf_.tellp(); } - //- Return the current output position in the buffer - // The same as the DynamicList::size() - std::streampos size() const + //- Const access to written contents as a list of characters + inline const UList<char> list() const { - return const_cast<stream_type&>(stream_).tellp(); + return UList<char> + ( + const_cast<char*>(buf_.storage_.cdata()), + buf_.tellp() + ); + } + + + //- Non-const access to written contents as a list of characters + inline UList<char> list() + { + return UList<char>(buf_.storage_.data(), buf_.tellp()); + } + + + //- Transfer contents to the Xfer container as a plain List + inline Xfer<List<char>> xfer() + { + buf_.shrink(); // Shrink to addressed area + auto lst = buf_.storage_.xfer(); + buf_.sync_pbuffer_to_list(); + return lst; } //- Move to buffer start, clear errors void rewind() { - buf_.storage_.clear(); - buf_.syncBufferPointers(); + buf_.pubseekpos(0, std::ios_base::out); stream_.clear(); // for safety, clear any old errors } + + //- Shrink to addressed space, should not affect stream. + inline void shrink() + { + buf_.shrink(); + } + + //- Clear storage + void clearStorage() + { + buf_.clearStorage(); + stream_.clear(); // for safety, clear any old errors + } + }; /*---------------------------------------------------------------------------*\ Class OListStream Declaration -\*----------------------------------------------d-----------------------------*/ +\*---------------------------------------------------------------------------*/ -//- An OSstream attached a DynamicList +//- An OSstream attached to a List class OListStream : public OListStreamAllocator, @@ -348,7 +408,7 @@ public: ) : allocator_type(), - OSstream(stream_, "output", format,version) + OSstream(stream_, "output", format, version) {} @@ -391,16 +451,30 @@ public: OSstream(stream_, "output", format, version) {} - - //- Destructor - ~OListStream() - {} + //- Transfer (move) construct + OListStream + ( + const Xfer<List<char>>& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + allocator_type(buffer), + OSstream(stream_, "output", format, version) + {} // Member functions //- Rewind the stream, clearing any old errors - using allocator_type::rewind; + virtual void rewind() + { + allocator_type::rewind(); + setGood(); // resynchronize with internal state + } + + //- Print description to Ostream + virtual void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/memory/UIBufStream.H b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H similarity index 52% rename from src/OpenFOAM/db/IOstreams/memory/UIBufStream.H rename to src/OpenFOAM/db/IOstreams/memory/UIListStream.H index e02929f181f..e7db211c1d5 100644 --- a/src/OpenFOAM/db/IOstreams/memory/UIBufStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::UIBufStream + Foam::UIListStream Description Similar to IStringStream but using an externally managed buffer for its @@ -41,7 +41,7 @@ Description buffer.setSize(nread); // content size // construct dictionary, or something else - UIBufStream is(buffer) + UIListStream is(buffer) dictionary dict1(is); // sometime later @@ -49,16 +49,23 @@ Description buffer.setSize(nread); // content size // without intermediate variable - dictionary dict2(UIBufStream(buffer)()); + dictionary dict2(UIListStream(buffer)()); \endcode +See Also + Foam::IListStream + Foam::OListStream + Foam::UOListStream + \*---------------------------------------------------------------------------*/ -#ifndef UIBufStream_H -#define UIBufStream_H +#ifndef UIListStream_H +#define UIListStream_H -#include "BufStreamAllocator.H" +#include "FixedList.H" +#include "UList.H" #include "ISstream.H" +#include "memoryStreamBuffer.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -66,22 +73,149 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class UIBufStream Declaration + Class UIListAllocator Declaration \*---------------------------------------------------------------------------*/ -class UIBufStream +//- An stream/stream-buffer input allocator for a externally allocated lists +class UIListStreamAllocator +{ + //- A streambuf class for input from UList or equivalent + class ulistbuf + : + public memorybuf::input + { + friend UIListStreamAllocator; + + //- Underlying list storage + UList<char> list_; + + public: + + //- Construct for specified buffer + ulistbuf(UList<char>& buffer) + : + list_(buffer) + { + set_gbuffer(list_); + } + + //- Construct for specified buffer + ulistbuf(char* buffer, std::streamsize num) + : + list_(buffer, num) + { + set_gbuffer(list_); + } + + //- Sync get buffer pointers to agree with list dimensions + inline void sync_gbuffer_to_list() + { + set_gbuffer(list_); + } + }; + +protected: + + // Protected data + + typedef std::istream stream_type; + + //- The stream buffer + ulistbuf buf_; + + //- The stream + stream_type stream_; + + + // Constructors + + //- Construct with list buffer + UIListStreamAllocator(UList<char>& list) + : + buf_(list), + stream_(&buf_) + {} + + //- Construct with buffer and number of bytes + UIListStreamAllocator(char *buffer, size_t nbytes) + : + buf_(buffer, nbytes), + stream_(&buf_) + {} + + + // Protected Member Functions + + //- Sync get buffer pointers to agree with list dimensions + inline void sync_gbuffer_to_list() + { + buf_.sync_gbuffer_to_list(); + } + + void printBufInfo(Ostream& os) const + { + os << "pos=" << buf_.tellg() + << " size=" << buf_.list_.size(); + } + +public: + + // Public Member Functions + + //- Const access to available contents as a list of characters + inline const UList<char>& list() const + { + return buf_.list_; + } + + + //- Non-const access to available contents as a list of characters + inline UList<char> list() + { + return buf_.list_; + } + + + //- The list size + inline label size() const + { + return buf_.list_.size(); + } + + + //- Position of the get buffer + std::streampos tellg() const + { + return buf_.tellg(); + } + + + //- Move to buffer start, clear errors + void rewind() + { + buf_.pubseekpos(0, std::ios_base::in); + stream_.clear(); // for safety, clear any old errors + } +}; + + +/*---------------------------------------------------------------------------*\ + Class UIListStream Declaration +\*---------------------------------------------------------------------------*/ + +class UIListStream : - public BufStreamAllocator<std::istream,false>, + public UIListStreamAllocator, public ISstream { - typedef BufStreamAllocator<std::istream,false> allocator_type; + typedef UIListStreamAllocator allocator_type; public: // Constructors //- Construct using specified buffer and number of bytes - UIBufStream + UIListStream ( const char* buffer, size_t nbytes, @@ -95,8 +229,21 @@ public: {} + //- Construct using data area from a FixedList + template<unsigned FixedSize> + UIListStream + ( + const FixedList<char,FixedSize>& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion, + const Foam::string& name="input" + ) + : + UIListStream(buffer.cdata(), FixedSize, format, version, name) + {} + //- Construct using data area from a List and number of bytes - UIBufStream + UIListStream ( const UList<char>& buffer, label size, @@ -105,13 +252,13 @@ public: const Foam::string& name="input" ) : - UIBufStream(buffer.cdata(), size, format,version,name) + UIListStream(buffer.cdata(), size, format, version, name) {} //- Construct using data area from a List and its inherent storage size // Uses addressed size, thus no special treatment for a DynamicList - UIBufStream + UIListStream ( const UList<char>& buffer, streamFormat format=ASCII, @@ -119,15 +266,10 @@ public: const Foam::string& name="input" ) : - UIBufStream(buffer.cdata(), buffer.size(), format,version,name) + UIListStream(buffer.cdata(), buffer.size(), format, version, name) {} - //- Destructor - ~UIBufStream() - {} - - // Member functions //- Return the current get position in the buffer @@ -145,6 +287,10 @@ public: } + //- Print description to Ostream + virtual void print(Ostream& os) const; + + // Member operators //- A non-const reference to const Istream diff --git a/src/OpenFOAM/db/IOstreams/memory/UListStream.H b/src/OpenFOAM/db/IOstreams/memory/UListStream.H new file mode 100644 index 00000000000..132dc812128 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/UListStream.H @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + Input/output streams with externally managed storage. + +\*---------------------------------------------------------------------------*/ + +#ifndef UListStream_H +#define UListStream_H + +#include "UIListStream.H" +#include "UOListStream.H" + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/memory/UOBufStream.H b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H similarity index 52% rename from src/OpenFOAM/db/IOstreams/memory/UOBufStream.H rename to src/OpenFOAM/db/IOstreams/memory/UOListStream.H index 6a8df54e7ae..5500fb53831 100644 --- a/src/OpenFOAM/db/IOstreams/memory/UOBufStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::UOBufStream + Foam::UOListStream Description Similar to OStringStream but using an externally managed buffer for @@ -38,7 +38,7 @@ Description DynamicList<char> buffer(4096); // allocate some large buffer { - UOBufStream os(buffer); + UOListStream os(buffer); os << "content1" << " and more content"; buffer.setSize(os.size()); // synchronize sizes } @@ -46,12 +46,12 @@ Description something.write(buffer, buffer.size()); \endcode - Although the UOBufStream is quite lightweight, there may be cases + Although the UOListStream is quite lightweight, there may be cases where it is preferable to reuse the stream as well. \code DynamicList<char> buffer(4096); // allocate some large buffer - UOBufStream os(buffer); + UOListStream os(buffer); os << "content1" << " and more content"; buffer.setSize(os.size()); // synchronize sizes @@ -70,41 +70,171 @@ Description something.write(buffer, os.size()); \endcode +See Also + Foam::IListStream + Foam::OListStream + Foam::UIListStream + \*---------------------------------------------------------------------------*/ -#ifndef UOBufStream_H -#define UOBufStream_H +#ifndef UOListStream_H +#define UOListStream_H -#include "BufStreamAllocator.H" +#include "DynamicList.H" +#include "FixedList.H" #include "OSstream.H" +#include "memoryStreamBuffer.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declaration -template<class T, int SizeMin> class DynamicList; +/*---------------------------------------------------------------------------*\ + Class UOListAllocator Declaration +\*---------------------------------------------------------------------------*/ + +//- An stream/stream-buffer allocator for external buffers +class UOListAllocator +{ + //- A streambuf adapter for output to UList or equivalent + class ulistbuf + : + public memorybuf::output + { + friend UOListAllocator; + + //- Underlying list storage + UList<char> list_; + + public: + + // Constructors + + //- Construct for specified buffer + ulistbuf(char* buffer, std::streamsize num) + : + list_(buffer, num) + { + set_pbuffer(list_); + } + + + // Member Functions + + //- Return the current list output capacity + inline label capacity() const + { + return list_.size(); + } + + //- Sync put buffer pointers to agree with list dimensions + inline void sync_pbuffer_to_list() + { + set_pbuffer(list_); + } + }; + + +protected: + + // Protected data + + typedef std::ostream stream_type; + + //- The stream buffer + ulistbuf buf_; + + //- The stream + stream_type stream_; + + + // Constructors + + //- Construct with buffer and number of bytes + UOListAllocator(char *buffer, size_t nbytes) + : + buf_(buffer, nbytes), + stream_(&buf_) + {} + + + // Protected Member Functions + + void printBufInfo(Ostream& os) const + { + os << "pos=" << buf_.tellp() + << " capacity=" << buf_.capacity(); + } + +public: + + // Public Member Functions + + //- The current list output capacity + inline label capacity() const + { + return buf_.capacity(); + } + + + //- The current output position in the buffer, + // which is also the addressed list size + inline label size() const + { + return buf_.tellp(); + } + + + //- Const access to written contents as a list of characters + inline const UList<char> list() const + { + return UList<char> + ( + const_cast<char*>(buf_.list_.cdata()), + buf_.tellp() + ); + } + + + //- Non-const access to written contents as a list of characters + inline UList<char> list() + { + return UList<char> + ( + const_cast<char*>(buf_.list_.cdata()), + buf_.tellp() + ); + } + + + //- Move to buffer start, clear errors + void rewind() + { + buf_.pubseekpos(0, std::ios_base::out); + stream_.clear(); // for safety, clear any old errors + } +}; /*---------------------------------------------------------------------------*\ - Class UOBufStream Declaration + Class UOListStream Declaration \*---------------------------------------------------------------------------*/ //- An OSstream attached to an unallocated external buffer -class UOBufStream +class UOListStream : - public BufStreamAllocator<std::ostream,false>, + public UOListAllocator, public OSstream { - typedef BufStreamAllocator<std::ostream,false> allocator_type; + typedef UOListAllocator allocator_type; public: // Constructors //- Construct using specified buffer and number of bytes - UOBufStream + UOListStream ( char* buffer, size_t nbytes, @@ -113,12 +243,12 @@ public: ) : allocator_type(buffer, nbytes), - OSstream(stream_, "output", format,version) + OSstream(stream_, "output", format, version) {} //- Construct using data area from a List and number of bytes - UOBufStream + UOListStream ( UList<char>& buffer, size_t size, @@ -126,56 +256,58 @@ public: versionNumber version=currentVersion ) : - UOBufStream(buffer.data(), size, format,version) + UOListStream(buffer.data(), size, format, version) {} + //- Construct using data area from a FixedList + template<unsigned FixedSize> + UOListStream + ( + FixedList<char,FixedSize>& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + UOListStream(buffer.data(), FixedSize, format, version) + {} //- Construct using data area from a List and its inherent storage size - UOBufStream + UOListStream ( UList<char>& buffer, streamFormat format=ASCII, versionNumber version=currentVersion ) : - UOBufStream(buffer.data(), buffer.size(), format,version) + UOListStream(buffer.data(), buffer.size(), format, version) {} //- Construct using data area from a DynamicList and its capacity template<int SizeMin> - UOBufStream + UOListStream ( DynamicList<char,SizeMin>& buffer, streamFormat format=ASCII, versionNumber version=currentVersion ) : - UOBufStream(buffer.data(), buffer.capacity(), format,version) + UOListStream(buffer.data(), buffer.capacity(), format, version) {} - //- Destructor - ~UOBufStream() - {} - - // Member functions - //- Return the current output position in the buffer - std::streampos size() const - { - return allocator_type::tellp(); - } - - //- Rewind the stream, clearing any old errors - void rewind() + virtual void rewind() { allocator_type::rewind(); setGood(); // resynchronize with internal state } + //- Print description to Ostream + virtual void print(Ostream& os) const; + }; diff --git a/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H new file mode 100644 index 00000000000..d0f412f1a43 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H @@ -0,0 +1,224 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::memorybuf + +Description + A std::streambuf used for memory buffer streams such as + UIListStream, UOListStream, etc. + +\*---------------------------------------------------------------------------*/ + +#ifndef memoryStreamBuffer_H +#define memoryStreamBuffer_H + +#include "UList.H" +#include <type_traits> +#include <sstream> + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class memorybuf Declaration +\*---------------------------------------------------------------------------*/ + +//- A streambuf for memory +class memorybuf +: + public std::streambuf +{ +protected: + + //- Set position pointer to relative position + virtual std::streampos seekoff + ( + std::streamoff off, + std::ios_base::seekdir way, + std::ios_base::openmode which = std::ios_base::in|std::ios_base::out + ) + { + const bool testin = which & std::ios_base::in; + const bool testout = which & std::ios_base::out; + + if (way == std::ios_base::beg) + { + if (testin) + { + setg(eback(), eback(), egptr()); + gbump(off); + } + if (testout) + { + setp(pbase(), epptr()); + pbump(off); + } + } + else if (way == std::ios_base::cur) + { + if (testin) + { + gbump(off); + } + if (testout) + { + pbump(off); + } + } + else if (way == std::ios_base::end) + { + if (testin) + { + setg(eback(), eback(), egptr()); + gbump(egptr() - eback() - off); + } + if (testout) + { + setp(pbase(), epptr()); + pbump(epptr() - pbase() - off); + } + } + + if (testin) + { + return (gptr() - eback()); // tellg() + } + if (testout) + { + return (pptr() - pbase()); // tellp() + } + + return -1; + } + + + //- Set position pointer to absolute position + virtual std::streampos seekpos + ( + std::streampos pos, + std::ios_base::openmode which = std::ios_base::in|std::ios_base::out + ) + { + return seekoff(pos, std::ios_base::beg, which); + } + + +public: + + // Forward declarations + class input; + class output; +}; + + +/*---------------------------------------------------------------------------*\ + Class memorybuf::input Declaration +\*---------------------------------------------------------------------------*/ + +//- An output streambuf for memory access +class memorybuf::input +: + public memorybuf +{ +protected: + + //- Get sequence of characters + virtual std::streamsize xsgetn(char* s, std::streamsize n) + { + std::streamsize count = 0; + + while (count < n && gptr() < egptr()) + { + *(s + count++) = *(gptr()); + gbump(1); + } + + return count; + } + + + //- The buffer get position + inline std::streamsize tellg() const + { + return (gptr() - eback()); + } + + //- Sync get buffer pointers to agree with list dimensions + inline void set_gbuffer(UList<char>& list) + { + setg(list.begin(), list.begin(), list.end()); + } +}; + + +/*---------------------------------------------------------------------------*\ + Class memorybuf::output Declaration +\*---------------------------------------------------------------------------*/ + +//- An output streambuf for memory access +class memorybuf::output +: + public memorybuf +{ +protected: + + //- Put sequence of characters + virtual std::streamsize xsputn(const char* s, std::streamsize n) + { + std::streamsize count = 0; + while (count < n && pptr() < epptr()) + { + *(pptr()) = *(s + count++); + pbump(1); + } + + return count; + } + + //- The buffer put position + inline std::streamsize tellp() const + { + return (pptr() - pbase()); + } + + //- Sync put buffer pointers to agree with list dimensions + inline void set_pbuffer(UList<char>& list) + { + setp(list.begin(), list.end()); + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab From 4818b5808e095d5e99b28db4010dd11f75f93145 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 26 Oct 2017 12:08:15 +0100 Subject: [PATCH 063/126] ENH: snappyHexMesh: add different method for cellZone-faceZone consistency. Fixes #629. --- .../snappyHexMesh/snappyHexMeshDict | 8 + .../meshRefinement/meshRefinement.H | 16 ++ .../meshRefinement/meshRefinementBaffles.C | 167 ++++++++++++++++-- .../refinementParameters.C | 3 +- .../refinementParameters.H | 8 + .../snappyHexMeshDriver/snappyRefineDriver.C | 4 + 6 files changed, 188 insertions(+), 18 deletions(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 46d570e206f..08eac7ef835 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -378,6 +378,14 @@ castellatedMeshControls // Optional: do not refine surface cells with opposite faces of // differing refinement levels //interfaceRefine false; + + // Optional: use an erosion instead of region assignment to allocate + // left-over cells to the background region (i.e. make cellZones + // consistent with the intersections of the surface). + // Erosion is specified as a number of erosion iterations. + // Erosion has less chance of bleeding and changing the zone + // for a complete region. + //nCellZoneErodeIter 2; } // Settings for the snapping. diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H index f0a9af23d1f..f807ad2dcfe 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H @@ -511,6 +511,7 @@ private: //- Determine patches for baffles void getBafflePatches ( + const label nErodeCellZones, const labelList& globalToMasterPatch, const pointField& locationsInMesh, const wordList& regionsInMesh, @@ -673,6 +674,17 @@ private: labelList& cellToZone ) const; + //- Opposite of findCellTopo: finds assigned cell connected to + // an unassigned one and puts it in the background zone. + void erodeCellZone + ( + const label nErodeCellZones, + const label backgroundZoneID, + const labelList& unnamedSurfaceRegion, + const labelList& namedSurfaceIndex, + labelList& cellToZone + ) const; + //- Make namedSurfaceIndex consistent with cellToZone // - clear out any blocked faces inbetween same cell zone. void makeConsistentFaceIndex @@ -686,6 +698,7 @@ private: void zonify ( const bool allowFreeStandingZoneFaces, + const label nErodeCellZones, const label backgroundZoneID, const pointField& locationsInMesh, const wordList& zonesInMesh, @@ -1037,6 +1050,7 @@ public: const bool useTopologicalSnapDetection, const bool removeEdgeConnectedCells, const scalarField& perpendicularAngle, + const label nErodeCellZones, const dictionary& motionDict, Time& runTime, const labelList& globalToMasterPatch, @@ -1067,6 +1081,7 @@ public: autoPtr<mapPolyMesh> splitMesh ( const label nBufferLayers, + const label nErodeCellZones, const labelList& globalToMasterPatch, const labelList& globalToSlavePatch, @@ -1148,6 +1163,7 @@ public: autoPtr<mapPolyMesh> zonify ( const bool allowFreeStandingZoneFaces, + const label nErodeCellZones, const pointField& locationsInMesh, const wordList& regionsInMesh, wordPairHashTable& zonesToFaceZone diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index 99d642c1bd3..66c3723a60a 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -279,6 +279,7 @@ void Foam::meshRefinement::getIntersections void Foam::meshRefinement::getBafflePatches ( + const label nErodeCellZones, const labelList& globalToMasterPatch, const pointField& locationsInMesh, const wordList& zonesInMesh, @@ -309,6 +310,7 @@ void Foam::meshRefinement::getBafflePatches zonify ( true, // allowFreeStandingZoneFaces + nErodeCellZones, -2, // zone to put unreached cells into locationsInMesh, zonesInMesh, @@ -331,16 +333,13 @@ void Foam::meshRefinement::getBafflePatches labelList neiCellZone; syncTools::swapBoundaryCellList(mesh_, cellToZone, neiCellZone); - const labelList testFaces(intersectedFaces()); - ownPatch.setSize(mesh_.nFaces()); ownPatch = -1; neiPatch.setSize(mesh_.nFaces()); neiPatch = -1; - forAll(testFaces, i) - { - label faceI = testFaces[i]; + forAll(ownPatch, faceI) + { if (unnamedRegion1[faceI] != -1 || unnamedRegion2[faceI] != -1) { label ownMasterPatch = -1; @@ -2060,6 +2059,111 @@ void Foam::meshRefinement::findCellZoneTopo } +void Foam::meshRefinement::erodeCellZone +( + const label nErodeCellZones, + const label backgroundZoneID, + const labelList& unnamedSurfaceRegion, + const labelList& namedSurfaceIndex, + labelList& cellToZone +) const +{ + // This routine fixes small problems with left over unassigned regions + // (after all off the unreachable bits of the mesh have been removed). + // The problem is that the cell zone information might be inconsistent + // with the face zone information. So what we do here is to erode + // any cell zones until we hit a named face. + // - backgroundZoneID = -2 : do not change so remove cells + // - backgroundZoneID = -1 : put into background + // Note that is the opposite of findCellZoneTopo which moves unassigned + // regions into a neighbouring region(=cellZone) unless there is an + // intersected faces inbetween the two. + + for (label iter = 0; iter < nErodeCellZones; iter++) + { + label nChanged = 0; + + labelList erodedCellToZone(cellToZone); + + // Do internal faces + for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) + { + if + ( + unnamedSurfaceRegion[facei] == -1 + && namedSurfaceIndex[facei] == -1 + ) + { + label own = mesh_.faceOwner()[facei]; + label nei = mesh_.faceNeighbour()[facei]; + if (cellToZone[own] == -2 && cellToZone[nei] >= -1) + { + erodedCellToZone[nei] = backgroundZoneID; + nChanged++; + } + else if (cellToZone[nei] == -2 && cellToZone[own] >= -1) + { + erodedCellToZone[own] = backgroundZoneID; + nChanged++; + } + } + } + + // Do boundary faces + + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + // Get coupled neighbour cellRegion + labelList neiCellZone; + syncTools::swapBoundaryCellList(mesh_, cellToZone, neiCellZone); + + // Calculate region to zone from cellRegions on either side of coupled + // face. + forAll(patches, patchi) + { + const polyPatch& pp = patches[patchi]; + + if (pp.coupled()) + { + forAll(pp, i) + { + label facei = pp.start()+i; + if + ( + unnamedSurfaceRegion[facei] == -1 + && namedSurfaceIndex[facei] == -1 + ) + { + label own = mesh_.faceOwner()[facei]; + label bFacei = facei-mesh_.nInternalFaces(); + if (neiCellZone[bFacei] == -2 && cellToZone[own] >= -1) + { + erodedCellToZone[own] = backgroundZoneID; + nChanged++; + } + } + } + } + } + + cellToZone.transfer(erodedCellToZone); + + reduce(nChanged, sumOp<label>()); + if (debug) + { + Pout<< "erodeCellZone : eroded " << nChanged + << " cells (moved from cellZone to background zone " + << backgroundZoneID << endl; + } + + if (nChanged == 0) + { + break; + } + } +} + + void Foam::meshRefinement::makeConsistentFaceIndex ( const labelList& surfaceMap, @@ -2281,6 +2385,7 @@ void Foam::meshRefinement::getIntersections void Foam::meshRefinement::zonify ( const bool allowFreeStandingZoneFaces, + const label nErodeCellZones, const label backgroundZoneID, const pointField& locationsInMesh, const wordList& zonesInMesh, @@ -2496,18 +2601,39 @@ void Foam::meshRefinement::zonify if (namedSurfaces.size()) { - Info<< "Walking from known cellZones; crossing a faceZone " - << "face changes cellZone" << nl << endl; + if (nErodeCellZones <= 0) + { + Info<< "Walking from known cellZones; crossing a faceZone " + << "face changes cellZone" << nl << endl; + + // Put unassigned regions into any connected cellZone + findCellZoneTopo + ( + backgroundZoneID, + pointField(0), + unnamedRegion1, // Intersections with unnamed surfaces + namedSurfaceIndex, // Intersections with named surfaces + surfaceToCellZone, + cellToZone + ); + } + else + { + Info<< "Eroding cellZone cells to make these consistent with" + << " faceZone faces" << nl << endl; + + // Erode cell zone cells (connected to an unassigned cell) + // and put them into backgroundZone + erodeCellZone + ( + nErodeCellZones, + backgroundZoneID, + unnamedRegion1, + namedSurfaceIndex, + cellToZone + ); + } - findCellZoneTopo - ( - backgroundZoneID, - pointField(0), - unnamedRegion1, // Intersections with unnamed surfaces - namedSurfaceIndex, // Intersections with named surfaces - surfaceToCellZone, - cellToZone - ); // Make sure namedSurfaceIndex is unset inbetween same cell zones. if (!allowFreeStandingZoneFaces) @@ -3424,6 +3550,7 @@ void Foam::meshRefinement::baffleAndSplitMesh const bool useTopologicalSnapDetection, const bool removeEdgeConnectedCells, const scalarField& perpendicularAngle, + const label nErodeCellZones, const dictionary& motionDict, Time& runTime, const labelList& globalToMasterPatch, @@ -3452,6 +3579,7 @@ void Foam::meshRefinement::baffleAndSplitMesh labelList ownPatch, neiPatch; getBafflePatches ( + nErodeCellZones, globalToMasterPatch, locationsInMesh, @@ -3522,6 +3650,7 @@ void Foam::meshRefinement::baffleAndSplitMesh labelList ownPatch, neiPatch; getBafflePatches ( + nErodeCellZones, globalToMasterPatch, locationsInMesh, @@ -3689,6 +3818,7 @@ void Foam::meshRefinement::mergeFreeStandingBaffles Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh ( const label nBufferLayers, + const label nErodeCellZones, const labelList& globalToMasterPatch, const labelList& globalToSlavePatch, @@ -3709,6 +3839,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh labelList ownPatch, neiPatch; getBafflePatches ( + nErodeCellZones, globalToMasterPatch, locationsInMesh, @@ -4202,6 +4333,7 @@ Foam::meshRefinement::dupNonManifoldBoundaryPoints() Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify ( const bool allowFreeStandingZoneFaces, + const label nErodeCellZones, const pointField& locationsInMesh, const wordList& zonesInMesh, wordPairHashTable& zonesToFaceZone @@ -4278,6 +4410,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify zonify ( allowFreeStandingZoneFaces, + nErodeCellZones,// Use erosion (>0) or regionSplit to clean up -1, // Set all cells with cellToZone -2 to -1 locationsInMesh, zonesInMesh, diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C index 2fb5844684f..d714253c9df 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C @@ -68,7 +68,8 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict) interfaceRefine_ ( dict.lookupOrDefault<Switch>("interfaceRefine", true) - ) + ), + nErodeCellZone_(dict.lookupOrDefault<label>("nCellZoneErodeIter", 0)) { point locationInMesh; if (dict.readIfPresent("locationInMesh", locationInMesh)) diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H index 9504efa5672..6ac70dc47fe 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H @@ -106,6 +106,9 @@ class refinementParameters Switch interfaceRefine_; + label nErodeCellZone_; + + // Private Member Functions //- Disallow default bitwise copy construct @@ -212,6 +215,11 @@ public: return interfaceRefine_; } + label nErodeCellZone() const + { + return nErodeCellZone_; + } + // Other diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C index 956fb4366f9..bf988056236 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C @@ -1362,6 +1362,7 @@ void Foam::snappyRefineDriver::removeInsideCells meshRefiner_.splitMesh ( nBufferLayers, // nBufferLayers + refineParams.nErodeCellZone(), globalToMasterPatch_, globalToSlavePatch_, refineParams.locationsInMesh(), @@ -1605,6 +1606,7 @@ void Foam::snappyRefineDriver::baffleAndSplitMesh refineParams.useTopologicalSnapDetection(), false, // perpendicular edge connected cells scalarField(0), // per region perpendicular angle + refineParams.nErodeCellZone(), motionDict, const_cast<Time&>(mesh.time()), @@ -1672,6 +1674,7 @@ void Foam::snappyRefineDriver::zonify meshRefiner_.zonify ( refineParams.allowFreeStandingZoneFaces(), + refineParams.nErodeCellZone(), refineParams.locationsInMesh(), refineParams.zonesInMesh(), zonesToFaceZone @@ -1731,6 +1734,7 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles refineParams.useTopologicalSnapDetection(), handleSnapProblems, // remove perp edge connected cells perpAngle, // perp angle + refineParams.nErodeCellZone(), motionDict, const_cast<Time&>(mesh.time()), -- GitLab From 16e75d84756f745924c321ff30baf01f05d7ec5c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 26 Oct 2017 21:23:24 +0200 Subject: [PATCH 064/126] ENH: add fileName::validate static method (issue #628) - similar to word::validate to allow stripping of invalid characters without triggering a FatalError. - use this validated fileName in Foam::readDir to avoid problems when a directory contains files with invalid characters in their names - adjust rmDir to handle filenames with invalid characters - fileName::equals() static method to compare strings while ignoring any differences that are solely due to duplicate slashes --- applications/test/fileName/Test-fileName.C | 214 +++++++++++++++++- .../test/primitives/Test-primitives.C | 89 ++++---- src/OSspecific/POSIX/POSIX.C | 149 +++++++----- .../primitives/strings/fileName/fileName.C | 149 +++++++++--- .../primitives/strings/fileName/fileName.H | 14 ++ 5 files changed, 478 insertions(+), 137 deletions(-) diff --git a/applications/test/fileName/Test-fileName.C b/applications/test/fileName/Test-fileName.C index 5de8912bd88..9ccd801245c 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-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,15 +39,135 @@ Description #include "POSIX.H" #include "Switch.H" #include "etcFiles.H" +#include "Pair.H" +#include "Tuple2.H" +#include <fstream> using namespace Foam; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +unsigned testStrip +( + const bool doClean, + std::initializer_list + < + Tuple2<bool, std::string> + > tests +) +{ + Info<< nl << "Checking with clean=" << Switch(doClean) << nl << endl; + + unsigned nFail = 0; + + for (const Tuple2<bool, std::string>& test : tests) + { + const bool expected = test.first(); + const std::string& input = test.second(); + + fileName output(fileName::validate(input, doClean)); + + // Check for real failure (invalid chars) vs. + // spurious failure (removed double slashes with 'doClean'). + + const bool same = + ( + doClean + ? fileName::equals(input, output) + : (input == output) + ); + + if (same) + { + if (expected) + { + Info<< "(pass) validated " << input << " = " << output << nl; + } + else + { + ++nFail; + Info<< "(fail) unexpected success for " << input << nl; + } + } + else + { + if (expected) + { + ++nFail; + Info<< "(fail) unexpected"; + } + else + { + Info<< "(pass) expected"; + } + + Info<< " failure for " << input << nl; + } + } + + return nFail; +} + + +unsigned testEquals +( + std::initializer_list + < + Tuple2<bool, Pair<std::string>> + > tests +) +{ + Info<< nl << "Checking fileName::equals()" << nl << endl; + + unsigned nFail = 0; + + for (const Tuple2<bool, Pair<std::string>>& test : tests) + { + const bool expected = test.first(); + const std::string& s1 = test.second().first(); + const std::string& s2 = test.second().second(); + + const bool same = fileName::equals(s1, s2); + + if (same) + { + if (expected) + { + Info<< "(pass) success"; + } + else + { + ++nFail; + Info<< "(fail) unexpected success"; + } + } + else + { + if (expected) + { + ++nFail; + Info<< "(fail) unexpected failure"; + } + else + { + Info<< "(pass) expected failure"; + } + + } + + Info<< " for " << s1 << " == " << s2 << nl; + } + return nFail; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { argList::noParallel(); + argList::addBoolOption("validate", "test fileName::validate"); argList::addBoolOption("ext", "test handing of file extensions"); argList::addBoolOption("construct", "test constructors"); argList::addBoolOption("default", "reinstate default tests"); @@ -235,6 +355,69 @@ int main(int argc, char *argv[]) Info<< nl; } + + if (args.optionFound("validate")) + { + unsigned nFail = 0; + Info<< nl << "Test fileName::validate" << nl; + + // Without clean + nFail += testEquals + ( + { + { true, { "abc", "abc/" } }, + { true, { "///abc/", "//abc///" } }, + { false, { " ab //c/", "ab/c" } }, + } + ); + + Info<< nl << "Test fileName::validate" << nl; + + // Without clean + nFail += testStrip + ( + false, + { + { true, "abc/" }, + { true, "/", }, + { true, "//", }, + { true, "/abc/def", }, + { true, "/abc/def/", }, + { false, "/abc def" }, + { true, "/abc////def///", }, + { false, "/abc//// def///" }, + } + ); + + // With clean + nFail += testStrip + ( + true, + { + { true, "abc/" }, + { true, "/" }, + { true, "//" }, + { true, "/abc/def" }, + { true, "/abc/def/" }, + { false, "/abc def" }, + { true, "/abc////def///" }, + { false, "/abc//// def///" }, + } + ); + + Info<< nl; + if (nFail) + { + Info<< "failed " << nFail; + } + else + { + Info<< "passed all"; + } + Info<< " fileName::validate tests" << nl; + } + + if (!defaultTests) { return 0; @@ -312,10 +495,32 @@ int main(int argc, char *argv[]) Foam::rm(lnB); Foam::rmDir(dirB); + Info<< nl << "=========================" << nl + << "Test some copying and deletion" << endl; + Info<< "Creating directory " << dirA << endl; Foam::mkDir(dirA); + Info<< "Populating with various files" << endl; + for + ( + const std::string name + : { "file-1", "file-2", "bad name one", "bad name 2" } + ) + { + // Full path, but without any stripping + const fileName file + ( + (static_cast<const std::string&>(dirA) + "/" + name), + false + ); + + Info<<" create: " << file << endl; + + std::ofstream os(file); + os << "file=<" << file << ">" << nl; + } const int oldPosix = POSIX::debug; POSIX::debug = 1; @@ -362,7 +567,7 @@ int main(int argc, char *argv[]) << " but is " << lnB.type(true) << exit(FatalError); } - // Delete + // Delete (link) Foam::rm(lnB); } @@ -379,12 +584,13 @@ int main(int argc, char *argv[]) << " but is " << lnB.type(false) << exit(FatalError); } - // Delete - Foam::rm(lnB); + // Delete (directory, not link) + Foam::rmDir(lnB); } POSIX::debug = oldPosix; + // Verify that rmDir works with bad names too Foam::rmDir(dirA); Foam::rm(lnA); } diff --git a/applications/test/primitives/Test-primitives.C b/applications/test/primitives/Test-primitives.C index acdb71fb052..d45a9feb736 100644 --- a/applications/test/primitives/Test-primitives.C +++ b/applications/test/primitives/Test-primitives.C @@ -51,7 +51,10 @@ template<class TYPE> unsigned testParsing ( TYPE (*function)(const std::string&), - const List<Tuple2<std::string, bool>>& tests + std::initializer_list + < + Tuple2<bool, std::string> + > tests ) { unsigned nFail = 0; @@ -60,10 +63,10 @@ unsigned testParsing // Expect some failures const bool prev = FatalIOError.throwExceptions(); - for (const Tuple2<std::string, bool>& test : tests) + for (const Tuple2<bool, std::string>& test : tests) { - const std::string& str = test.first(); - const bool expected = test.second(); + const bool expected = test.first(); + const std::string& str = test.second(); bool parsed = true; @@ -124,18 +127,18 @@ int main(int argc, char *argv[]) ( &readDouble, { - { "", false }, - { " ", false }, - { " xxx ", false }, - { " 1234E-", false }, - { " 1234E junk", false }, - { " 3.14159 ", true }, - { " 31.4159E-1 " , true }, - { " 100E1000 " , false }, - { " 1E-40 " , true }, - { " 1E-305 " , true }, - { " 1E-37 " , true }, - { " 1E-300 " , true }, + { false, "" }, + { false, " " }, + { false, " xxx " }, + { false, " 1234E-" }, + { false, " 1234E junk" }, + { true, " 3.14159 " }, + { true, " 31.4159E-1 " }, + { false, " 100E1000 " }, + { true, " 1E-40 " }, + { true, " 1E-305 " }, + { true, " 1E-37 " }, + { true, " 1E-300 " }, } ); } @@ -148,14 +151,14 @@ int main(int argc, char *argv[]) ( &readFloat, { - { " 3.14159 ", true }, - { " 31.4159E-1 " , true }, - { " 31.4159E200 " , false }, - { " 31.4159E20 " , true }, - { " 1E-40 " , true }, - { " 1E-305 " , true }, - { " 1E-37 " , true }, - { " 1E-300 " , true }, + { true, " 3.14159 " }, + { true, " 31.4159E-1 " }, + { false, " 31.4159E200 " }, + { true, " 31.4159E20 " }, + { true, " 1E-40 " }, + { true, " 1E-305 " }, + { true, " 1E-37 " }, + { true, " 1E-300 " }, } ); } @@ -166,15 +169,15 @@ int main(int argc, char *argv[]) ( &readNasScalar, { - { " 3.14159 ", true }, - { " 31.4159E-1 " , true }, - { " 314.159-2 " , true }, - { " 31.4159E200 " , true }, - { " 31.4159E20 " , true }, - { " 1E-40 " , true }, - { " 1E-305 " , true }, - { " 1E-37 " , true }, - { " 1E-300 " , true }, + { true, " 3.14159 " }, + { true, " 31.4159E-1 " }, + { true, " 314.159-2 " }, + { true, " 31.4159E200 " }, + { true, " 31.4159E20 " }, + { true, " 1E-40 " }, + { true, " 1E-305 " }, + { true, " 1E-37 " }, + { true, " 1E-300 " }, } ); } @@ -185,12 +188,12 @@ int main(int argc, char *argv[]) ( &readInt32, { - { " 3.14159 ", false }, - { " 31E1 ", false }, - { " 31.4159E-1 " , false }, - { "100" , true }, - { " 2147483644" , true }, - { " 2147483700 " , false }, + { false, " 3.14159 " }, + { false, " 31E1 " }, + { false, " 31.4159E-1 " }, + { true, "100" }, + { true, " 2147483644" }, + { false, " 2147483700 " }, } ); } @@ -202,10 +205,10 @@ int main(int argc, char *argv[]) ( &readUint32, { - { " 2147483644" , true }, - { " 2147483700 " , true }, - { " 4294967295 " , true }, - { " 4294968000 " , false }, + { true, "\t2147483644" }, + { true, " 2147483700 " }, + { true, " 4294967295 " }, + { false, " 4294968000 " }, } ); } diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index 708375bfadd..432dc8ccef4 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -109,6 +109,35 @@ static inline bool isBackupName(const Foam::fileName& name) ); } + +// Like fileName "/" global operator, but retain any invalid characters +static inline Foam::fileName fileNameConcat +( + const std::string& a, + const std::string& b +) +{ + if (a.size()) + { + if (b.size()) + { + // Two non-empty strings: can concatenate + return Foam::fileName((a + '/' + b), false); + } + + return Foam::fileName(a, false); + } + + // Or, if the first string is empty + + if (b.size()) + { + return Foam::fileName(b, false); + } + + // Both strings are empty + return Foam::fileName(); +} //! \endcond @@ -148,12 +177,10 @@ Foam::string Foam::getEnv(const std::string& envName) { return string(env); } - else - { - // Return null-constructed string rather than string::null - // to avoid cyclic dependencies in the construction of globals - return string(); - } + + // Return null-constructed string rather than string::null + // to avoid cyclic dependencies in the construction of globals + return string(); } @@ -220,10 +247,8 @@ Foam::string Foam::userName() { return pw->pw_name; } - else - { - return string(); - } + + return string(); } @@ -246,10 +271,8 @@ Foam::fileName Foam::home() { return pw->pw_dir; } - else - { - return fileName(); - } + + return fileName(); } @@ -266,10 +289,8 @@ Foam::fileName Foam::home(const std::string& userName) { return pw->pw_dir; } - else - { - return fileName(); - } + + return fileName(); } @@ -708,14 +729,15 @@ Foam::fileNameList Foam::readDir const bool followLink ) { - // Initial filename list size - // also used as increment if initial size found to be insufficient + // Initial filename list size and the increment when resizing the list static const int maxNnames = 100; // Basic sanity: cannot strip '.gz' from directory names const bool stripgz = filtergz && (type != fileName::DIRECTORY); const word extgz("gz"); + fileNameList dirEntries; + // Open directory and set the structure pointer // Do not attempt to open an empty directory name DIR *source; @@ -731,12 +753,12 @@ Foam::fileNameList Foam::readDir << "cannot open directory " << directory << endl; } - return fileNameList(); + return dirEntries; } if (POSIX::debug) { - //InfoInFunction + // InfoInFunction Pout<< FUNCTION_NAME << " : reading directory " << directory << endl; if ((POSIX::debug & 2) && !Pstream::master()) { @@ -744,22 +766,31 @@ Foam::fileNameList Foam::readDir } } - label nEntries = 0; - fileNameList dirEntries(maxNnames); + label nFailed = 0; // Entries with invalid characters + label nEntries = 0; // Number of selected entries + dirEntries.setSize(maxNnames); // Read and parse all the entries in the directory for (struct dirent *list; (list = ::readdir(source)) != nullptr; /*nil*/) { - const fileName name(list->d_name); + const std::string item(list->d_name); // Ignore files/directories beginning with "." // These are the ".", ".." directories and any hidden files/dirs - if (name.empty() || name[0] == '.') + if (item.empty() || item[0] == '.') { continue; } - if + // Validate filename without spaces, quotes, etc in the name. + // No duplicate slashes to strip - dirent will not have them anyhow. + + const fileName name(fileName::validate(item)); + if (name != item) + { + ++nFailed; + } + else if ( (type == fileName::DIRECTORY) || (type == fileName::FILE && !isBackupName(name)) @@ -783,10 +814,18 @@ Foam::fileNameList Foam::readDir } } } + ::closedir(source); - // Reset the length of the entries list + // Finalize the length of the entries list dirEntries.setSize(nEntries); - ::closedir(source); + + if (nFailed && POSIX::debug) + { + std::cerr + << "Foam::readDir() : reading directory " << directory << nl + << nFailed << " entries with invalid characters in their name" + << std::endl; + } return dirEntries; } @@ -911,22 +950,22 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink) } // Copy files - fileNameList contents = readDir(src, fileName::FILE, false, followLink); - forAll(contents, i) + fileNameList files = readDir(src, fileName::FILE, false, followLink); + for (const fileName& item : files) { if (POSIX::debug) { InfoInFunction - << "Copying : " << src/contents[i] - << " to " << destFile/contents[i] << endl; + << "Copying : " << src/item + << " to " << destFile/item << endl; } // File to file. - cp(src/contents[i], destFile/contents[i], followLink); + cp(src/item, destFile/item, followLink); } // Copy sub directories. - fileNameList subdirs = readDir + fileNameList dirs = readDir ( src, fileName::DIRECTORY, @@ -934,17 +973,17 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink) followLink ); - forAll(subdirs, i) + for (const fileName& item : dirs) { if (POSIX::debug) { InfoInFunction - << "Copying : " << src/subdirs[i] + << "Copying : " << src/item << " to " << destFile << endl; } // Dir to Dir. - cp(src/subdirs[i], destFile, followLink); + cp(src/item, destFile, followLink); } } else @@ -1002,12 +1041,10 @@ bool Foam::ln(const fileName& src, const fileName& dst) { return true; } - else - { - WarningInFunction - << "symlink from " << src << " to " << dst << " failed." << endl; - return false; - } + + WarningInFunction + << "symlink from " << src << " to " << dst << " failed." << endl; + return false; } @@ -1157,14 +1194,20 @@ bool Foam::rmDir(const fileName& directory, const bool silent) label nErrors = 0; for (struct dirent *list; (list = ::readdir(source)) != nullptr; /*nil*/) { - const fileName name(list->d_name); - if (name.empty() || name == "." || name == "..") + const std::string item(list->d_name); + + // Ignore "." and ".." directories + if (item.empty() || item == "." || item == "..") { - // Ignore "." and ".." directories continue; } - const fileName path = directory/name; + // Allow invalid characters (spaces, quotes, etc), + // otherwise we cannot subdirs with these types of names. + // -> const fileName path = directory/name; <- + + const fileName path(fileNameConcat(directory, item)); + if (path.type(false) == fileName::DIRECTORY) { if (!rmDir(path, true)) // Only report errors at the top-level @@ -1548,10 +1591,8 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol) // symbol can be found if there was no error return !::dlerror(); } - else - { - return false; - } + + return false; } @@ -1680,7 +1721,7 @@ Foam::label Foam::allocateThread() } } - label index = threads_.size(); + const label index = threads_.size(); if (POSIX::debug) { Pout<< "allocateThread : new index:" << index << endl; @@ -1750,7 +1791,7 @@ Foam::label Foam::allocateMutex() } } - label index = mutexes_.size(); + const label index = mutexes_.size(); if (POSIX::debug) { diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index d191c46d5e4..8ca6388330c 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -37,20 +37,105 @@ int Foam::fileName::debug(debug::debugSwitch(fileName::typeName, 0)); const Foam::fileName Foam::fileName::null; +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::fileName Foam::fileName::validate +( + const std::string& s, + const bool doClean +) +{ + fileName out; + out.resize(s.size()); + + char prev = 0; + std::string::size_type count = 0; + + // Largely as per stripInvalid + for (auto iter = s.cbegin(); iter != s.cend(); ++iter) + { + const char c = *iter; + + if (fileName::valid(c)) + { + if (doClean && prev == '/' && c == '/') + { + // Avoid repeated '/'; + continue; + } + + // Only track valid chars + out[count++] = prev = c; + } + } + + if (doClean && prev == '/' && count > 1) + { + // Avoid trailing '/' + --count; + } + + out.resize(count); + + return out; +} + + +bool Foam::fileName::equals(const std::string& s1, const std::string& s2) +{ + // Do not use (s1 == s2) or s1.compare(s2) first since this would + // potentially be doing the comparison twice. + + std::string::size_type i1 = 0; + std::string::size_type i2 = 0; + + const auto n1 = s1.size(); + const auto n2 = s2.size(); + + //Info<< "compare " << s1 << " == " << s2 << endl; + while (i1 < n1 && i2 < n2) + { + //Info<< "check '" << s1[i1] << "' vs '" << s2[i2] << "'" << endl; + + if (s1[i1] != s2[i2]) + { + return false; + } + + // Increment to next positions and also skip repeated slashes + do + { + ++i1; + } + while (s1[i1] == '/'); + + do + { + ++i2; + } + while (s2[i2] == '/'); + } + //Info<< "return: " << Switch(i1 == n1 && i2 == n2) << endl; + + // Equal if it made it all the way through both strings + return (i1 == n1 && i2 == n2); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fileName::fileName(const UList<word>& lst) { // Estimate overall size size_type sz = lst.size(); // Approx number of '/' needed - for (const auto& item : lst) + for (const word& item : lst) { sz += item.size(); } reserve(sz); sz = 0; - for (const auto& item : lst) + for (const word& item : lst) { if (item.size()) { @@ -65,14 +150,14 @@ Foam::fileName::fileName(std::initializer_list<word> lst) { // Estimate overall size size_type sz = lst.size(); // Approx number of '/' needed - for (const auto& item : lst) + for (const word& item : lst) { sz += item.size(); } reserve(sz); sz = 0; - for (const auto& item : lst) + for (const word& item : lst) { if (item.size()) { @@ -217,10 +302,8 @@ std::string Foam::fileName::name(const std::string& str) { return str; } - else - { - return str.substr(beg+1); - } + + return str.substr(beg+1); } @@ -253,10 +336,8 @@ std::string Foam::fileName::nameLessExt(const std::string& str) { return str.substr(beg); } - else - { - return str.substr(beg, dot - beg); - } + + return str.substr(beg, dot - beg); } @@ -299,10 +380,8 @@ Foam::fileName Foam::fileName::lessExt() const { return *this; } - else - { - return substr(0, i); - } + + return substr(0, i); } @@ -407,28 +486,26 @@ void Foam::fileName::operator=(const char* str) Foam::fileName Foam::operator/(const string& a, const string& b) { - if (a.size()) // First string non-null + if (a.size()) { - if (b.size()) // Second string non-null + if (b.size()) { + // Two non-empty strings: can concatenate return fileName(a + '/' + b); } - else // Second string null - { - return a; - } + + return a; } - else // First string null + + // Or, if the first string is empty + + if (b.size()) { - if (b.size()) // Second string non-null - { - return b; - } - else // Second string null - { - return fileName(); - } + return b; } + + // Both strings are empty + return fileName(); } @@ -438,19 +515,19 @@ Foam::fileName Foam::search(const word& file, const fileName& directory) { // Search the current directory for the file fileNameList files(fileHandler().readDir(directory)); - forAll(files, i) + for (const fileName& item : files) { - if (files[i] == file) + if (item == file) { - return directory/file; + return directory/item; } } // If not found search each of the sub-directories fileNameList dirs(fileHandler().readDir(directory, fileName::DIRECTORY)); - forAll(dirs, i) + for (const fileName& item : dirs) { - fileName path = search(file, directory/dirs[i]); + fileName path = search(file, directory/item); if (path != fileName::null) { return path; diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index a0a3ece3ce8..8d8d7999b97 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -135,6 +135,20 @@ public: //- Is this character valid for a fileName? inline static bool valid(char c); + //- Construct validated fileName (no invalid characters). + // Optionally perform some additional cleanup such as removing + // duplicate or trailing slashes. + static fileName validate + ( + const std::string& s, + const bool doClean=false + ); + + //- This is a specialized (possibly slower) version of compare() + // that ignores duplicate or trailing slashes. + static bool equals(const std::string& s1, const std::string& s2); + + //- Cleanup filename // // Removes trailing \c / -- GitLab From 8ec64d812859c22f72d9e2151f6ff62e22bc888f Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 26 Oct 2017 23:59:18 +0200 Subject: [PATCH 065/126] STYLE: compilation of some unit tests --- .../test/HashTable3/Test-HashTable3.C | 33 ++- applications/test/Hashing/Make/options | 3 + applications/test/HashingSpeed/Make/options | 3 + .../test/PackedList2/Test-PackedList2.C | 197 +++++++++++++----- .../test/PackedList3/Test-PackedList3.C | 25 +-- .../test/PackedList4/Test-PackedList4.C | 20 +- 6 files changed, 196 insertions(+), 85 deletions(-) diff --git a/applications/test/HashTable3/Test-HashTable3.C b/applications/test/HashTable3/Test-HashTable3.C index 7184d305743..39c882d6eba 100644 --- a/applications/test/HashTable3/Test-HashTable3.C +++ b/applications/test/HashTable3/Test-HashTable3.C @@ -35,12 +35,20 @@ Description using namespace Foam; +template<class T> +Ostream& printInfo(Ostream& os, const HashTable<T, T, Hash<T>>& ht) +{ + os << " (size " << ht.size() << " capacity " << ht.capacity() << ") "; + return os; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { - const label nLoops = 30; + const label nLoops = 300; const label nBase = 100000; const label nSize = nLoops * nBase; @@ -52,17 +60,18 @@ int main(int argc, char *argv[]) // StaticHashTable<label, label, Hash<label>> map(2 * nSize); HashTable<label, label, Hash<label>> map(2 * nSize); - Info<< "Constructed map of size: " << nSize - << " (size " << map.size() << " capacity " << map.capacity() << ") " - << " " << timer.cpuTimeIncrement() << " s\n\n"; + Info<< "Constructed map of size: " << nSize; + printInfo(Info, map); + Info<< timer.cpuTimeIncrement() << " s\n\n"; for (label i = 0; i < nSize; i++) { map.insert(i, i); } - Info<< "Inserted " << nSize << " elements" - << " (size " << map.size() << " capacity " << map.capacity() << ") " - << timer.cpuTimeIncrement() << " s\n"; + + Info<< "Inserted " << nSize << " elements"; + printInfo(Info, map); + Info<< timer.cpuTimeIncrement() << " s\n\n"; label elemI = 0; for (label iLoop = 0; iLoop < nLoops; iLoop++) @@ -72,12 +81,14 @@ int main(int argc, char *argv[]) map.erase(elemI++); } - map.shrink(); - Info<< "loop " << iLoop << " - Erased " << nBase << " elements" - << " (size " << map.size() << " capacity " << map.capacity() << ") " - << timer.cpuTimeIncrement() << " s\n"; + // map.shrink(); + Info<< "loop " << iLoop << " - Erased " << nBase << " elements"; + printInfo(Info, map); + Info << nl; } + Info<< timer.cpuTimeIncrement() << " s\n"; + return 0; } diff --git a/applications/test/Hashing/Make/options b/applications/test/Hashing/Make/options index e69de29bb2d..7dba39797af 100644 --- a/applications/test/Hashing/Make/options +++ b/applications/test/Hashing/Make/options @@ -0,0 +1,3 @@ +EXE_INC = ${c++LESSWARN} + +/* EXE_LIBS = */ diff --git a/applications/test/HashingSpeed/Make/options b/applications/test/HashingSpeed/Make/options index e69de29bb2d..7dba39797af 100644 --- a/applications/test/HashingSpeed/Make/options +++ b/applications/test/HashingSpeed/Make/options @@ -0,0 +1,3 @@ +EXE_INC = ${c++LESSWARN} + +/* EXE_LIBS = */ diff --git a/applications/test/PackedList2/Test-PackedList2.C b/applications/test/PackedList2/Test-PackedList2.C index ce9b15ed51f..ad1df378de3 100644 --- a/applications/test/PackedList2/Test-PackedList2.C +++ b/applications/test/PackedList2/Test-PackedList2.C @@ -34,9 +34,25 @@ Description #include "StaticHashTable.H" #include "cpuTime.H" #include <vector> +#include <unordered_set> using namespace Foam; +#undef TEST_STATIC_HASH +#undef TEST_STD_BOOLLIST +#undef TEST_STD_UNORDERED_SET + +template<class T> +void printInfo(const std::unordered_set<T, Foam::Hash<T>>& ht) +{ + Info<<"std::unordered_set elements:" + << ht.size() + << " buckets:" << ht.bucket_count() + << " load_factor: " << ht.load_factor() + << nl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,11 +63,16 @@ int main(int argc, char *argv[]) const label n = 1000000; const label nIters = 1000; - unsigned int sum = 0; + unsigned long sum = 0; PackedBoolList packed(n, 1); boolList unpacked(n, true); - std::vector<bool> stlVector(n, true); + + #ifdef TEST_STD_BOOLLIST + std::vector<bool> stdBoolList(n, true); + #endif + + cpuTime timer; labelHashSet emptyHash; labelHashSet fullHash(1024); @@ -60,6 +81,11 @@ int main(int argc, char *argv[]) fullHash.insert(i); } + Info<< "populated labelHashSet in " + << timer.cpuTimeIncrement() << " s\n\n"; + + + #ifdef TEST_STATIC_HASH // fullStaticHash is really slow // give it lots of slots to help StaticHashTable<nil, label, Hash<label>> emptyStaticHash; @@ -68,14 +94,32 @@ int main(int argc, char *argv[]) { fullStaticHash.insert(i, nil()); } + Info<< "populated StaticHashTable in " + << timer.cpuTimeIncrement() << " s\n\n"; + #endif + + #ifdef TEST_STD_UNORDERED_SET + std::unordered_set<label, Foam::Hash<label>> emptyStdHash; + std::unordered_set<label, Foam::Hash<label>> fullStdHash; + fullStdHash.reserve(1024); + for (label i = 0; i < n; i++) + { + fullStdHash.insert(i); + } + Info<< "populated unordered_set in " + << timer.cpuTimeIncrement() << " s\n\n"; + #endif emptyHash.printInfo(Info); fullHash.printInfo(Info); + #ifdef TEST_STATIC_HASH emptyStaticHash.printInfo(Info); fullStaticHash.printInfo(Info); - - - cpuTime timer; + #endif + #ifdef TEST_STD_UNORDERED_SET + printInfo(emptyStdHash); + printInfo(fullStdHash); + #endif for (label iter = 0; iter < nIters; ++iter) { @@ -104,9 +148,11 @@ int main(int argc, char *argv[]) sum += packed[i]; } } - Info<< "Counting brute-force:" << timer.cpuTimeIncrement() + + std::cout + << "Counting brute-force:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; // Count packed @@ -115,9 +161,11 @@ int main(int argc, char *argv[]) { sum += packed.count(); } - Info<< "Counting via count():" << timer.cpuTimeIncrement() + + std::cout + << "Counting via count():" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; // Dummy addition @@ -129,25 +177,29 @@ int main(int argc, char *argv[]) sum += i + 1; } } - Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << " (sum is meaningless)" << endl; + + std::cout + << "Dummy loop:" << timer.cpuTimeIncrement() << " s" << nl + << " sum " << sum << " (sum is meaningless)" << nl; // // Read // + #ifdef TEST_STD_BOOLLIST // Read stl sum = 0; for (label iter = 0; iter < nIters; ++iter) { - for (unsigned int i = 0; i < stlVector.size(); i++) + for (unsigned int i = 0; i < stdBoolList.size(); i++) { - sum += stlVector[i]; + sum += stdBoolList[i]; } } - Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; - + std::cout + << "Reading stdBoolList:" << timer.cpuTimeIncrement() << " s" << nl + << " sum " << sum << nl; + #endif // Read unpacked sum = 0; @@ -158,8 +210,9 @@ int main(int argc, char *argv[]) sum += unpacked[i]; } } - Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + std::cout + << "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << nl + << " sum " << sum << nl; // Read packed @@ -171,9 +224,10 @@ int main(int argc, char *argv[]) sum += packed.get(i); } } - Info<< "Reading packed using get:" << timer.cpuTimeIncrement() + std::cout + << "Reading packed using get:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; // Read packed @@ -185,9 +239,10 @@ int main(int argc, char *argv[]) sum += packed[i]; } } - Info<< "Reading packed using reference:" << timer.cpuTimeIncrement() + std::cout + << "Reading packed using reference:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; // Read via iterator @@ -199,9 +254,10 @@ int main(int argc, char *argv[]) sum += it; } } - Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement() + std::cout + << "Reading packed using iterator:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; // Read via iterator @@ -213,9 +269,10 @@ int main(int argc, char *argv[]) sum += cit(); } } - Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement() + std::cout + << "Reading packed using const_iterator():" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; // Read empty hash @@ -227,9 +284,10 @@ int main(int argc, char *argv[]) sum += emptyHash.found(i); } } - Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement() + std::cout + << "Reading empty labelHashSet:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; // Read full hash @@ -241,12 +299,14 @@ int main(int argc, char *argv[]) sum += fullHash.found(i); } } - Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement() + std::cout + << "Reading full labelHashSet:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; - // Read empty static hash + #ifdef TEST_STATIC_HASH + // Read empty StaticHashTable sum = 0; for (label iter = 0; iter < nIters; ++iter) { @@ -255,13 +315,12 @@ int main(int argc, char *argv[]) sum += emptyStaticHash.found(i); } } - Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement() + std::cout + << "Reading empty StaticHash:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; + << " sum " << sum << nl; -#if 0 - // we can skip this test - it is usually quite slow - // Read full static hash + // Read full StaticHashTable sum = 0; for (label iter = 0; iter < nIters; ++iter) { @@ -270,26 +329,60 @@ int main(int argc, char *argv[]) sum += fullStaticHash.found(i); } } - Info<< "Reading full StaticHash:" << timer.cpuTimeIncrement() + std::cout + << "Reading full StaticHash:" << timer.cpuTimeIncrement() << " s" << nl - << " sum " << sum << endl; -#endif + << " sum " << sum << nl; + #endif - Info<< "Starting write tests" << endl; + + #ifdef TEST_STD_UNORDERED_SET + // Read empty stl set + sum = 0; + for (label iter = 0; iter < nIters; ++iter) + { + forAll(unpacked, i) + { + sum += (emptyStdHash.find(i) != emptyStdHash.cend()); + } + } + std::cout + << "Reading empty std::unordered_set:" << timer.cpuTimeIncrement() + << " s" << nl + << " sum " << sum << nl; + + // Read full stl set + sum = 0; + for (label iter = 0; iter < nIters; ++iter) + { + forAll(unpacked, i) + { + sum += (fullStdHash.find(i) != fullStdHash.cend()); + } + } + std::cout + << "Reading full std::unordered_set:" << timer.cpuTimeIncrement() + << " s" << nl + << " sum " << sum << nl; + #endif + + Info<< "Starting write tests" << nl; // // Write // - // Write stl + #ifdef TEST_STD_BOOLLIST + // Read stl for (label iter = 0; iter < nIters; ++iter) { - for (unsigned int i = 0; i < stlVector.size(); i++) + for (unsigned int i = 0; i < stdBoolList.size(); i++) { - stlVector[i] = true; + stdBoolList[i] = true; } } - Info<< "Writing stl:" << timer.cpuTimeIncrement() << " s" << endl; + Info<< "Writing stdBoolList:" << timer.cpuTimeIncrement() << " s" << nl; + #endif // Write unpacked for (label iter = 0; iter < nIters; ++iter) @@ -299,7 +392,7 @@ int main(int argc, char *argv[]) unpacked[i] = true; } } - Info<< "Writing unpacked:" << timer.cpuTimeIncrement() << " s" << endl; + Info<< "Writing unpacked:" << timer.cpuTimeIncrement() << " s" << nl; // Write packed @@ -311,7 +404,7 @@ int main(int argc, char *argv[]) } } Info<< "Writing packed using reference:" << timer.cpuTimeIncrement() - << " s" << endl; + << " s" << nl; // Write packed @@ -323,7 +416,7 @@ int main(int argc, char *argv[]) } } Info<< "Writing packed using set:" << timer.cpuTimeIncrement() - << " s" << endl; + << " s" << nl; // Write packed for (label iter = 0; iter < nIters; ++iter) @@ -334,7 +427,7 @@ int main(int argc, char *argv[]) } } Info<< "Writing packed using iterator:" << timer.cpuTimeIncrement() - << " s" << endl; + << " s" << nl; // Write packed @@ -343,7 +436,7 @@ int main(int argc, char *argv[]) packed = 0; } Info<< "Writing packed uniform 0:" << timer.cpuTimeIncrement() - << " s" << endl; + << " s" << nl; // Write packed @@ -352,7 +445,7 @@ int main(int argc, char *argv[]) packed = 1; } Info<< "Writing packed uniform 1:" << timer.cpuTimeIncrement() - << " s" << endl; + << " s" << nl; PackedList<3> oddPacked(n, 3); @@ -363,7 +456,7 @@ int main(int argc, char *argv[]) packed = 0; } Info<< "Writing packed<3> uniform 0:" << timer.cpuTimeIncrement() - << " s" << endl; + << " s" << nl; // Write packed @@ -372,7 +465,7 @@ int main(int argc, char *argv[]) packed = 1; } Info<< "Writing packed<3> uniform 1:" << timer.cpuTimeIncrement() - << " s" << endl; + << " s" << nl; Info<< "End\n" << endl; diff --git a/applications/test/PackedList3/Test-PackedList3.C b/applications/test/PackedList3/Test-PackedList3.C index 0665363ebe8..5add8789250 100644 --- a/applications/test/PackedList3/Test-PackedList3.C +++ b/applications/test/PackedList3/Test-PackedList3.C @@ -28,11 +28,7 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" -#include "boolList.H" -#include "HashSet.H" -#include "StaticHashTable.H" #include "cpuTime.H" -#include <vector> #include "PackedBoolList.H" using namespace Foam; @@ -44,24 +40,29 @@ using namespace Foam; int main(int argc, char *argv[]) { + const label nLoop = 5; const label n = 100000000; - const label nReport = 1000000; + // const label nReport = 1000000; cpuTime timer; // test inserts - // PackedBoolList PackedBoolList packed; - for (label i = 0; i < n; i++) + for (label iloop = 0; iloop < nLoop; ++iloop) { - if ((i % nReport) == 0 && i) + for (label i = 0; i < n; ++i) { - Info<< "i:" << i << " in " << timer.cpuTimeIncrement() << " s" - <<endl; + // if ((i % nReport) == 0 && i) + // { + // Info<< "." << flush; + // } + packed[i] = 1; + // Make compiler do something else too + packed[i/2] = 0; } - packed[i] = 1; } - Info<< "insert test: " << n << " elements in " + Info<< nl + << "insert test: " << nLoop << "*" << n << " elements in " << timer.cpuTimeIncrement() << " s\n\n"; Info << "\nEnd\n" << endl; diff --git a/applications/test/PackedList4/Test-PackedList4.C b/applications/test/PackedList4/Test-PackedList4.C index ee85d629854..e50eee04f4d 100644 --- a/applications/test/PackedList4/Test-PackedList4.C +++ b/applications/test/PackedList4/Test-PackedList4.C @@ -28,6 +28,7 @@ Description \*---------------------------------------------------------------------------*/ #include "uLabel.H" +#include "boolList.H" #include "IOstreams.H" #include "PackedBoolList.H" #include "StringStream.H" @@ -146,17 +147,16 @@ int main(int argc, char *argv[]) Info<< list4 << " indices: " << list4.used()() << nl; Info<< "\nassign from labelList\n"; - list4 = labelList - ( - IStringStream - ( - "(0 1 2 3 12 13 14 19 20 21)" - )() - ); + list4 = labelList{0, 1, 2, 3, 12, 13, 14, 19, 20, 21}; list4.printInfo(Info, true); Info<< list4 << " indices: " << list4.used()() << nl; + // Not yet: + // PackedBoolList list5{0, 1, 2, 3, 12, 13, 14, 19, 20, 21}; + // list5.printInfo(Info, true); + // Info<< list5 << " indices: " << list5.used()() << nl; + Info<< "\nassign from indices\n"; list4.read ( @@ -170,13 +170,13 @@ int main(int argc, char *argv[]) list4.printInfo(Info, true); Info<< list4 << " indices: " << list4.used()() << nl; - List<bool> boolLst(list4.size()); + boolList bools(list4.size()); forAll(list4, i) { - boolLst[i] = list4[i]; + bools[i] = list4[i]; } - Info<< "List<bool>: " << boolLst << nl; + Info<< "boolList: " << bools << nl; // check roundabout assignments PackedList<2> pl2 -- GitLab From 0a62fd2f87396c8edd9d1e7a4829c5dee36f0dcb Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 27 Oct 2017 14:28:00 +0200 Subject: [PATCH 066/126] ENH: allow passing of comparator to sortToc methods - this increases the flexibility of the interface - Add stringOps 'natural' string sorting comparison. Digits are sorted in their natural order, which means that (file10.txt file05.txt file2.txt) are sorted as (file2.txt file05.txt file10.txt) STYLE: consistent naming of template parameters for comparators - Compare for normal binary predicates - ListComparePredicate for list compare binary predicates --- applications/test/sort/Test-sortList.C | 140 +++++++- src/OpenFOAM/Make/files | 1 + .../DictionaryBase/DictionaryBase.C | 11 + .../DictionaryBase/DictionaryBase.H | 4 + .../HashTables/HashTable/HashTable.C | 16 +- .../HashTables/HashTable/HashTable.H | 4 + .../containers/Lists/ListOps/ListOps.H | 40 ++- .../Lists/ListOps/ListOpsTemplates.C | 51 +-- .../Lists/SortableList/SortableList.C | 5 +- .../Lists/SortableList/SortableList.H | 4 +- src/OpenFOAM/containers/Lists/UList/UList.C | 12 +- src/OpenFOAM/containers/Lists/UList/UList.H | 40 +-- src/OpenFOAM/db/dictionary/dictionary.H | 4 + .../db/dictionary/dictionaryTemplates.C | 7 + .../primitives/predicates/predicates.H | 38 +- .../primitives/strings/stringOps/stringOps.H | 1 + .../strings/stringOps/stringOpsSort.C | 325 ++++++++++++++++++ .../strings/stringOps/stringOpsSort.H | 133 +++++++ 18 files changed, 757 insertions(+), 79 deletions(-) create mode 100644 src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C create mode 100644 src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.H diff --git a/applications/test/sort/Test-sortList.C b/applications/test/sort/Test-sortList.C index 1fbfcfcf39c..8b208f4f50f 100644 --- a/applications/test/sort/Test-sortList.C +++ b/applications/test/sort/Test-sortList.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,8 @@ Description #include "SortableList.H" #include "ListOps.H" +#include "HashSet.H" +#include "stringOps.H" using namespace Foam; @@ -175,6 +177,142 @@ int main(int argc, char *argv[]) Info<< "flat = " << values << endl; } + // Sort strings + { + HashSet<string> hashed + { + "2.txt", + "05.txt", + "15.txt", + "other.bak04", + "other.bak1", + "file1.txt", + "file10.txt", + "file2.txt", + "file100.txt", + "file.txt", + "file011.txt", + "file15.txt", + "file0009.txt", + "abcd.txt", + + // Some regular processor directories + "processor0", + "processor1", + "processor9", + "processor10", + "processor11", + "processor20", + "processor21", + "processor35", + "processors", + + // Aggregate processor directories + "processor0-31", + "processor32-63", + "processor64-95", + "processor96-127", + "processor128-159", + "processor160-191", + "processor192-223", + "processor224-255", + }; + + Info<< nl << "Test string sorting" << nl << endl; + + // Using hash toc + if (true) + { + Info<< "Unsorted" << hashed.toc() << endl; + Info<< "sortedToc" << hashed.sortedToc() << endl; + Info<< "natural" + << hashed.sortedToc(stringOps::natural_sort()) << endl; + + Info<< "reverse natural" + << hashed.sortedToc(stringOps::natural_sort::reverse()) + << endl; + } + + // Normal list + if (true) + { + labelList order; + + List<string> strings(hashed.toc()); + Info<< nl << "stringList:" << strings << endl; + + sort(strings); + Info<< "normal sort:" << strings << endl; + + shuffle(strings); + sort(strings, stringOps::natural_sort()); + Info<< "natural sort:" << strings << endl; + + shuffle(strings); + sort(strings, stringOps::natural_sort::reverse()); + Info<< "reverse natural:" << strings << endl; + + strings = hashed.toc(); + + Info<< nl << "test sorted order" << endl; + Info<< nl << "list:" << strings << endl; + + sortedOrder(strings, order); + Info<< "sortedOrder:" << flatOutput(order) << endl; + + shuffle(strings); + sort(strings, stringOps::natural_sort()); + Info<< "reverse natural:" << strings << endl; + + shuffle(strings); + sort(strings, stringOps::natural_sort::reverse()); + Info<< "reverse natural:" << strings << endl; + + sortedOrder + ( + strings, + order, + stringOps::natural_sort::less<string>(strings) + ); + Info<< "natural sortedOrder: " << flatOutput(order) << endl; + } + + // SortableList + if (false) + { + SortableList<string> sortable; + Info<< nl << "Testing sortable list"; + + // Assign to ensure list is initially unsorted + sortable = hashed.toc(); + Info<< nl << "input:" << sortable << endl; + + sortable.sort(); + Info<< nl << "normal:" << sortable << endl; + + // This is still a bother (looks fairly ugly) + // so not implemented for now + + /// // Assign to ensure list is initially unsorted + /// sortable = hashed.toc(); + /// sortable.sort + /// ( + /// stringOps::natural_sort::less<string>(sortable) + /// ); + /// Info<< nl << "natural:" << sortable << endl; + + /// // Assign to ensure list is initially unsorted + /// sortable = hashed.toc(); + /// sortable.sort + /// ( + /// stringOps::natural_sort::greater<string>(sortable) + /// ); + /// Info<< nl << "natural:" << sortable << endl; + } + + } + + Info<< "\nEnd\n" << endl; return 0; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index acf60a63d05..4a6adb98a16 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -114,6 +114,7 @@ $(strings)/wordRe/wordRe.C $(strings)/wordRes/wordRes.C $(strings)/lists/hashedWordList.C $(strings)/stringOps/stringOps.C +$(strings)/stringOps/stringOpsSort.C $(strings)/parsing/parsing.C ops = primitives/ops diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C index 60b390223c2..2f95d40f713 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C @@ -189,6 +189,17 @@ Foam::wordList Foam::DictionaryBase<IDLListType, T>::sortedToc() const } +template<class IDLListType, class T> +template<class Compare> +Foam::wordList Foam::DictionaryBase<IDLListType, T>::sortedToc +( + const Compare& comp +) const +{ + return hashedTs_.sortedToc(comp); +} + + template<class IDLListType, class T> void Foam::DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr) { diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H index f4d864d82c7..8c487374272 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H @@ -131,6 +131,10 @@ public: //- Return the table of contents as a sorted list wordList sortedToc() const; + //- Return table of contents sorted using the specified comparator + template<class Compare> + wordList sortedToc(const Compare& comp) const; + // Editing diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index 1f209ef350e..1c1d7b43606 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -268,13 +268,27 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const template<class T, class Key, class Hash> Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const { - List<Key> keyLst = this->toc(); + List<Key> keyLst(this->toc()); Foam::sort(keyLst); return keyLst; } +template<class T, class Key, class Hash> +template<class Compare> +Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc +( + const Compare& comp +) const +{ + List<Key> keyLst(this->toc()); + Foam::sort(keyLst, comp); + + return keyLst; +} + + template<class T, class Key, class Hash> template<class UnaryPredicate> Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocKeys diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index aa848e475c4..f9dda76f9c8 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -347,6 +347,10 @@ public: //- Return the table of contents as a sorted list List<Key> sortedToc() const; + //- Return table of contents sorted using the specified comparator + template<class Compare> + List<Key> sortedToc(const Compare& comp) const; + //- Return the sorted table of contents with keys that satisfy // the unary predicate, optionally with inverted logic. template<class UnaryPredicate> diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index d7c93bef023..c3a6406da9e 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -110,24 +110,44 @@ void inplaceMapKey(const labelUList& oldToNew, Container& lst); template<class T> void sortedOrder(const UList<T>& lst, labelList& order); -template<class T, class Cmp> -void sortedOrder(const UList<T>& lst, labelList& order, const Cmp& cmp); +//- Sort using specified list compare predicate +template<class T, class ListComparePredicate> +void sortedOrder +( + const UList<T>& lst, + labelList& order, + const ListComparePredicate& comp +); //- Generate (sorted) indices corresponding to duplicate list values template<class T> void duplicateOrder(const UList<T>& lst, labelList& order); -template<class T, class Cmp> -void duplicateOrder(const UList<T>& lst, labelList& order, const Cmp& cmp); +//- Generate (sorted) indices corresponding to duplicate list values +// sort using specified list compare predicate +template<class T, class ListComparePredicate> +void duplicateOrder +( + const UList<T>& lst, + labelList& order, + const ListComparePredicate& comp +); //- Generate (sorted) indices corresponding to unique list values template<class T> void uniqueOrder(const UList<T>& lst, labelList& order); -template<class T, class Cmp> -void uniqueOrder(const UList<T>& lst, labelList& order, const Cmp& cmp); +//- Generate (sorted) indices corresponding to unique list values +// sort using specified list compare predicate +template<class T, class ListComparePredicate> +void uniqueOrder +( + const UList<T>& lst, + labelList& order, + const ListComparePredicate& comp +); //- Inplace sorting and removal of duplicates. @@ -137,8 +157,12 @@ void inplaceUniqueSort(ListType& lst); //- Inplace sorting and removal of duplicates. // Do not use FixedList for the input list, since it doesn't resize. -template<class ListType, class Cmp> -void inplaceUniqueSort(ListType& lst, const Cmp& cmp); +template<class ListType, class ListComparePredicate> +void inplaceUniqueSort +( + ListType& lst, + const ListComparePredicate& comp +); //- Extract elements of List when select is a certain value. diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index 641aa4ade0e..a55b8c714cd 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -211,27 +211,30 @@ void Foam::sortedOrder } -template<class T, class Cmp> +template<class T, class ListComparePredicate> void Foam::sortedOrder ( const UList<T>& lst, labelList& order, - const Cmp& cmp + const ListComparePredicate& comp ) { + const label len = lst.size(); + // list lengths must be identical - if (order.size() != lst.size()) + if (order.size() != len) { - // avoid copying any elements, they are overwritten anyhow + // Avoid copying any elements, they are overwritten anyhow order.clear(); - order.setSize(lst.size()); + order.setSize(len); } - forAll(order, elemI) + for (label i=0; i<len; ++i) { - order[elemI] = elemI; + order[i] = i; // identity } - Foam::stableSort(order, cmp); + + Foam::stableSort(order, comp); } @@ -246,12 +249,12 @@ void Foam::duplicateOrder } -template<class T, class Cmp> +template<class T, class ListComparePredicate> void Foam::duplicateOrder ( const UList<T>& lst, labelList& order, - const Cmp& cmp + const ListComparePredicate& comp ) { if (lst.size() < 2) @@ -260,7 +263,7 @@ void Foam::duplicateOrder return; } - sortedOrder(lst, order, cmp); + sortedOrder(lst, order, comp); const label last = (order.size()-1); label n = 0; @@ -286,15 +289,15 @@ void Foam::uniqueOrder } -template<class T, class Cmp> +template<class T, class ListComparePredicate> void Foam::uniqueOrder ( const UList<T>& lst, labelList& order, - const Cmp& cmp + const ListComparePredicate& comp ) { - sortedOrder(lst, order, cmp); + sortedOrder(lst, order, comp); if (order.size() > 1) { @@ -324,18 +327,24 @@ void Foam::inplaceUniqueSort(ListType& lst) } -template<class ListType, class Cmp> -void Foam::inplaceUniqueSort(ListType& lst, const Cmp& cmp) +template<class ListType, class ListComparePredicate> +void Foam::inplaceUniqueSort +( + ListType& lst, + const ListComparePredicate& comp +) { labelList order; - uniqueOrder(lst, order, cmp); + uniqueOrder(lst, order, comp); + + const label len = order.size(); - ListType newLst(order.size()); - newLst.setSize(order.size()); // Consistent sizing (eg, DynamicList) + ListType newLst(len); + newLst.setSize(len); // Consistent sizing (eg, DynamicList) - forAll(order, elemI) + for (label i=0; i<len; ++i) { - newLst[elemI] = lst[order[elemI]]; + newLst[i] = lst[order[i]]; } lst.transfer(newLst); diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C index fac433d7d75..6d2d2698dca 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C @@ -133,7 +133,7 @@ Foam::List<T>& Foam::SortableList<T>::shrink() template<class T> void Foam::SortableList<T>::sort() { - sortedOrder(*this, indices_); + Foam::sortedOrder(*this, indices_); List<T> lst(*this, indices_); // Copy with indices for mapping List<T>::transfer(lst); @@ -143,7 +143,7 @@ void Foam::SortableList<T>::sort() template<class T> void Foam::SortableList<T>::reverseSort() { - sortedOrder(*this, indices_, typename UList<T>::greater(*this)); + Foam::sortedOrder(*this, indices_, typename UList<T>::greater(*this)); List<T> lst(*this, indices_); // Copy with indices for mapping List<T>::transfer(lst); @@ -157,6 +157,7 @@ void Foam::SortableList<T>::swap(SortableList<T>& lst) indices_.swap(lst.indices_); } + template<class T> Foam::Xfer<Foam::List<T>> Foam::SortableList<T>::xfer() { diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H index 8ef6aefa197..083e69386f0 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H @@ -119,8 +119,8 @@ public: //- Clear the indices and return a reference to the underlying List List<T>& shrink(); - //- (stable) sort the list (if changed after construction time) - // also resizes the indices as required + //- (stable) sort the list (if changed after construction time). + // Resizes the indices as required void sort(); //- Reverse (stable) sort the list diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index b87e524b593..9258fbf637a 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -293,10 +293,10 @@ void Foam::sort(UList<T>& a) } -template<class T, class Cmp> -void Foam::sort(UList<T>& a, const Cmp& cmp) +template<class T, class Compare> +void Foam::sort(UList<T>& a, const Compare& comp) { - std::sort(a.begin(), a.end(), cmp); + std::sort(a.begin(), a.end(), comp); } @@ -307,10 +307,10 @@ void Foam::stableSort(UList<T>& a) } -template<class T, class Cmp> -void Foam::stableSort(UList<T>& a, const Cmp& cmp) +template<class T, class Compare> +void Foam::stableSort(UList<T>& a, const Compare& comp) { - std::stable_sort(a.begin(), a.end(), cmp); + std::stable_sort(a.begin(), a.end(), comp); } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 5c7999e2294..fcdbd7c0da0 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -139,39 +139,35 @@ public: // Public classes - //- Less function class that can be used for sorting - class less + //- A list compare binary predicate for normal sort + struct less { - const UList<T>& values_; + const UList<T>& values; - public: - - less(const UList<T>& values) + less(const UList<T>& list) : - values_(values) + values(list) {} - bool operator()(const label a, const label b) + bool operator()(const label a, const label b) const { - return values_[a] < values_[b]; + return values[a] < values[b]; } }; - //- Greater function class that can be used for sorting - class greater + //- A list compare binary predicate for reverse sort + struct greater { - const UList<T>& values_; - - public: + const UList<T>& values; - greater(const UList<T>& values) + greater(const UList<T>& list) : - values_(values) + values(list) {} - bool operator()(const label a, const label b) + bool operator()(const label a, const label b) const { - return values_[a] > values_[b]; + return values[a] > values[b]; } }; @@ -487,14 +483,14 @@ public: template<class T> void sort(UList<T>& a); -template<class T, class Cmp> -void sort(UList<T>& a, const Cmp& cmp); +template<class T, class Compare> +void sort(UList<T>& a, const Compare& comp); template<class T> void stableSort(UList<T>& a); -template<class T, class Cmp> -void stableSort(UList<T>& a, const Cmp& cmp); +template<class T, class Compare> +void stableSort(UList<T>& a, const Compare& comp); template<class T> void shuffle(UList<T>& a); diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index fc34a32d991..f0c66b97a85 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -452,6 +452,10 @@ public: //- Return the sorted table of contents wordList sortedToc() const; + //- Return table of contents sorted using the specified comparator + template<class Compare> + wordList sortedToc(const Compare& comp) const; + //- Return the list of available keys or patterns List<keyType> keys(bool patterns = false) const; diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index b247dfe8122..1e46e5da33b 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -28,6 +28,13 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template<class Compare> +Foam::wordList Foam::dictionary::sortedToc(const Compare& comp) const +{ + return hashedEntries_.sortedToc(comp); +} + + template<class T> T Foam::dictionary::lookupType ( diff --git a/src/OpenFOAM/primitives/predicates/predicates.H b/src/OpenFOAM/primitives/predicates/predicates.H index 0d7d8539fa2..a44b4eec7e2 100644 --- a/src/OpenFOAM/primitives/predicates/predicates.H +++ b/src/OpenFOAM/primitives/predicates/predicates.H @@ -49,37 +49,40 @@ namespace predicates Class always Declaration \*---------------------------------------------------------------------------*/ -//- Unary and binary predicates returning true, useful for templating. -class always +//- Unary and binary predicates that always return true, useful for templating. +struct always { -public: typedef always value_type; - //- Construct null + //- Null constructible inline always() {} - //- Evaluated as a bool - return true + //- Evaluated as a bool + // \return true inline operator bool() const { return true; } - //- Unary predicate returning true + //- Unary predicate + // \return true template<class T> inline bool operator()(const T&) const { return true; } - //- Binary predicate returning true + //- Binary predicate + // \return true template<class T1, class T2> inline bool operator()(const T1&, const T2&) const { return true; } - //- String match returning true + //- String match + // \return true inline bool match(const std::string&, bool literal=false) const { return true; @@ -91,37 +94,40 @@ public: Class never Declaration \*---------------------------------------------------------------------------*/ -//- Unary and binary predicates returning false, useful for templating. -class never +//- Unary and binary predicates that never return true, useful for templating. +struct never { -public: typedef never value_type; - //- Construct null + //- Null constructible inline never() {} - //- Evaluated as a bool - return false + //- Evaluated as a bool + // \return false inline operator bool() const { return false; } - //- Unary predicate returning false + //- Unary predicate + // \return false template<class T> inline bool operator()(const T&) const { return false; } - //- Binary predicate returning false + //- Binary predicate + // \return false template<class T1, class T2> inline bool operator()(const T1&, const T2&) const { return false; } - //- String match returning false + //- String match + // \return false inline bool match(const std::string&, bool literal=false) const { return false; diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H index 92092f9d520..0d84856f52d 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H @@ -41,6 +41,7 @@ SourceFiles #include "word.H" #include "dictionary.H" #include "HashTable.H" +#include "stringOpsSort.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C new file mode 100644 index 00000000000..aeeb29fa14b --- /dev/null +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C @@ -0,0 +1,325 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +Changes for OpenFOAM + + Code cleanup, reduction, elimination of redundant code. +\*---------------------------------------------------------------------------*/ + +//======================================================================== +// Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, distribute with modifications, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +// THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name(s) of the above copyright +// holders shall not be used in advertising or otherwise to promote the +// sale, use or other dealings in this Software without prior written +// authorization. +//======================================================================== + +//======================================================================== +// Original Author: Jan-Marten Spit <jmspit@euronet.nl> +//======================================================================== + +#include "stringOpsSort.H" +#include <cctype> +#include <cstring> + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Local tweaks/preferences: +// +// [DIGITS_ALWAYS_FIRST] : as per original code +// This results in "file123.txt" sorting before "file.txt", which is +// inconsistent with what 'ls -v' produces +// - normally do not want this (Mark Olesen: Oct-2017) +#undef DIGITS_ALWAYS_FIRST + +// [IGNORE_LEADING_ZEROS] : as per original code +// This results in "file0005.txt" sorting before "file06.txt" +// -> normally want this (Mark Olesen: Oct-2017) +#define IGNORE_LEADING_ZEROS + +// [MANUAL_NUMCOMPARE] : handwritten code instead of strncmp +// The orignal code has a mix of strncmp for equality but handwritten code +// for greater-than/less-than. +// +// -> this does to be unneeded, rely on strncmp() return values +// (Mark Olesen: Oct-2017) +#undef MANUAL_NUMCOMPARE + +// [DEBUG_NATSTRCMP] : debug info to std::cerr (for development purposes only) +#undef DEBUG_NATSTRCMP + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef DEBUG_NATSTRCMP +#include <iostream> + +template<class T> +static inline void debugPrint(const char* text, T item1, T item2) +{ + std::cerr << text << ": <" << item1 << "> <" << item2 << ">\n"; +} + +// Character sequences, end pointer is _inclusive_. +static inline void debugPrint +( + const char* b1, const char* e1, + const char* b2, const char* e2 +) +{ + std::cerr << "<"; + while (b1 < e1) { std::cerr << *b1++; } + std::cerr << *e1 << "> "; + + std::cerr << "<"; + while (b2 < e2) { std::cerr << *b2++; } + std::cerr << *e2 << ">\n"; +} +#endif + +#ifdef MANUAL_NUMCOMPARE +// Manual comparison of identical length (digit) sequences +static inline int manual_numcompare(const char* s1, const char* s2) +{ + while (*s1 && *s2) + { + const int cmp = (*s1 - *s2); + if (!cmp) return cmp; + + ++s1; ++s2; + } + return 0; // Length check done before in caller. +} +#endif + + +// ------------------------------------------------------------------------- // + +int Foam::stringOps::natstrcmp(const char* s1, const char* s2) +{ + #ifdef DEBUG_NATSTRCMP + debugPrint("natstrcmp", s1, s2); + #endif + + // States for state engine + enum stateType { SCAN, ALPHA, NUMERIC }; + + // Number of leading zeroes + unsigned zeros1 = 0; + unsigned zeros2 = 0; + + // Pointers to begin/end of integer sequences (without leading zeros) + const char* numbeg1 = nullptr; + const char* numbeg2 = nullptr; + const char* numend1 = nullptr; + const char* numend2 = nullptr; + + stateType state = SCAN; + + const char* p1 = s1; + const char* p2 = s2; + + while (*p1 && *p2) + { + // Bitmask for digits vs alpha + // - 0: neither are digits + // - 1: p1 is the only digit + // - 2: p2 is the only digit + // - 3: both p1 and p2 are digits + + const unsigned digitMask = + ((isdigit(*p2) ? 2:0) | (isdigit(*p1) ? 1:0)); + + switch (state) + { + case SCAN: + { + #ifdef DEBUG_NATSTRCMP + debugPrint("SCAN", *p1, *p2); + #endif + + switch (digitMask) + { + case 0: // (alpha,alpha) + { + state = ALPHA; + + if (*p1 == *p2) + { + ++p1; ++p2; + } + else + { + // Lexical compare + return (*p1 - *p2); + } + break; + } + + #ifdef DIGITS_ALWAYS_FIRST + case 0x1: // (digit,alpha) : digit < alpha + { + return -1; + break; + } + case 0x2: // (alpha,digit) : alpha > digit + { + return 1; + break; + } + #else /* DIGITS_ALWAYS_FIRST */ + case 0x1: // (digit,alpha) + case 0x2: // (alpha,digit) + { + // Lexical compare for digits/alpha + return (*p1 - *p2); + break; + } + #endif /* DIGITS_ALWAYS_FIRST */ + + default: // (digit,digit) + { + state = NUMERIC; + + #ifdef IGNORE_LEADING_ZEROS + if (!zeros1) // Start skip of leading zeros + { + while (*p1 == '0') { ++p1; ++zeros1; } + } + else + #endif + { + while (*p1 == '0') { ++p1; } + } + #ifdef IGNORE_LEADING_ZEROS + if (!zeros2) // Start skip of leading zeros + { + while (*p2 == '0') { ++p2; ++zeros2; } + } + else + #endif + { + while (*p2 == '0') { ++p2; } + } + + if (zeros1 == zeros2) + { + // Same number of zeros - so irrelevant + zeros1 = zeros2 = 0; + } + + if (!isdigit(*p1)) --p1; + if (!isdigit(*p2)) --p2; + + numbeg1 = numend1 = p1; + numbeg2 = numend2 = p2; + + break; + } + } + break; + } + + case ALPHA: + { + #ifdef DEBUG_NATSTRCMP + debugPrint("ALPHA", *p1, *p2); + #endif + + if (digitMask) + { + state = SCAN; + } + else // (alpha,alpha) + { + if (*p1 == *p2) + { + ++p1; ++p2; + } + else + { + // Lexical compare + return (*p1 - *p2); + } + } + break; + } + + case NUMERIC: + { + while (isdigit(*p1)) numend1 = p1++; + while (isdigit(*p2)) numend2 = p2++; + + #ifdef DEBUG_NATSTRCMP + debugPrint("NUMERIC", *p1, *p2); + debugPrint(numbeg1,numend1, numbeg2,numend2); + #endif + + // Length (minus 1) of each sequence + const size_t len1 = (numend1 - numbeg1); + const size_t len2 = (numend2 - numbeg2); + + if (len1 < len2) + { + return -1; + } + else if (len1 > len2) + { + return 1; + } + + // Same number of digits, leading zeros have been skipped. + // - so lexical and numerical compares are equivalent. + + const int cmp = strncmp(numbeg1, numbeg2, len1+1); + if (!cmp) + { + // Identical (digit) sequence - continue + state = SCAN; + } + else + { + #ifdef MANUAL_STRNCMP + return manual_numcompare(numbeg1, numbeg2); + #else + return cmp; + #endif + } + break; + } + } + } + + if (zeros1 < zeros2) return -1; + if (zeros1 > zeros2) return 1; + if (!*p1 && *p2) return -1; // s1 shorter than s2 + if (*p1 && !*p2) return 1; // s1 longer than s2 + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.H b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.H new file mode 100644 index 00000000000..8e6344f27a8 --- /dev/null +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.H @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +InNamespace + Foam::stringOps + +Description + Specialized string sorting. + +SourceFiles + stringOpsSort.C + +\*---------------------------------------------------------------------------*/ + +#ifndef stringOpsSort_H +#define stringOpsSort_H + +#include "stringOps.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace stringOps +{ + + //- 'Natural' compare for C-strings + // Uses algorithm and code from Jan-Marten Spit <jmspit@euronet.nl> + // + // In the 'natural' comparison, strings are compared alphabetically + // and numerically. Thus 'file010.txt' sorts after 'file2.txt' + // + // \param s1 left string + // \param s2 right string + // \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2 + int natstrcmp(const char* s1, const char* s2); + + + //- Encapsulation of natural order sorting for algorithms + struct natural_sort + { + //- Natural compare for std::string + // \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2 + static inline int compare + ( + const std::string& s1, + const std::string& s2 + ) + { + return natstrcmp(s1.data(), s2.data()); + } + + //- Default (forward) natural sorting + bool operator()(const std::string& s1, const std::string& s2) const + { + return natural_sort::compare(s1, s2) < 0; + } + + //- Reverse natural sorting + struct reverse + { + //- Reverse natural sorting + bool operator()(const std::string& s1, const std::string& s2) const + { + return natural_sort::compare(s1, s2) > 0; + } + }; + + + //- A list compare binary predicate for natural sort + template<class T> + struct less + { + const UList<T>& values; + + less(const UList<T>& list) + : + values(list) + {} + + bool operator()(const label a, const label b) const + { + return natural_sort::compare(values[a], values[b]) < 0; + } + }; + + + //- A list compare binary predicate for reverse natural sort + template<class T> + struct greater + { + const UList<T>& values; + + greater(const UList<T>& list) + : + values(list) + {} + + bool operator()(const label a, const label b) const + { + return natural_sort::compare(values[a], values[b]) > 0; + } + }; + }; + +} // End namespace stringOps +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab From 5b8b689a37c089e6184627d71a9eba4ceb2f034c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 27 Oct 2017 16:13:45 +0200 Subject: [PATCH 067/126] STYLE: split off HashTableCore into separate header --- .../HashTables/HashTable/HashTable.H | 82 +---------- .../HashTables/HashTable/HashTableCore.C | 2 +- .../HashTables/HashTable/HashTableCore.H | 134 ++++++++++++++++++ .../StaticHashTable/StaticHashTableI.H | 14 -- 4 files changed, 136 insertions(+), 96 deletions(-) create mode 100644 src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index f9dda76f9c8..1c42c9426a1 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -44,8 +44,6 @@ Note SourceFiles HashTableI.H HashTable.C - HashTableCoreI.H - HashTableCore.C HashTableIO.C \*---------------------------------------------------------------------------*/ @@ -53,13 +51,10 @@ SourceFiles #ifndef HashTable_H #define HashTable_H -#include "label.H" -#include "uLabel.H" #include "word.H" #include "Xfer.H" #include "Hash.H" -#include "className.H" -#include "nullObject.H" +#include "HashTableCore.H" #include <initializer_list> #include <iterator> @@ -84,80 +79,6 @@ template<class T, class Key, class Hash> Ostream& operator<<(Ostream& os, const HashTable<T, Key, Hash>& tbl); -/*---------------------------------------------------------------------------*\ - Class HashTableCore Declaration -\*---------------------------------------------------------------------------*/ - -//- Bits that are independent of the HashTable template parameters. -struct HashTableCore -{ - //- Maximum allowable internal table size. Approximately labelMax/4 - static const label maxTableSize; - - //- Return a canonical (power-of-two) of the requested size. - static label canonicalSize(const label requested_size); - - //- Construct null - HashTableCore() - {} - - //- Define template name and debug - ClassName("HashTable"); - - static_assert - ( - sizeof(NullObject) >= sizeof(void*), - "NullObject is too small to reinterpret_cast as HashTable::iterator" - ); - - - //- Factory method to create a non-const iterator begin - template<class IteratorType, class TableType> - inline static IteratorType iterator_begin(TableType& table); - - //- Factory method to create a const iterator begin - template<class IteratorType, class TableType> - inline static IteratorType iterator_begin(const TableType& table); - - //- Factory method to create a const iterator begin - template<class IteratorType, class TableType> - inline static IteratorType iterator_cbegin(const TableType& table); - - //- Factory method to create a non-const iterator end - // Simply reinterprets a NullObject as a hash-table iterator. - template<class IteratorType> - inline static const IteratorType& iterator_end(); - - //- Factory method to create a const iterator cend - // Simply reinterprets a NullObject as a hash-table iterator. - template<class IteratorType> - inline static const IteratorType& iterator_cend(); - - - //- Factory class for creating a begin/end pair for any const iterator. - template<class IteratorType, class TableType> - class const_iterator_pair - { - label size_; - IteratorType iter_; - - public: - - inline const_iterator_pair(const TableType& tbl); - - inline label size() const; - inline bool empty() const; - - inline IteratorType begin() const; - inline IteratorType cbegin() const; - - inline const IteratorType& end() const; - inline const IteratorType& cend() const; - }; - -}; - - /*---------------------------------------------------------------------------*\ Class HashTable Declaration \*---------------------------------------------------------------------------*/ @@ -871,7 +792,6 @@ inline void Swap // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "HashTableCoreI.H" #include "HashTableI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C index 08805148a96..d6d7bef31d7 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "HashTable.H" +#include "HashTableCore.H" #include "uLabel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H new file mode 100644 index 00000000000..46cc0c3f463 --- /dev/null +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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::HashTableCore + +Description + Template invariant parts of hash table implementation. + +SourceFiles + HashTableCoreI.H + HashTableCore.C + +\*---------------------------------------------------------------------------*/ + +#ifndef HashTableCore_H +#define HashTableCore_H + +#include "label.H" +#include "uLabel.H" +#include "className.H" +#include "nullObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class HashTableCore Declaration +\*---------------------------------------------------------------------------*/ + +//- Bits that are independent of HashTable template parameters. +struct HashTableCore +{ + //- Maximum allowable internal table size. Approximately labelMax/4 + static const label maxTableSize; + + //- Return a canonical (power-of-two) of the requested size. + static label canonicalSize(const label requested_size); + + //- Construct null + HashTableCore() + {} + + //- Define template name and debug + ClassName("HashTable"); + + static_assert + ( + sizeof(NullObject) >= sizeof(void*), + "NullObject is too small to reinterpret_cast as HashTable::iterator" + ); + + + //- Factory method to create a non-const iterator begin + template<class IteratorType, class TableType> + inline static IteratorType iterator_begin(TableType& table); + + //- Factory method to create a const iterator begin + template<class IteratorType, class TableType> + inline static IteratorType iterator_begin(const TableType& table); + + //- Factory method to create a const iterator begin + template<class IteratorType, class TableType> + inline static IteratorType iterator_cbegin(const TableType& table); + + //- Factory method to create a non-const iterator end + // Simply reinterprets a NullObject as a hash-table iterator. + template<class IteratorType> + inline static const IteratorType& iterator_end(); + + //- Factory method to create a const iterator cend + // Simply reinterprets a NullObject as a hash-table iterator. + template<class IteratorType> + inline static const IteratorType& iterator_cend(); + + + //- Factory class for creating a begin/end pair for any const iterator. + template<class IteratorType, class TableType> + class const_iterator_pair + { + label size_; + IteratorType iter_; + + public: + + inline const_iterator_pair(const TableType& tbl); + + inline label size() const; + inline bool empty() const; + + inline IteratorType begin() const; + inline IteratorType cbegin() const; + + inline const IteratorType& end() const; + inline const IteratorType& cend() const; + }; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "HashTableCoreI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index 2e6b5db0ea0..e93e7e4861f 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -343,13 +343,6 @@ Foam::StaticHashTable<T, Key, Hash>::begin() } } - #ifdef FULLDEBUG - if (debug) - { - Info<< "StaticHashTable is empty\n"; - } - #endif - return StaticHashTable<T, Key, Hash>::endIter_; } @@ -375,13 +368,6 @@ Foam::StaticHashTable<T, Key, Hash>::cbegin() const } } - #ifdef FULLDEBUG - if (debug) - { - Info<< "StaticHashTable is empty\n"; - } - #endif - return StaticHashTable<T, Key, Hash>::endConstIter_; } -- GitLab From 9729edf2931d31d7384c006df7a8ad1fb793f202 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 28 Oct 2017 17:38:42 +0200 Subject: [PATCH 068/126] STYLE: adjusted comments in natstrcmp --- .../strings/stringOps/stringOpsSort.C | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C index aeeb29fa14b..ca37276b8fd 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C @@ -56,11 +56,6 @@ Changes for OpenFOAM // - normally do not want this (Mark Olesen: Oct-2017) #undef DIGITS_ALWAYS_FIRST -// [IGNORE_LEADING_ZEROS] : as per original code -// This results in "file0005.txt" sorting before "file06.txt" -// -> normally want this (Mark Olesen: Oct-2017) -#define IGNORE_LEADING_ZEROS - // [MANUAL_NUMCOMPARE] : handwritten code instead of strncmp // The orignal code has a mix of strncmp for equality but handwritten code // for greater-than/less-than. @@ -204,23 +199,27 @@ int Foam::stringOps::natstrcmp(const char* s1, const char* s2) { state = NUMERIC; - #ifdef IGNORE_LEADING_ZEROS - if (!zeros1) // Start skip of leading zeros + // State changed from SCAN to NUMERIC, so skip leading + // leading zeros so the numeric comparison is + // untainted by them, but capture the first occurrence + // of leading zeroes for a final tie-break if needed. + + if (!zeros1) { + // First occurrence of any leading zeroes while (*p1 == '0') { ++p1; ++zeros1; } } else - #endif { while (*p1 == '0') { ++p1; } } - #ifdef IGNORE_LEADING_ZEROS - if (!zeros2) // Start skip of leading zeros + + if (!zeros2) { + // First occurrence of any leading zeroes while (*p2 == '0') { ++p2; ++zeros2; } } else - #endif { while (*p2 == '0') { ++p2; } } -- GitLab From 69786840afe7a8bdbcb763d9d8172dbaa8e49525 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 29 Oct 2017 11:34:09 +0100 Subject: [PATCH 069/126] STYLE: code cleanup for includeEntry --- .../includeEntry/includeEntry.C | 83 +++++++------------ .../includeEntry/includeEntry.H | 4 +- .../includeEtcEntry/includeEtcEntry.C | 57 ++++++------- .../includeEtcEntry/includeEtcEntry.H | 11 ++- .../includeIfPresentEntry.C | 8 +- 5 files changed, 70 insertions(+), 93 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index a9ddde6632d..90fe356885c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -24,11 +24,11 @@ License \*---------------------------------------------------------------------------*/ #include "includeEntry.H" -#include "IFstream.H" #include "addToMemberFunctionSelectionTable.H" #include "stringOps.H" -#include "Time.H" +#include "IFstream.H" #include "IOstreams.H" +#include "Time.H" #include "fileOperation.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -62,27 +62,6 @@ namespace functionEntries // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // -Foam::fileName Foam::functionEntries::includeEntry::resolveFile -( - Istream& is, - const dictionary& dict -) -{ - fileName fName(is); - // Substitute dictionary and environment variables. - // Allow empty substitutions. - stringOps::inplaceExpand(fName, dict, true, true); - - if (fName.empty() || fName.isAbsolute()) - { - return fName; - } - - // Relative name - return fileName(is.name()).path()/fName; -} - - Foam::fileName Foam::functionEntries::includeEntry::resolveFile ( const fileName& dir, @@ -91,6 +70,7 @@ Foam::fileName Foam::functionEntries::includeEntry::resolveFile ) { fileName fName(f); + // Substitute dictionary and environment variables. // Allow empty substitutions. stringOps::inplaceExpand(fName, dict, true, true); @@ -114,7 +94,8 @@ bool Foam::functionEntries::includeEntry::execute ) { const fileName rawName(is); - const fileName fName = resolveFile(is.name().path(), rawName, parentDict); + const fileName fName(resolveFile(is.name().path(), rawName, parentDict)); + autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName)); ISstream& ifs = ifsPtr(); @@ -133,27 +114,22 @@ bool Foam::functionEntries::includeEntry::execute ( dynamic_cast<const regIOobject&>(top) ); - //Info<< rio.name() << " : adding dependency on included file " - // << fName << endl; - rio.addWatch(fName); } parentDict.read(ifs); return true; } - else - { - FatalIOErrorInFunction - ( - is - ) << "Cannot open include file " - << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() - << exit(FatalIOError); - - return false; - } + + FatalIOErrorInFunction + ( + is + ) << "Cannot open include file " + << (ifs.name().size() ? ifs.name() : rawName) + << " while reading dictionary " << parentDict.name() + << exit(FatalIOError); + + return false; } @@ -165,7 +141,8 @@ bool Foam::functionEntries::includeEntry::execute ) { const fileName rawName(is); - const fileName fName = resolveFile(is.name().path(), rawName, parentDict); + const fileName fName(resolveFile(is.name().path(), rawName, parentDict)); + autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName)); ISstream& ifs = ifsPtr(); @@ -184,27 +161,23 @@ bool Foam::functionEntries::includeEntry::execute ( dynamic_cast<const regIOobject&>(top) ); - //Info<< rio.name() << " : adding dependency on included file " - // << fName << endl; - rio.addWatch(fName); } entry.read(parentDict, ifs); return true; } - else - { - FatalIOErrorInFunction - ( - is - ) << "Cannot open include file " - << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() - << exit(FatalIOError); - - return false; - } + + FatalIOErrorInFunction + ( + is + ) << "Cannot open include file " + << (ifs.name().size() ? ifs.name() : rawName) + << " while reading dictionary " << parentDict.name() + << exit(FatalIOError); + + return false; } + // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H index bbdc1220173..a2e7f5c9091 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H @@ -68,9 +68,6 @@ protected: // Protected Member Functions - //- Read the include fileName from Istream, expand and return - static fileName resolveFile(Istream& is, const dictionary& dict); - //- Expand include fileName and return static fileName resolveFile ( @@ -79,6 +76,7 @@ protected: const dictionary& dict ); + public: // Static data members diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C index c77204a5dd5..8fd559b7d69 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C @@ -24,9 +24,10 @@ License \*---------------------------------------------------------------------------*/ #include "includeEtcEntry.H" +#include "addToMemberFunctionSelectionTable.H" #include "etcFiles.H" #include "stringOps.H" -#include "addToMemberFunctionSelectionTable.H" +#include "IFstream.H" #include "IOstreams.H" #include "fileOperation.H" @@ -61,7 +62,7 @@ namespace functionEntries // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // -Foam::fileName Foam::functionEntries::includeEtcEntry::resolveFile +Foam::fileName Foam::functionEntries::includeEtcEntry::resolveEtcFile ( const fileName& f, const dictionary& dict @@ -78,7 +79,7 @@ Foam::fileName Foam::functionEntries::includeEtcEntry::resolveFile return fName; } - // Search the etc directories for the file + // Search etc directories for the file return Foam::findEtcFile(fName); } @@ -92,9 +93,8 @@ bool Foam::functionEntries::includeEtcEntry::execute ) { const fileName rawName(is); - const fileName fName(resolveFile(rawName, parentDict)); + const fileName fName(resolveEtcFile(rawName, parentDict)); - //IFstream ifs(fName); autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName)); ISstream& ifs = ifsPtr(); @@ -107,18 +107,16 @@ bool Foam::functionEntries::includeEtcEntry::execute parentDict.read(ifs); return true; } - else - { - FatalIOErrorInFunction - ( - is - ) << "Cannot open etc file " - << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() - << exit(FatalIOError); - - return false; - } + + FatalIOErrorInFunction + ( + is + ) << "Cannot open etc file " + << (ifs.name().size() ? ifs.name() : rawName) + << " while reading dictionary " << parentDict.name() + << exit(FatalIOError); + + return false; } @@ -130,9 +128,8 @@ bool Foam::functionEntries::includeEtcEntry::execute ) { const fileName rawName(is); - const fileName fName(resolveFile(rawName, parentDict)); + const fileName fName(resolveEtcFile(rawName, parentDict)); - //IFstream ifs(fName); autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName)); ISstream& ifs = ifsPtr(); @@ -145,18 +142,16 @@ bool Foam::functionEntries::includeEtcEntry::execute entry.read(parentDict, ifs); return true; } - else - { - FatalIOErrorInFunction - ( - is - ) << "Cannot open etc file " - << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() - << exit(FatalIOError); - - return false; - } + + FatalIOErrorInFunction + ( + is + ) << "Cannot open etc file " + << (ifs.name().size() ? ifs.name() : rawName) + << " while reading dictionary " << parentDict.name() + << exit(FatalIOError); + + return false; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H index 4920ff7db01..9d6ccae4091 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H @@ -79,9 +79,16 @@ class includeEtcEntry : public functionEntry { - //- Expand include fileName and return - static fileName resolveFile(const fileName& f, const dictionary& dict); +protected: + // Protected Member Functions + + //- Expand include fileName and search etc directories for the file + static fileName resolveEtcFile + ( + const fileName& f, + const dictionary& dict + ); public: diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C index 202e1408fe7..a110e55cd97 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C @@ -64,7 +64,9 @@ bool Foam::functionEntries::includeIfPresentEntry::execute Istream& is ) { - const fileName fName(resolveFile(is, parentDict)); + const fileName rawName(is); + const fileName fName(resolveFile(is.name().path(), rawName, parentDict)); + autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName)); ISstream& ifs = ifsPtr(); @@ -100,7 +102,9 @@ bool Foam::functionEntries::includeIfPresentEntry::execute Istream& is ) { - const fileName fName(resolveFile(is, parentDict)); + const fileName rawName(is); + const fileName fName(resolveFile(is.name().path(), rawName, parentDict)); + autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName)); ISstream& ifs = ifsPtr(); -- GitLab From f76431c53670d2fee08f03e0049577d9ce35d0ca Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 29 Oct 2017 12:37:47 +0100 Subject: [PATCH 070/126] ENH: retain original FoamFile dictionary header when including files. - previously using a top-level #include would inadvertently remove the original header --- src/OpenFOAM/db/dictionary/dictionary.H | 4 +- src/OpenFOAM/db/dictionary/dictionaryIO.C | 11 +- src/OpenFOAM/db/dictionary/entry/entryIO.C | 129 ++++++++---------- .../primitiveEntry/primitiveEntry.C | 75 +++++----- 4 files changed, 106 insertions(+), 113 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 7b3baa055a9..75ef089de29 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -414,7 +414,7 @@ public: //- Construct top-level dictionary from Istream, // reading entries until EOF, optionally keeping the header - dictionary(Istream& is, const bool keepHeader); + dictionary(Istream& is, bool keepHeader); //- Construct as copy given the parent dictionary dictionary(const dictionary& parentDict, const dictionary& dict); @@ -765,7 +765,7 @@ public: bool read(Istream& is); //- Read dictionary from Istream, optionally keeping the header - bool read(Istream& is, const bool keepHeader); + bool read(Istream& is, bool keepHeader); // Write diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 9c1e36c1b52..d608b74e689 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -55,7 +55,7 @@ Foam::dictionary::dictionary(Istream& is) } -Foam::dictionary::dictionary(Istream& is, const bool keepHeader) +Foam::dictionary::dictionary(Istream& is, bool keepHeader) : dictionaryName(is.name()), parent_(dictionary::null) @@ -77,8 +77,14 @@ Foam::autoPtr<Foam::dictionary> Foam::dictionary::New(Istream& is) // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -bool Foam::dictionary::read(Istream& is, const bool keepHeader) +bool Foam::dictionary::read(Istream& is, bool keepHeader) { + // Normally remove FoamFile header when read, but avoid this if it already + // existed prior to the current read. + // We would otherwise lose it with every top-level '#include ...' + + keepHeader = keepHeader || hashedEntries_.found("FoamFile"); + // Check for empty dictionary if (is.eof()) { @@ -103,7 +109,6 @@ bool Foam::dictionary::read(Istream& is, const bool keepHeader) while (!is.eof() && entry::New(*this, is)) {} - // Normally remove the FoamFile header entry if it exists if (!keepHeader) { remove("FoamFile"); diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index 3e549c9faf6..14bf0beb54e 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -62,10 +62,8 @@ bool Foam::entry::getKeyword(keyType& keyword, token& keyToken, Istream& is) keyword = keyToken.stringToken(); return true; } - else - { - return false; - } + + return false; } @@ -84,20 +82,17 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is) { return false; } - else - { - // Otherwise the token is invalid - cerr<< "--> FOAM Warning :" << nl - << " From function " - << FUNCTION_NAME << nl - << " in file " << __FILE__ - << " at line " << __LINE__ << nl - << " Reading " << is.name().c_str() << nl - << " found " << keyToken << nl - << " expected either " << token::END_BLOCK << " or EOF" - << std::endl; - return false; - } + + // Otherwise the token is invalid + std::cerr + << "--> FOAM Warning :" << nl + << " From function " << FUNCTION_NAME << nl + << " in file " << __FILE__ << " at line " << __LINE__ << nl + << " Reading " << is.name().c_str() << nl + << " found " << keyToken << nl + << " expected either " << token::END_BLOCK << " or EOF" + << std::endl; + return false; } @@ -154,22 +149,20 @@ bool Foam::entry::New false ); } - else - { - // Otherwise the token is invalid - cerr<< "--> FOAM Warning :" << nl - << " From function " - << FUNCTION_NAME << nl - << " in file " << __FILE__ - << " at line " << __LINE__ << nl - << " Reading " << is.name().c_str() << nl - << " found " << keyToken << nl - << " expected either " << token::END_BLOCK << " or EOF" - << std::endl; - return false; - } + + // Otherwise the token is invalid + std::cerr + << "--> FOAM Warning :" << nl + << " From function " << FUNCTION_NAME << nl + << " in file " << __FILE__ << " at line " << __LINE__ << nl + << " Reading " << is.name().c_str() << nl + << " found " << keyToken << nl + << " expected either " << token::END_BLOCK << " or EOF" + << std::endl; + return false; } - else if (keyword[0] == '#') + + if (keyword[0] == '#') { // Function entry @@ -186,17 +179,11 @@ bool Foam::entry::New false ); } - else - { - const word functionName(keyword.substr(1), false); - return functionEntry::execute(functionName, parentDict, is); - } + + const word functionName(keyword.substr(1), false); + return functionEntry::execute(functionName, parentDict, is); } - else if - ( - !disableFunctionEntries - && keyword[0] == '$' - ) + else if (!disableFunctionEntries && keyword[0] == '$') { // Substitution entry @@ -237,14 +224,12 @@ bool Foam::entry::New false ); } - else - { - FatalIOErrorInFunction(is) - << "Attempt to use undefined variable " << varName - << " as keyword" - << exit(FatalIOError); - return false; - } + + FatalIOErrorInFunction(is) + << "Attempt to use undefined variable " << varName + << " as keyword" + << exit(FatalIOError); + return false; } else { @@ -276,9 +261,6 @@ bool Foam::entry::New return false; } - // How to manage duplicate entries - bool mergeEntry = false; - const bool scoped = ( !disableFunctionEntries @@ -293,27 +275,19 @@ bool Foam::entry::New : parentDict.search(keyword, false, false) ); + // How to manage duplicate entries + bool mergeEntry = false; + if (finder.found()) { // Use keyword from the found entry (ie, eliminate scoping chars) const keyType key = finder.ref().keyword(); - if (mode == inputMode::MERGE) - { - mergeEntry = true; - } - else if (mode == inputMode::OVERWRITE) - { - // Clear existing dictionary so merge acts like overwrite - if (finder.isDict()) - { - finder.dict().clear(); - } - mergeEntry = true; - } - else if (mode == inputMode::PROTECT) + if (mode == inputMode::PROTECT || keyword == "FoamFile") { - // Read and discard the entry. + // Read and discard if existing element should be protected, + // or would potentially alter the "FoamFile" header. + // Disable function/variable expansion to avoid side-effects const int oldFlag = entry::disableFunctionEntries; entry::disableFunctionEntries = 1; @@ -330,7 +304,8 @@ bool Foam::entry::New entry::disableFunctionEntries = oldFlag; return true; } - else if (mode == inputMode::ERROR) + + if (mode == inputMode::ERROR) { FatalIOErrorInFunction(is) << "duplicate entry: " << key @@ -339,6 +314,20 @@ bool Foam::entry::New return false; } + if (mode == inputMode::MERGE) + { + mergeEntry = true; + } + else if (mode == inputMode::OVERWRITE) + { + // Clear existing dictionary so merge acts like overwrite + if (finder.isDict()) + { + finder.dict().clear(); + } + mergeEntry = true; + } + // Merge/overwrite data entry if (nextToken == token::BEGIN_BLOCK) diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C index 37cc203083e..88750273e7c 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C @@ -49,7 +49,7 @@ bool Foam::primitiveEntry::expandVariable { // Recursive substitution mode. // Content between {} is replaced with expansion. - string expanded = varName.substr(1, varName.size()-2); + string expanded(varName.substr(1, varName.size()-2)); // Substitute dictionary and environment variables. // Do not allow empty substitutions. @@ -57,46 +57,45 @@ bool Foam::primitiveEntry::expandVariable return expandVariable(expanded, dict); } - else + + // Lookup variable name in the given dictionary WITHOUT pattern matching. + // Having a pattern match means that in this example: + // { + // internalField XXX; + // boundaryField { ".*" {YYY;} movingWall {value $internalField;} + // } + // The $internalField would be matched by the ".*" !!! + + // Recursive, non-patterns + const entry* eptr = dict.lookupScopedEntryPtr(varName, true, false); + if (!eptr) { - // lookup the variable name in the given dictionary.... - // Note: allow wildcards to match? For now disabled since following - // would expand internalField to wildcard match and not expected - // internalField: - // internalField XXX; - // boundaryField { ".*" {YYY;} movingWall {value $internalField;} - const entry* ePtr = dict.lookupScopedEntryPtr(varName, true, false); - - // ...if defined append its tokens into this - if (ePtr) - { - if (ePtr->isDict()) - { - append(ePtr->dict().tokens()); - } - else - { - append(ePtr->stream()); - } - } - else + // Not found - revert to environment variable + const string str(getEnv(varName)); + + if (str.empty()) { - // Not in the dictionary - try an environment variable - const string envStr = getEnv(varName); - - if (envStr.empty()) - { - FatalIOErrorInFunction - ( - dict - ) << "Illegal dictionary entry or environment variable name " - << varName << endl << "Valid dictionary entries are " - << dict.toc() << exit(FatalIOError); - - return false; - } - append(tokenList(IStringStream('(' + envStr + ')')())); + FatalIOErrorInFunction + ( + dict + ) << "Illegal dictionary entry or environment variable name " + << varName << endl << "Valid dictionary entries are " + << dict.toc() << exit(FatalIOError); + + return false; } + + append(tokenList(IStringStream('(' + str + ')')())); + } + else if (eptr->isDict()) + { + // Found dictionary entry + append(eptr->dict().tokens()); + } + else + { + // Found primitive entry + append(eptr->stream()); } return true; -- GitLab From 743e75b978b718adafda1f0b19368dec8b1a9a48 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 29 Oct 2017 13:53:34 +0100 Subject: [PATCH 071/126] STYLE: code cleanup in stringOps --- .../primitives/strings/stringOps/stringOps.C | 226 ++++++++---------- 1 file changed, 99 insertions(+), 127 deletions(-) diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index b3c35d95413..0bb89dd6938 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -29,11 +29,71 @@ License #include "etcFiles.H" #include "StringStream.H" +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +namespace Foam +{ +// Standard handling of "~/", "./" etc. +static void standardExpansions(Foam::string& s) +{ + if (s.empty()) + { + return; + } + + if (s[0] == '.') + { + // Expand a lone '.' and an initial './' into cwd + if (s.size() == 1) + { + s = cwd(); + } + else if (s[1] == '/') + { + s.std::string::replace(0, 1, cwd()); + } + } + else if (s[0] == '~') + { + // Expand initial ~ + // ~/ => home directory + // ~OpenFOAM => site/user OpenFOAM configuration directory + // ~user => home directory for specified user + + string user; + fileName file; + + const auto slash = s.find('/'); + if (slash == std::string::npos) + { + user = s.substr(1); + } + else + { + user = s.substr(1, slash - 1); + file = s.substr(slash + 1); + } + + // NB: be a bit lazy and expand ~unknownUser as an + // empty string rather than leaving it untouched. + // otherwise add extra test + + if (user == "OpenFOAM") + { + s = findEtcFile(file); + } + else + { + s = home(user)/file; + } + } +} +} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //! \cond fileScope // Find the type/position of the ":-" or ":+" alternative values +// Returns 0, '-', '+' corresponding to not-found or ':-' or ':+' static inline int findParameterAlternative ( const std::string& s, @@ -70,6 +130,8 @@ static inline int findParameterAlternative //! \endcond +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + Foam::string Foam::stringOps::expand ( const string& original, @@ -257,13 +319,14 @@ Foam::string Foam::stringOps::getVariable { string value; - const entry* ePtr = dict.lookupScopedEntryPtr + const entry* eptr = dict.lookupScopedEntryPtr ( name, true, false ); - if (ePtr) + + if (eptr) { OStringStream buf; // Force floating point numbers to be printed with at least @@ -271,11 +334,8 @@ Foam::string Foam::stringOps::getVariable buf << fixed; buf.precision(IOstream::defaultPrecision()); - // fail for non-primitiveEntry - dynamicCast<const primitiveEntry> - ( - *ePtr - ).write(buf, true); + // Fails for non-primitiveEntry + dynamicCast<const primitiveEntry>(*eptr).write(buf, true); value = buf.str(); } @@ -308,8 +368,11 @@ Foam::string Foam::stringOps::getVariable } } } + } - if (!allowEmpty && value.empty()) + if (!allowEmpty && value.empty()) + { + if (allowEnvVars) { FatalIOErrorInFunction ( @@ -317,15 +380,14 @@ Foam::string Foam::stringOps::getVariable ) << "Cannot find dictionary or environment variable " << name << exit(FatalIOError); } - } - - if (!allowEmpty && value.empty()) - { - FatalIOErrorInFunction - ( - dict - ) << "Cannot find dictionary variable " - << name << exit(FatalIOError); + else + { + FatalIOErrorInFunction + ( + dict + ) << "Cannot find dictionary variable " + << name << exit(FatalIOError); + } } return value; @@ -360,8 +422,9 @@ Foam::string Foam::stringOps::expand { newString.append(string(s[index])); } - index++; + ++index; } + return newString; } @@ -390,7 +453,7 @@ Foam::string& Foam::stringOps::inplaceExpand if (s[begVar+1] == '{') { // Recursive variable expansion mode - label stringStart = begVar; + auto stringStart = begVar; begVar += 2; string varValue ( @@ -471,53 +534,8 @@ Foam::string& Foam::stringOps::inplaceExpand } } - if (!s.empty()) - { - if (s[0] == '~') - { - // Expand initial ~ - // ~/ => home directory - // ~OpenFOAM => site/user OpenFOAM configuration directory - // ~user => home directory for specified user - - string user; - fileName file; - - if ((begVar = s.find('/')) != string::npos) - { - user = s.substr(1, begVar - 1); - file = s.substr(begVar + 1); - } - else - { - user = s.substr(1); - } - - // NB: be a bit lazy and expand ~unknownUser as an - // empty string rather than leaving it untouched. - // otherwise add extra test - if (user == "OpenFOAM") - { - s = findEtcFile(file); - } - else - { - s = home(user)/file; - } - } - else if (s[0] == '.') - { - // Expand a lone '.' and an initial './' into cwd - if (s.size() == 1) - { - s = cwd(); - } - else if (s[1] == '/') - { - s.std::string::replace(0, 1, cwd()); - } - } - } + // Standard handling of "~/", "./" etc. + standardExpansions(s); return s; } @@ -596,32 +614,33 @@ Foam::string& Foam::stringOps::inplaceExpand ); - // lookup in the dictionary - const entry* ePtr = dict.lookupScopedEntryPtr + // Lookup in the dictionary without wildcards. + // See note in primitiveEntry + const entry* eptr = dict.lookupScopedEntryPtr ( varName, true, - false // wildcards disabled. See primitiveEntry + false ); // if defined - copy its entries - if (ePtr) + if (eptr) { OStringStream buf; // Force floating point numbers to be printed with at least // some decimal digits. buf << fixed; buf.precision(IOstream::defaultPrecision()); - if (ePtr->isDict()) + if (eptr->isDict()) { - ePtr->dict().write(buf, false); + eptr->dict().write(buf, false); } else { - // fail for other types + // Fail for non-primitiveEntry dynamicCast<const primitiveEntry> ( - *ePtr + *eptr ).write(buf, true); } @@ -816,53 +835,8 @@ Foam::string& Foam::stringOps::inplaceExpand } } - if (!s.empty()) - { - if (s[0] == '~') - { - // Expand initial ~ - // ~/ => home directory - // ~OpenFOAM => site/user OpenFOAM configuration directory - // ~user => home directory for specified user - - string user; - fileName file; - - if ((begVar = s.find('/')) != string::npos) - { - user = s.substr(1, begVar - 1); - file = s.substr(begVar + 1); - } - else - { - user = s.substr(1); - } - - // NB: be a bit lazy and expand ~unknownUser as an - // empty string rather than leaving it untouched. - // otherwise add extra test - if (user == "OpenFOAM") - { - s = findEtcFile(file); - } - else - { - s = home(user)/file; - } - } - else if (s[0] == '.') - { - // Expand a lone '.' and an initial './' into cwd - if (s.size() == 1) - { - s = cwd(); - } - else if (s[1] == '/') - { - s.std::string::replace(0, 1, cwd()); - } - } - } + // Standard handling of "~/", "./" etc. + standardExpansions(s); return s; } @@ -886,11 +860,9 @@ bool Foam::stringOps::inplaceReplaceVar(string& s, const word& varName) { return false; } - else - { - s.replace(i, content.size(), string("${" + varName + "}")); - return true; - } + + s.replace(i, content.size(), string("${" + varName + "}")); + return true; } -- GitLab From d6b32094e1d31ea031041f3380d6a06632d2e2b2 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 29 Oct 2017 16:02:19 +0100 Subject: [PATCH 072/126] ENH: add reverse iteration macros - forAllReverseIters and forAllReverseConstIters macros - stdFoam::rbegin(), stdFoam::rend() stdFoam::crbegin(), stdFoam::crend() --- applications/test/List/Test-List.C | 16 +++++ src/OpenFOAM/include/stdFoam.H | 112 ++++++++++++++++++++++++++--- 2 files changed, 119 insertions(+), 9 deletions(-) diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 990da8729f5..22aa159469d 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -105,6 +105,22 @@ int main(int argc, char *argv[]) }; Info<< "list2: " << list2 << endl; + Info<< "forAllConstIters(list2): "; + forAllConstIters(list2, iter) { Info<< " " << *iter; } + Info<< endl; + + Info<< "forAllReverseConstIters(list2): "; + forAllReverseConstIters(list2, iter) { Info<< " " << *iter; } + Info<< endl; + + Info<< "forAllConstIters(list2): "; + forAllIters(list2, iter) { *iter *= 2; Info<< " " << *iter; } + Info<< endl; + + Info<< "forAllReverseConstIters(list2): "; + forAllReverseIters(list2, iter) { *iter *= 0.5; Info<< " " << *iter; } + Info<< endl; + list1.append(list2); Info<< "list1.append(list2): " << list1 << endl; diff --git a/src/OpenFOAM/include/stdFoam.H b/src/OpenFOAM/include/stdFoam.H index 3141c383512..ac2653a779a 100644 --- a/src/OpenFOAM/include/stdFoam.H +++ b/src/OpenFOAM/include/stdFoam.H @@ -34,13 +34,15 @@ Description control over which definitions are used within the OpenFOAM code-base. SeeAlso - - http://en.cppreference.com/w/cpp/iterator/end - http://en.cppreference.com/w/cpp/iterator/begin + - http://en.cppreference.com/w/cpp/iterator/end + - http://en.cppreference.com/w/cpp/iterator/rbegin + - http://en.cppreference.com/w/cpp/iterator/rend \*---------------------------------------------------------------------------*/ -#ifndef StdFoam_H -#define StdFoam_H +#ifndef stdFoam_H +#define stdFoam_H #include <initializer_list> #include <utility> @@ -52,7 +54,9 @@ namespace stdFoam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Return iterator to the beginning of the container \a c or array. +// Forward iteration + +//- Return iterator to the beginning of the container \a c. // Definition as per std::begin C++17 template<class C> constexpr auto begin(C& c) -> decltype(c.begin()) @@ -60,7 +64,7 @@ constexpr auto begin(C& c) -> decltype(c.begin()) return c.begin(); } -//- Return const_iterator to the beginning of the container \a c or array. +//- Return const_iterator to the beginning of the container \a c. // Definition as per std::begin C++17 template<class C> constexpr auto begin(const C& c) -> decltype(c.begin()) @@ -68,7 +72,7 @@ constexpr auto begin(const C& c) -> decltype(c.begin()) return c.begin(); } -//- Return const_iterator to the beginning of the container \a c or array. +//- Return const_iterator to the beginning of the container \a c. // Definition as per std::cbegin C++17 template<class C> constexpr auto cbegin(const C& c) -> decltype(c.begin()) @@ -76,7 +80,7 @@ constexpr auto cbegin(const C& c) -> decltype(c.begin()) return c.begin(); } -//- Return iterator to the end of the container \a c or array. +//- Return iterator to the end of the container \a c array. // Definition as per std::end C++17 template<class C> constexpr auto end(C& c) -> decltype(c.end()) @@ -84,7 +88,7 @@ constexpr auto end(C& c) -> decltype(c.end()) return c.end(); } -//- Return const_iterator to the end of the container \a c or array. +//- Return const_iterator to the end of the container \a c array. // Definition as per std::end C++17 template<class C> constexpr auto end(const C& c) -> decltype(c.end()) @@ -92,7 +96,7 @@ constexpr auto end(const C& c) -> decltype(c.end()) return c.end(); } -//- Return const_iterator to the end of the container \a c or array. +//- Return const_iterator to the end of the container \a c. // Definition as per std::cend C++17 template<class C> constexpr auto cend(const C& c) -> decltype(c.end()) @@ -101,6 +105,57 @@ constexpr auto cend(const C& c) -> decltype(c.end()) } +// Reverse iteration + +//- Return reverse_iterator to the reverse-begin of container \a c. +// Definition as per std::rbegin C++17 +template<class C> +constexpr auto rbegin(C& c) -> decltype(c.rbegin()) +{ + return c.rbegin(); +} + +//- Return const_reverse_iterator to the reverse-begin of container \a c. +// Definition as per std::rbegin C++17 +template<class C> +constexpr auto rbegin(const C& c) -> decltype(c.rbegin()) +{ + return c.rbegin(); +} + +//- Return const_reverse_iterator to the reverse-begin of container \a c. +// Definition as per std::crbegin C++17 +template<class C> +constexpr auto crbegin(const C& c) -> decltype(c.rbegin()) +{ + return c.rbegin(); +} + +//- Return reverse_iterator to reverse-end of container \a c. +// Definition as per std::rend C++17 +template<class C> +constexpr auto rend(C& c) -> decltype(c.rend()) +{ + return c.rend(); +} + +//- Return const_reverse_iterator to reverse-end of container \a c. +// Definition as per std::rend C++17 +template<class C> +constexpr auto rend(const C& c) -> decltype(c.rend()) +{ + return c.rend(); +} + +//- Return const_reverse_iterator to reverse-end of container \a c. +// Definition as per std::crend C++17 +template<class C> +constexpr auto crend(const C& c) -> decltype(c.rend()) +{ + return c.rend(); +} + + } // End namespace stdFoam @@ -143,6 +198,43 @@ constexpr auto cend(const C& c) -> decltype(c.end()) ) +//- Rverse iterate across elements in the \a container object of type +// \a Container. +// \par Usage +// \code +// forAllReverseIters(container, iter) +// { +// statements; +// } +// \endcode +// \sa forAllReverseConstIters +#define forAllReverseIters(container,iter) \ + for \ + ( \ + auto iter = stdFoam::rbegin(container); \ + iter != stdFoam::rend(container); \ + --iter \ + ) + + +//- Reverse iterate across elements of \a container object with const access. +// \par Usage +// \code +// forAllReverseConstIters(container, iter) +// { +// statements; +// } +// \endcode +// \sa forAllReverseIters +#define forAllReverseConstIters(container,iter) \ + for \ + ( \ + auto iter = stdFoam::crbegin(container); \ + iter != stdFoam::crend(container); \ + --iter \ + ) + + //- Loop across all elements in \a list // \par Usage // \code @@ -169,6 +261,8 @@ constexpr auto cend(const C& c) -> decltype(c.end()) for (Foam::label i=(list).size()-1; i>=0; --i) +// Compatibility macros for pre C++11 + //- Iterate across all elements in the \a container object // of type \a Container. // \par Usage -- GitLab From cd46cb70413256978910f7e09b989f8b6bd795ee Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 29 Oct 2017 20:57:43 +0100 Subject: [PATCH 073/126] ENH: consistent reverse iterator definitions for UList and FixedList - consistent with C++ STL conventions, the reverse iterators should use operator++ to transit the list from rbegin() to rend(). The previous implementation used raw pointers, which meant that they had the opposite behaviour: operator-- to transit from rbegin() to rend(). The updated version only has operator++ defined, thus the compiler should catch any possible instances where people were using the old (incorrect) versions. - updated forAllReverseIters() and forAllConstReverseIters() macros to be consistent with new implementation and with C++ STL conventions. --- applications/test/FixedList/Test-FixedList.C | 58 +++++++++++ applications/test/List/Test-List.C | 34 ++++++- .../containers/Lists/FixedList/FixedList.H | 90 ++++++++++++++++-- .../containers/Lists/FixedList/FixedListI.H | 24 ++--- src/OpenFOAM/containers/Lists/UList/UList.H | 95 +++++++++++++++++-- src/OpenFOAM/containers/Lists/UList/UListI.H | 24 ++--- src/OpenFOAM/include/stdFoam.H | 8 +- 7 files changed, 287 insertions(+), 46 deletions(-) diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C index a06abee82f6..c501b77bc4c 100644 --- a/applications/test/FixedList/Test-FixedList.C +++ b/applications/test/FixedList/Test-FixedList.C @@ -38,6 +38,7 @@ See also #include "List.H" #include "IPstream.H" #include "OPstream.H" +#include <numeric> using namespace Foam; @@ -48,6 +49,63 @@ int main(int argc, char *argv[]) { argList args(argc, argv); + if (false) + { + FixedList<string, 1> ident; + + auto iter = ident.begin(); + + Info << iter->size() << endl; + + auto riter = ident.rbegin(); + Info << riter->size() << endl; + + auto iter2 = ident.rbegin(); + + iter2 = iter; + } + + { + FixedList<label, 15> ident; + std::iota(ident.begin(), ident.end(), 0); + + // auto iter = ident.begin(); + // + // iter += 5; + // Info << *iter << "< " << endl; + // iter -= 2; + // Info << *iter << "< " << endl; + + // Don't yet bother with making reverse iterators random access + // auto riter = ident.crbegin(); + + // riter += 5; + // Info << *riter << "< " << endl; + // riter += 2; + // Info << *riter << "< " << endl; + + Info<<"Ident:"; + forAllConstIters(ident, iter) + { + Info<<" " << *iter; + } + Info<< nl; + + Info<<"reverse:"; + forAllReverseIters(ident, iter) + { + Info<<" " << *iter; + } + Info<< nl; + + Info<<"const reverse:"; + forAllConstReverseIters(ident, iter) + { + Info<<" " << *iter; + } + Info<< nl; + } + { FixedList<label, 4> list1{1, 2, 3, 4}; diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 22aa159469d..cfb709bf3bb 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -47,6 +47,7 @@ See also #include "SubList.H" #include <list> +#include <numeric> using namespace Foam; @@ -79,6 +80,33 @@ int main(int argc, char *argv[]) #include "setRootCase.H" + { + List<label> ident(15); + std::iota(ident.begin(), ident.end(), 0); + + Info<<"Ident:"; + forAllConstIters(ident, iter) + { + Info<<" " << *iter; + } + Info<< nl; + + Info<<"reverse:"; + forAllReverseIters(ident, iter) + { + Info<<" " << *iter; + } + Info<< nl; + + Info<<"const reverse:"; + forAllConstReverseIters(ident, iter) + { + Info<<" " << *iter; + } + Info<< nl; + } + + if (false) { labelList intlist(IStringStream("(0 1 2)")()); @@ -109,15 +137,15 @@ int main(int argc, char *argv[]) forAllConstIters(list2, iter) { Info<< " " << *iter; } Info<< endl; - Info<< "forAllReverseConstIters(list2): "; - forAllReverseConstIters(list2, iter) { Info<< " " << *iter; } + Info<< "forAllConstReverseIters(list2): "; + forAllConstReverseIters(list2, iter) { Info<< " " << *iter; } Info<< endl; Info<< "forAllConstIters(list2): "; forAllIters(list2, iter) { *iter *= 2; Info<< " " << *iter; } Info<< endl; - Info<< "forAllReverseConstIters(list2): "; + Info<< "forAllReverseIters(list2): "; forAllReverseIters(list2, iter) { *iter *= 0.5; Info<< " " << *iter; } Info<< endl; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 8db0275bd4d..af54d5c782e 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -338,10 +338,86 @@ public: inline const_iterator end() const; - // STL reverse_iterator - - //- Reverse iterator for reverse traversal of FixedList - typedef T* reverse_iterator; + // Reverse iterators + + //- Generic const/non-const reverse iterator + template<bool Const> + class reverse_iterator_base + { + public: + //- The const/non-const type for entries + typedef typename std::conditional + <Const, const T, T>::type value_type; + + //- A pointer to a const/non-const entry + typedef value_type* pointer; + + //- A reference to a const/non-const entry + typedef value_type& reference; + + + private: + + //- The element pointer + pointer ptr_; + + public: + + //- Construct null or from list element pointer + inline reverse_iterator_base(pointer ptr = nullptr) + : + ptr_(ptr) + {} + + //- Copy construct + inline reverse_iterator_base(const reverse_iterator_base& iter) + : + ptr_(iter.ptr_) + {} + + + //- Reverse increment + inline void operator++() + { + --ptr_; + } + + //- Reverse increment + inline reverse_iterator_base operator++(int) + { + reverse_iterator_base old(*this); + --ptr_; + return old; + } + + //- Dereference iterator + reference operator*() const + { + return *ptr_; + } + + //- Dereference iterator + pointer operator->() const + { + return ptr_; + } + + //- Equality + bool operator==(const reverse_iterator_base& iter) const + { + return ptr_ == iter.ptr_; + } + + //- inequality + bool operator!=(const reverse_iterator_base& iter) const + { + return ptr_ != iter.ptr_; + } + }; + + + //- STL reverse_iterator + typedef reverse_iterator_base<false> reverse_iterator; //- Return reverse_iterator to begin reverse traversing the FixedList inline reverse_iterator rbegin(); @@ -350,10 +426,8 @@ public: inline reverse_iterator rend(); - // STL const_reverse_iterator - - //- Reverse iterator for reverse traversal of constant FixedList - typedef const T* const_reverse_iterator; + //- STL const reverse iterator + typedef reverse_iterator_base<true> const_reverse_iterator; //- Return const_reverse_iterator to begin reverse traversing FixedList inline const_reverse_iterator crbegin() const; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index c9554231f45..7e263d27728 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -465,50 +465,50 @@ Foam::FixedList<T, Size>::cend() const template<class T, unsigned Size> -inline typename Foam::FixedList<T, Size>::iterator +inline typename Foam::FixedList<T, Size>::reverse_iterator Foam::FixedList<T, Size>::rbegin() { - return &v_[Size-1]; + return reverse_iterator(&v_[Size-1]); } template<class T, unsigned Size> -inline typename Foam::FixedList<T, Size>::const_iterator +inline typename Foam::FixedList<T, Size>::const_reverse_iterator Foam::FixedList<T, Size>::rbegin() const { - return &v_[Size-1]; + return const_reverse_iterator(&v_[Size-1]); } template<class T, unsigned Size> -inline typename Foam::FixedList<T, Size>::const_iterator +inline typename Foam::FixedList<T, Size>::const_reverse_iterator Foam::FixedList<T, Size>::crbegin() const { - return &v_[Size-1]; + return const_reverse_iterator(&v_[Size-1]); } template<class T, unsigned Size> -inline typename Foam::FixedList<T, Size>::iterator +inline typename Foam::FixedList<T, Size>::reverse_iterator Foam::FixedList<T, Size>::rend() { - return &v_[-1]; + return reverse_iterator(&v_[-1]); } template<class T, unsigned Size> -inline typename Foam::FixedList<T, Size>::const_iterator +inline typename Foam::FixedList<T, Size>::const_reverse_iterator Foam::FixedList<T, Size>::rend() const { - return &v_[-1]; + return const_reverse_iterator(&v_[-1]); } template<class T, unsigned Size> -inline typename Foam::FixedList<T, Size>::const_iterator +inline typename Foam::FixedList<T, Size>::const_reverse_iterator Foam::FixedList<T, Size>::crend() const { - return &v_[-1]; + return const_reverse_iterator(&v_[-1]); } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 19257b6b551..b33f1706896 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -383,11 +383,94 @@ public: //- Return const_iterator to end traversing the constant UList inline const_iterator end() const; + // Reverse iterators - // STL reverse_iterator + //- Generic const/non-const reverse iterator + template<bool Const> + class reverse_iterator_base + { + public: + //- The const/non-const type for entries + typedef typename std::conditional + <Const, const T, T>::type value_type; + + //- A pointer to a const/non-const entry + typedef value_type* pointer; + + //- A reference to a const/non-const entry + typedef value_type& reference; + + + private: + + //- The element pointer + pointer ptr_; + + + public: + + //- Construct null or from list element pointer + inline reverse_iterator_base(pointer ptr = nullptr) + : + ptr_(ptr) + {} + + + //- Copy construct + inline reverse_iterator_base(const reverse_iterator_base& iter) + : + ptr_(iter.ptr_) + {} + + + //- Reverse increment + inline void operator++() + { + --ptr_; + } + + //- Reverse increment + inline reverse_iterator_base operator++(int) + { + reverse_iterator_base old(*this); + --ptr_; + return old; + } + + //- Reverse increase + inline void operator+=(int n) + { + ptr_ -= n; + } + + //- Dereference iterator + reference operator*() const + { + return *ptr_; + } + + //- Dereference iterator + pointer operator->() const + { + return ptr_; + } + + //- Equality + bool operator==(const reverse_iterator_base& iter) const + { + return ptr_ == iter.ptr_; + } + + //- inequality + bool operator!=(const reverse_iterator_base& iter) const + { + return ptr_ != iter.ptr_; + } + }; - //- Reverse iterator for reverse traversal of UList - typedef T* reverse_iterator; + + //- STL reverse_iterator + typedef reverse_iterator_base<false> reverse_iterator; //- Return reverse_iterator to begin reverse traversing the UList inline reverse_iterator rbegin(); @@ -396,10 +479,8 @@ public: inline reverse_iterator rend(); - // STL const_reverse_iterator - - //- Reverse iterator for reverse traversal of constant UList - typedef const T* const_reverse_iterator; + //- STL const reverse iterator + typedef reverse_iterator_base<true> const_reverse_iterator; //- Return const_reverse_iterator to begin reverse traversing the UList inline const_reverse_iterator crbegin() const; diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index e8060ac9bda..20cdaae6de2 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -286,45 +286,45 @@ Foam::UList<T>::cend() const } template<class T> -inline typename Foam::UList<T>::iterator +inline typename Foam::UList<T>::reverse_iterator Foam::UList<T>::rbegin() { - return &v_[size_-1]; + return reverse_iterator(&v_[size_-1]); } template<class T> -inline typename Foam::UList<T>::const_iterator +inline typename Foam::UList<T>::const_reverse_iterator Foam::UList<T>::rbegin() const { - return &v_[size_-1]; + return const_reverse_iterator(&v_[size_-1]); } template<class T> -inline typename Foam::UList<T>::const_iterator +inline typename Foam::UList<T>::const_reverse_iterator Foam::UList<T>::crbegin() const { - return &v_[size_-1]; + return const_reverse_iterator(&v_[size_-1]); } template<class T> -inline typename Foam::UList<T>::iterator +inline typename Foam::UList<T>::reverse_iterator Foam::UList<T>::rend() { - return &v_[-1]; + return reverse_iterator(&v_[-1]); } template<class T> -inline typename Foam::UList<T>::const_iterator +inline typename Foam::UList<T>::const_reverse_iterator Foam::UList<T>::rend() const { - return &v_[-1]; + return const_reverse_iterator(&v_[-1]); } template<class T> -inline typename Foam::UList<T>::const_iterator +inline typename Foam::UList<T>::const_reverse_iterator Foam::UList<T>::crend() const { - return &v_[-1]; + return const_reverse_iterator(&v_[-1]); } diff --git a/src/OpenFOAM/include/stdFoam.H b/src/OpenFOAM/include/stdFoam.H index ac2653a779a..ac6bd6c3422 100644 --- a/src/OpenFOAM/include/stdFoam.H +++ b/src/OpenFOAM/include/stdFoam.H @@ -207,13 +207,13 @@ constexpr auto crend(const C& c) -> decltype(c.rend()) // statements; // } // \endcode -// \sa forAllReverseConstIters +// \sa forAllConstReverseIters #define forAllReverseIters(container,iter) \ for \ ( \ auto iter = stdFoam::rbegin(container); \ iter != stdFoam::rend(container); \ - --iter \ + ++iter \ ) @@ -226,12 +226,12 @@ constexpr auto crend(const C& c) -> decltype(c.rend()) // } // \endcode // \sa forAllReverseIters -#define forAllReverseConstIters(container,iter) \ +#define forAllConstReverseIters(container,iter) \ for \ ( \ auto iter = stdFoam::crbegin(container); \ iter != stdFoam::crend(container); \ - --iter \ + ++iter \ ) -- GitLab From ba8fdda5cc9b11f1602f56f5bb9e290c16ffe478 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 30 Oct 2017 10:31:05 +0100 Subject: [PATCH 074/126] ENH: improve wcleanBuild, wcleanPlatform flexibility (issue #627) - add -compiler=NAME option to remove a build or platforms directory corresponding to any specified compiler on the current arch. - when -compiler or -compiler=NAME is specified, also clean related sub-directories as well. This will cleanup mpi-related directory. --- wmake/scripts/wcleanBuild | 185 ++++++++++++++++++++++++++++++++++++++ wmake/wcleanBuild | 136 +--------------------------- wmake/wcleanPlatform | 138 +--------------------------- 3 files changed, 187 insertions(+), 272 deletions(-) create mode 100755 wmake/scripts/wcleanBuild mode change 100755 => 120000 wmake/wcleanBuild mode change 100755 => 120000 wmake/wcleanPlatform diff --git a/wmake/scripts/wcleanBuild b/wmake/scripts/wcleanBuild new file mode 100755 index 00000000000..0c13af7642e --- /dev/null +++ b/wmake/scripts/wcleanBuild @@ -0,0 +1,185 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. +# +# Script +# wcleanBuild +# +# Usage +# wcleanBuild <option | platform> [.. <option | platform>] +# +# Description +# Deletes the specified 'build/' object files directories from the +# the project top-level 'build/' directory $WM_PROJECT_DIR. +# +# special platforms +# - 'all' removes all platforms. +# - 'compiler' corresponds to $WM_ARCH$WM_COMPILER. +# - 'current' corresponds to $WM_OPTIONS. +# +# You must be in the project or the third-party top-level directory +# to run this script. +# +# When called as wcleanPlatform, the target directory changes to +# 'platforms/ and the 'all' target also cleans up lnInclude dirs and +# tutorials +# +#------------------------------------------------------------------------------ +Script="${0##*/}" +targetDir=build # Safe default - override based on script name + +case "$Script" in +(*[Pp]latform*) + targetDir=platforms + ;; +esac + +usage() { + local extraText + if [ "$targetDir" = platforms ] + then + extraText=", lnInclude and clean tutorials" + fi + + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE + +Usage: ${0##*/} <option | platform> [.. <option | platform>] + +options: + -a, -all Same as 'all' + -c, -current Use \$WM_OPTIONS ($WM_OPTIONS) + -comp, -compiler Use \$WM_ARCH\$WM_COMPILER* ($WM_ARCH$WM_COMPILER) + -compiler=NAME Use \$WM_ARCH<NAME>* ($WM_ARCH<NAME>*) + -h, -help Print the usage + + +Deletes the specified $targetDir/ object file directories from the project +top-level $targetDir/ directory $WM_PROJECT_DIR. + +special platforms: + all Remove all platforms$extraText + compiler $WM_ARCH$WM_COMPILER (ie, \$WM_ARCH\$WM_COMPILER) + current $WM_OPTIONS (ie, \$WM_OPTIONS) + +You must be in the project or the third-party top-level directory +to run this script. + +USAGE + exit 1 +} + +# Find -help anywhere +for i +do + case "$i" in (-h | -help) usage ;; esac +done + +#------------------------------------------------------------------------------ +# Run from OPENFOAM or THIRDPARTY top-level directory only +wmakeCheckPwd -q "$WM_PROJECT_DIR" 2>/dev/null || \ +wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \ +{ +cat<<ERROR +${0##*/}: Error incorrect top-level directory + + Not in Project: $WM_PROJECT_DIR + Nor in ThirdParty: $WM_THIRD_PARTY_DIR + +ERROR + exit 1 +} + +if [ "$#" -eq 0 ] +then + usage "No platform specified to clean from $targetDir" +else + echo "$# platform(s) to clean from $targetDir" + echo +fi + + +for name +do + unset compiler + + case "$name" in + -a | -all | all) + echo "all $targetDir/ ..." + rm -rf $targetDir + if [ "$targetDir" = platforms ] + then + wcleanLnIncludeAll . + [ -x tutorials/Allclean ] && tutorials/Allclean + fi + echo + break # Removed everything - can stop now + ;; + -c | -current | current) + name="$WM_OPTIONS" + ;; + -comp | -compiler | compiler) + compiler="$WM_COMPILER" + unset name + ;; + -compiler=*) + compiler="${name#*=}" + unset name + ;; + esac + + if [ -n "$compiler" ] + then + name="$WM_ARCH$compiler" + + dirs=$(find $targetDir -maxdepth 1 -name "${name}*") + if [ -n "$dirs" ] + then + for name in $dirs + do + echo " '$name'" + rm -rf "$name" + done + echo + else + echo " '$name' - not built or already cleaned" + echo + fi + elif [ -n "$name" ] + then + if [ -d "$targetDir/$name" ] + then + echo " '$name'" + rm -rf "$targetDir/$name"* + echo + else + echo " '$name' - not built or already cleaned" + echo + fi + fi +done + +exit 0 # clean exit + +#------------------------------------------------------------------------------ diff --git a/wmake/wcleanBuild b/wmake/wcleanBuild deleted file mode 100755 index 3989b06e0a3..00000000000 --- a/wmake/wcleanBuild +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/sh -#------------------------------------------------------------------------------ -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. -# -# Script -# wcleanBuild -# -# Usage -# wcleanBuild <platform> [.. <platformN>] -# -# Description -# Deletes the specified 'build/' object files directories from the -# the project top-level 'build/' directory $WM_PROJECT_DIR. -# -# special platforms -# - 'all' removes all platforms. -# - 'compiler' corresponds to $WM_ARCH$WM_COMPILER. -# - 'current' corresponds to $WM_OPTIONS. -# -# You must be in the project or the third-party top-level directory -# to run this script. -# -#------------------------------------------------------------------------------ -Script=${0##*/} - -usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE - -Usage: $Script <platform> [.. <platformN>] - $Script -all | -compiler | -current [<platform> [.. <platformN>]] - -options: - -a, -all Same as 'all' - -comp, -compiler Same as 'compiler' - -c, -current Same as 'current' - -h, -help Print the usage - - -Deletes the specified build/ object file directories from the project -top-level build/ directory $WM_PROJECT_DIR. - -special platforms: - all Remove all platforms - compiler $WM_ARCH$WM_COMPILER (ie, \$WM_ARCH\$WM_COMPILER) - current $WM_OPTIONS (ie, \$WM_OPTIONS) - -You must be in the project or the third-party top-level directory -to run this script. - -USAGE - exit 1 -} - -# Find -help anywhere -for i -do - case "$i" in (-h | -help) usage ;; esac -done - -#------------------------------------------------------------------------------ -# Run from OPENFOAM or THIRDPARTY top-level directory only -wmakeCheckPwd -q "$WM_PROJECT_DIR" 2>/dev/null || \ -wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \ -{ -cat<<ERROR -${0##*/}: Error incorrect top-level directory - - Not in Project: $WM_PROJECT_DIR - Nor in ThirdParty: $WM_THIRD_PARTY_DIR - -ERROR - exit 1 -} - -if [ "$#" -eq 0 ] -then - usage "No platform specified" -else - echo "$# platform(s) to clean" - echo -fi - -for name -do - case "$name" in - -comp | -compiler | compiler) - name="$WM_ARCH$WM_COMPILER" - ;; - -c | -current | current) - name="$WM_OPTIONS" - ;; - -a | -all | all) - echo "all build/ ..." - rm -rf build - echo - break # Can stop now - ;; - esac - - if [ -n "$name" -d "build/$name" ] - then - echo " '$name'" - rm -rf "build/$name"* - echo - else - echo " '$name' - not built" - echo - fi -done - -exit 0 # clean exit - -#------------------------------------------------------------------------------ diff --git a/wmake/wcleanBuild b/wmake/wcleanBuild new file mode 120000 index 00000000000..a0376ef9764 --- /dev/null +++ b/wmake/wcleanBuild @@ -0,0 +1 @@ +scripts/wcleanBuild \ No newline at end of file diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform deleted file mode 100755 index 39c6da0a860..00000000000 --- a/wmake/wcleanPlatform +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/sh -#------------------------------------------------------------------------------ -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. -#------------------------------------------------------------------------------- -# 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/>. -# -# Script -# wcleanPlatform -# -# Usage -# wcleanPlatform <platform> [.. <platformN>] -# -# Description -# Deletes the specified 'platforms/' object files directories from the -# the project top-level 'platforms/' directory $WM_PROJECT_DIR. -# -# special platforms -# - 'all' removes all platforms, lnInclude directories and cleans tutorials. -# - 'compiler' corresponds to $WM_ARCH$WM_COMPILER. -# - 'current' corresponds to $WM_OPTIONS. -# -# You must be in the project or the third-party top-level directory -# to run this script. -# -#------------------------------------------------------------------------------ -Script=${0##*/} - -usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE - -Usage: $Script <platform> [.. <platformN>] - $Script -all | -compiler | -current [<platform> [.. <platformN>]] - -options: - -a, -all Same as 'all' - -comp, -compiler Same as 'compiler' - -c, -current Same as 'current' - -h, -help Print the usage - - -Deletes the specified platforms/ object file directories from the project -top-level platforms/ directory $WM_PROJECT_DIR. - -special platforms: - all Remove all platforms, lnInclude and clean tutorials - compiler $WM_ARCH$WM_COMPILER (ie, \$WM_ARCH\$WM_COMPILER) - current $WM_OPTIONS (ie, \$WM_OPTIONS) - -You must be in the project or the third-party top-level directory -to run this script. - -USAGE - exit 1 -} - -# Find -help anywhere -for i -do - case "$i" in (-h | -help) usage ;; esac -done - -#------------------------------------------------------------------------------ -# Run from OPENFOAM or THIRDPARTY top-level directory only -wmakeCheckPwd -q "$WM_PROJECT_DIR" 2>/dev/null || \ -wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \ -{ -cat<<ERROR -${0##*/}: Error incorrect top-level directory - - Not in Project: $WM_PROJECT_DIR - Nor in ThirdParty: $WM_THIRD_PARTY_DIR - -ERROR - exit 1 -} - -if [ "$#" -eq 0 ] -then - usage "No platform specified" -else - echo "$# platform(s) to clean" - echo -fi - -for name -do - case "$name" in - -comp | -compiler | compiler) - name="$WM_ARCH$WM_COMPILER" - ;; - -c | -current | current) - name="$WM_OPTIONS" - ;; - -a | -all | all) - echo "all platforms/ ..." - rm -rf platforms - wcleanLnIncludeAll . - [ -x tutorials/Allclean ] && tutorials/Allclean - echo - break # Can stop now - ;; - esac - - if [ -n "$name" -d "build/$name" ] - then - echo " '$name'" - rm -rf "platforms/$name"* - echo - else - echo " '$name' - not built" - echo - fi -done - -exit 0 # clean exit - -#------------------------------------------------------------------------------ diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform new file mode 120000 index 00000000000..a0376ef9764 --- /dev/null +++ b/wmake/wcleanPlatform @@ -0,0 +1 @@ +scripts/wcleanBuild \ No newline at end of file -- GitLab From 7e4f3a8237e251e2bd957f24219b3f1fe5dc43ff Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 30 Oct 2017 11:38:24 +0100 Subject: [PATCH 075/126] STYLE: consistent rounding for float/double underflow (issue #625) - use (value <= VSMALL) instead of (value < VSMALL) for consistency with what equal(value, 0) delivers. --- src/OpenFOAM/primitives/Scalar/Scalar.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.C b/src/OpenFOAM/primitives/Scalar/Scalar.C index d94c3c31c48..99e1b1c7c97 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.C +++ b/src/OpenFOAM/primitives/Scalar/Scalar.C @@ -115,7 +115,7 @@ bool readScalar(const char* buf, Scalar& val) // Round underflow to zero val = ( - (parsed > -ScalarVSMALL && parsed < ScalarVSMALL) + (parsed >= -ScalarVSMALL && parsed <= ScalarVSMALL) ? 0 : Scalar(parsed) ); -- GitLab From a79d2835f1fb2c9226f7dfa58e5cfcf0e29d00fa Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 30 Oct 2017 11:43:12 +0000 Subject: [PATCH 076/126] ENH: functionObjectList: format errors from FO reading. Fixes #575. --- src/OpenFOAM/db/error/error.C | 29 ++++++++++++------- src/OpenFOAM/db/error/error.H | 3 ++ .../functionObjectList/functionObjectList.C | 5 ++-- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/OpenFOAM/db/error/error.C b/src/OpenFOAM/db/error/error.C index b0c4b3d8771..d72835e175e 100644 --- a/src/OpenFOAM/db/error/error.C +++ b/src/OpenFOAM/db/error/error.C @@ -250,21 +250,30 @@ void Foam::error::abort() } -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -Foam::Ostream& Foam::operator<<(Ostream& os, const error& err) +void Foam::error::write(Ostream& os, const bool includeTitle) const { - os << nl - << err.title().c_str() << endl - << err.message().c_str(); + os << nl; + if (includeTitle) + { + os << title().c_str() << endl; + } + os << message().c_str(); - if (error::level >= 2 && err.sourceFileLineNumber()) + if (error::level >= 2 && sourceFileLineNumber()) { os << nl << nl - << " From function " << err.functionName().c_str() << endl - << " in file " << err.sourceFileName().c_str() - << " at line " << err.sourceFileLineNumber() << '.'; + << " From function " << functionName().c_str() << endl + << " in file " << sourceFileName().c_str() + << " at line " << sourceFileLineNumber() << '.'; } +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const error& err) +{ + err.write(os); return os; } diff --git a/src/OpenFOAM/db/error/error.H b/src/OpenFOAM/db/error/error.H index 961bd3cd4dc..bf59c5facbe 100644 --- a/src/OpenFOAM/db/error/error.H +++ b/src/OpenFOAM/db/error/error.H @@ -195,6 +195,9 @@ public: // Prints stack before exiting. void abort(); + //- Print error message + void write(Ostream& os, const bool includeTitle = true) const; + // Ostream operator diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 0acd4e17d1c..0082266d5b0 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -788,8 +788,9 @@ bool Foam::functionObjectList::read() } catch (Foam::error& err) { - WarningInFunction - << "Caught FatalError " << err << nl << endl; + // Bit of trickery to get the original message + err.write(Warning, false); + InfoInFunction << nl << endl; } // Restore previous exception throwing state -- GitLab From 6f6029d0a63c1ff7429c3ac0c222d8ff437341f2 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 30 Oct 2017 16:58:42 +0000 Subject: [PATCH 077/126] COMP: LList: make constructor explicit. Fixes #630. --- src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index eefabca3290..f16cf03d14d 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -110,13 +110,13 @@ public: {} //- Construct given initial T - LList(T a) + explicit LList(T a) : LListBase(new link(a)) {} //- Construct from Istream - LList(Istream&); + explicit LList(Istream&); //- Construct as copy LList(const LList<LListBase, T>&); -- GitLab From 930d6dcaf2fb1c8fd902283adbd7e2ebb8bbf43d Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 31 Oct 2017 10:54:17 +0100 Subject: [PATCH 078/126] ENH: dummy I/O for nullObject, additional null subclass for zero/one - the zero::null and one::null sub-classes add an additional null output adapter. The function of the nil class (special-purpose class only used for HashSet) is now taken by zero::null. --- applications/test/HashSet/Test-hashSet.C | 5 +- applications/test/sizeof/Test-sizeof.C | 8 ++ src/OpenFOAM/primitives/nil/nil.H | 97 ------------------- .../primitives/nullObject/nullObject.H | 66 +++++++++---- src/OpenFOAM/primitives/one/one.H | 60 ++++++++++-- .../strings/wordRes/wordReListMatcher.H | 4 +- src/OpenFOAM/primitives/zero/nil.H | 24 +++++ src/OpenFOAM/primitives/zero/zero.H | 57 ++++++++++- 8 files changed, 192 insertions(+), 129 deletions(-) delete mode 100644 src/OpenFOAM/primitives/nil/nil.H create mode 100644 src/OpenFOAM/primitives/zero/nil.H diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C index 781c6ceabdf..7ead0c42852 100644 --- a/applications/test/HashSet/Test-hashSet.C +++ b/applications/test/HashSet/Test-hashSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +26,7 @@ Description \*---------------------------------------------------------------------------*/ #include "hashedWordList.H" +#include "nil.H" #include "HashSet.H" #include "Map.H" #include "labelPairHashes.H" @@ -69,6 +70,8 @@ int main(int argc, char *argv[]) Info<< "tableA keys: "; tableA.writeKeys(Info) << endl; + Info<< "tableB content: " << tableB << endl; + auto keyIterPair = tableA.keys(); for (const auto& i : keyIterPair) { diff --git a/applications/test/sizeof/Test-sizeof.C b/applications/test/sizeof/Test-sizeof.C index a884d87fde9..93358f7af7b 100644 --- a/applications/test/sizeof/Test-sizeof.C +++ b/applications/test/sizeof/Test-sizeof.C @@ -61,6 +61,10 @@ int main(int argc, char *argv[]) nil x; cout<<"nil:" << sizeof(x) << nl; } + { + zero x; + cout<<"zero:" << sizeof(x) << nl; + } { bool x(0); cout<<"bool:" << sizeof(x) << nl; @@ -93,6 +97,10 @@ int main(int argc, char *argv[]) cout<<"double:" << sizeof(double) << nl; } + { + cout<<"string:" << sizeof(Foam::string) << nl; + } + Info << "---\nEnd\n" << endl; diff --git a/src/OpenFOAM/primitives/nil/nil.H b/src/OpenFOAM/primitives/nil/nil.H deleted file mode 100644 index 3e5ae948e9c..00000000000 --- a/src/OpenFOAM/primitives/nil/nil.H +++ /dev/null @@ -1,97 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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::nil - -Description - A zero-sized class without any storage. Used, for example, in HashSet. - -Note - A zero-sized class actually does still require at least 1 byte storage. - -\*---------------------------------------------------------------------------*/ - -#ifndef nil_H -#define nil_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declaration of classes -class Istream; -class Ostream; - -// Forward declaration of friend functions and operators - -class nil; - -Istream& operator>>(Istream&, nil&); -Ostream& operator<<(Ostream&, const nil&); - - -/*---------------------------------------------------------------------------*\ - Class nil Declaration -\*---------------------------------------------------------------------------*/ - -class nil -{ - -public: - - // Constructors - - //- Construct null - nil() - {} - - //- Construct from Istream - nil(Istream&) - {} - - - // IOstream Operators - - friend Istream& operator>>(Istream& is, nil&) - { - return is; - } - - friend Ostream& operator<<(Ostream& os, const nil&) - { - return os; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/nullObject/nullObject.H b/src/OpenFOAM/primitives/nullObject/nullObject.H index e0ab12029ef..d2316fa5d37 100644 --- a/src/OpenFOAM/primitives/nullObject/nullObject.H +++ b/src/OpenFOAM/primitives/nullObject/nullObject.H @@ -22,12 +22,13 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::nullObject + Foam::NullObject Description Singleton null-object class and instance. - It occupies enough space to reinterpret its content as a class with - a null pointer for its content. + Its contents occupy just enough space to also be reinterpreted + as another class with a null pointer or zero long for its first + member. SourceFiles nullObjectI.H @@ -43,8 +44,14 @@ SourceFiles namespace Foam { +// Forward declarations +class Istream; +class Ostream; + +class NullObject; + /*---------------------------------------------------------------------------*\ - Class nullObject Declaration + Class NullObject Declaration \*---------------------------------------------------------------------------*/ class NullObject @@ -55,12 +62,12 @@ class NullObject { void* ptr; unsigned long val; - } null; + } content; - //- Private constructor + //- Private constructor for singleton only NullObject() : - null{nullptr} + content{nullptr} {} //- Disallow default bitwise copy construct @@ -70,23 +77,44 @@ class NullObject void operator=(const NullObject&) = delete; public: - //- The unique null object - static const NullObject nullObject; - //- A nullptr pointer content - inline const void* pointer() const - { - return null.ptr; - } + // Static Data - //- A zero value content - inline unsigned long value() const - { - return null.val; - } + //- A unique null object + static const NullObject nullObject; + + + // Member Functions + + //- A nullptr pointer content + inline const void* pointer() const + { + return content.ptr; + } + + //- Zero valued integer content + inline unsigned long value() const + { + return content.val; + } }; +// IOstream Operators + +//- Read from Istream consumes no content. +inline Istream& operator>>(Istream& is, NullObject&) +{ + return is; +} + +//- Write to Ostream emits no content. +inline Ostream& operator<<(Ostream& os, const NullObject&) +{ + return os; +} + + //- Pointer to the unique nullObject extern const NullObject* nullObjectPtr; diff --git a/src/OpenFOAM/primitives/one/one.H b/src/OpenFOAM/primitives/one/one.H index a184af000df..350db36483d 100644 --- a/src/OpenFOAM/primitives/one/one.H +++ b/src/OpenFOAM/primitives/one/one.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,9 +25,8 @@ Class Foam::one Description - A class representing the concept of 1 (scalar(1.0)) used to avoid - unnecessary manipulations for objects which are known to be one at - compile-time. + A class representing the concept of 1 (or 1.0) used to avoid unnecessary + manipulations for objects that are known to be one at compile-time. SourceFiles oneI.H @@ -44,6 +43,11 @@ SourceFiles namespace Foam { +// Forward declaration of classes, friend functions and operators +class Istream; +class Ostream; +class one; + /*---------------------------------------------------------------------------*\ Class one Declaration \*---------------------------------------------------------------------------*/ @@ -51,15 +55,22 @@ namespace Foam class one { public: - typedef one value_type; + // Forward declaration + class null; + + // Constructors - //- Construct null + //- Null constructible one() {} + //- Construct null from Istream. Consumes no content. + explicit one(Istream&) + {} + // Member operators @@ -83,6 +94,43 @@ public: }; +/*---------------------------------------------------------------------------*\ + Class one::null Declaration +\*---------------------------------------------------------------------------*/ + +//- A one class with a null output adapter. +class one::null +: + public one +{ +public: + typedef null value_type; + + //- Null constructible + null() + {} + + //- Construct null from Istream without consuming any content. + explicit null(Istream&) + {} +}; + + +// IOstream Operators + +//- Read from Istream consumes no content. +inline Istream& operator>>(Istream& is, one&) +{ + return is; +} + +//- Write to Ostream emits no content. +inline Ostream& operator<<(Ostream& os, const one::null&) +{ + return os; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H b/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H index b7b63a5680e..d456dfbd363 100644 --- a/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H +++ b/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H @@ -39,13 +39,11 @@ Description namespace Foam { - typedef wordRes wordReListMatcher; +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - #endif // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/zero/nil.H b/src/OpenFOAM/primitives/zero/nil.H new file mode 100644 index 00000000000..b331b89636e --- /dev/null +++ b/src/OpenFOAM/primitives/zero/nil.H @@ -0,0 +1,24 @@ +/*---------------------------------------------------------------------------*\ +Compatibility include + +Typedef + Foam::nil + +Description + The older name for Foam::zero::null. + +\*---------------------------------------------------------------------------*/ + +#ifndef nil_H +#define nil_H + +#include "zero.H" + +namespace Foam +{ + typedef zero::null nil; +} + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/zero/zero.H b/src/OpenFOAM/primitives/zero/zero.H index b0156929b63..84cbf2c362c 100644 --- a/src/OpenFOAM/primitives/zero/zero.H +++ b/src/OpenFOAM/primitives/zero/zero.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,6 +43,12 @@ SourceFiles namespace Foam { +// Forward declarations +class Istream; +class Ostream; + +class zero; + /*---------------------------------------------------------------------------*\ Class zero Declaration \*---------------------------------------------------------------------------*/ @@ -50,15 +56,22 @@ namespace Foam class zero { public: - typedef zero value_type; + // Forward declaration + class null; + + // Constructors - //- Construct null + //- Null constructible zero() {} + //- Construct null from Istream. Consumes no content. + explicit zero(Istream&) + {} + // Member operators @@ -85,9 +98,47 @@ public: { return 0; } + +}; + + +/*---------------------------------------------------------------------------*\ + Class zero::null Declaration +\*---------------------------------------------------------------------------*/ + +//- A zero class with a null output adapter. +class zero::null +: + public zero +{ +public: + typedef null value_type; + + //- Null constructible + null() + {} + + //- Construct null from Istream without consuming any content. + explicit null(Istream&) + {} }; +// IOstream Operators + +//- Read from Istream consumes no content. +inline Istream& operator>>(Istream& is, zero&) +{ + return is; +} + +//- Write to Ostream emits no content. +inline Ostream& operator<<(Ostream& os, const zero::null&) +{ + return os; +} + + // Global zero static const zero Zero; -- GitLab From db552fb7515f4a6b3288e752a71d74482fd1ea38 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 30 Oct 2017 21:35:05 +0100 Subject: [PATCH 079/126] DEFEATURE: remove StaticHashTable - unused, unmaintained and slower than the regular HashTable --- .../test/HashTable3/Test-HashTable3.C | 2 - .../test/PackedList2/Test-PackedList2.C | 51 -- applications/test/StaticHashTable/Make/files | 3 - .../test/StaticHashTable/Make/options | 0 .../StaticHashTable/Test-staticHashTable.C | 170 ------ etc/controlDict | 1 - src/OpenFOAM/Make/files | 1 - .../StaticHashTable/StaticHashTable.C | 530 ------------------ .../StaticHashTable/StaticHashTable.H | 415 -------------- .../StaticHashTable/StaticHashTableCore.C | 86 --- .../StaticHashTable/StaticHashTableI.H | 399 ------------- .../StaticHashTable/StaticHashTableIO.C | 237 -------- 12 files changed, 1895 deletions(-) delete mode 100644 applications/test/StaticHashTable/Make/files delete mode 100644 applications/test/StaticHashTable/Make/options delete mode 100644 applications/test/StaticHashTable/Test-staticHashTable.C delete mode 100644 src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C delete mode 100644 src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H delete mode 100644 src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C delete mode 100644 src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H delete mode 100644 src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C diff --git a/applications/test/HashTable3/Test-HashTable3.C b/applications/test/HashTable3/Test-HashTable3.C index 39c882d6eba..99e0749d166 100644 --- a/applications/test/HashTable3/Test-HashTable3.C +++ b/applications/test/HashTable3/Test-HashTable3.C @@ -30,7 +30,6 @@ Description #include "HashTable.H" #include "HashPtrTable.H" #include "Map.H" -#include "StaticHashTable.H" #include "cpuTime.H" using namespace Foam; @@ -57,7 +56,6 @@ int main(int argc, char *argv[]) // ie, a // Map<label> map(2 * nSize); // HashTable<label, label, Hash<label>> map(2 * nSize); - // StaticHashTable<label, label, Hash<label>> map(2 * nSize); HashTable<label, label, Hash<label>> map(2 * nSize); Info<< "Constructed map of size: " << nSize; diff --git a/applications/test/PackedList2/Test-PackedList2.C b/applications/test/PackedList2/Test-PackedList2.C index ad1df378de3..51ddcdaec7b 100644 --- a/applications/test/PackedList2/Test-PackedList2.C +++ b/applications/test/PackedList2/Test-PackedList2.C @@ -31,14 +31,12 @@ Description #include "boolList.H" #include "PackedBoolList.H" #include "HashSet.H" -#include "StaticHashTable.H" #include "cpuTime.H" #include <vector> #include <unordered_set> using namespace Foam; -#undef TEST_STATIC_HASH #undef TEST_STD_BOOLLIST #undef TEST_STD_UNORDERED_SET @@ -84,20 +82,6 @@ int main(int argc, char *argv[]) Info<< "populated labelHashSet in " << timer.cpuTimeIncrement() << " s\n\n"; - - #ifdef TEST_STATIC_HASH - // fullStaticHash is really slow - // give it lots of slots to help - StaticHashTable<nil, label, Hash<label>> emptyStaticHash; - StaticHashTable<nil, label, Hash<label>> fullStaticHash(100000); - for (label i = 0; i < n; i++) - { - fullStaticHash.insert(i, nil()); - } - Info<< "populated StaticHashTable in " - << timer.cpuTimeIncrement() << " s\n\n"; - #endif - #ifdef TEST_STD_UNORDERED_SET std::unordered_set<label, Foam::Hash<label>> emptyStdHash; std::unordered_set<label, Foam::Hash<label>> fullStdHash; @@ -112,10 +96,6 @@ int main(int argc, char *argv[]) emptyHash.printInfo(Info); fullHash.printInfo(Info); - #ifdef TEST_STATIC_HASH - emptyStaticHash.printInfo(Info); - fullStaticHash.printInfo(Info); - #endif #ifdef TEST_STD_UNORDERED_SET printInfo(emptyStdHash); printInfo(fullStdHash); @@ -305,37 +285,6 @@ int main(int argc, char *argv[]) << " sum " << sum << nl; - #ifdef TEST_STATIC_HASH - // Read empty StaticHashTable - sum = 0; - for (label iter = 0; iter < nIters; ++iter) - { - forAll(unpacked, i) - { - sum += emptyStaticHash.found(i); - } - } - std::cout - << "Reading empty StaticHash:" << timer.cpuTimeIncrement() - << " s" << nl - << " sum " << sum << nl; - - // Read full StaticHashTable - sum = 0; - for (label iter = 0; iter < nIters; ++iter) - { - forAll(unpacked, i) - { - sum += fullStaticHash.found(i); - } - } - std::cout - << "Reading full StaticHash:" << timer.cpuTimeIncrement() - << " s" << nl - << " sum " << sum << nl; - #endif - - #ifdef TEST_STD_UNORDERED_SET // Read empty stl set sum = 0; diff --git a/applications/test/StaticHashTable/Make/files b/applications/test/StaticHashTable/Make/files deleted file mode 100644 index e8d76bddc0c..00000000000 --- a/applications/test/StaticHashTable/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -Test-staticHashTable.C - -EXE = $(FOAM_USER_APPBIN)/Test-staticHashTable diff --git a/applications/test/StaticHashTable/Make/options b/applications/test/StaticHashTable/Make/options deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/applications/test/StaticHashTable/Test-staticHashTable.C b/applications/test/StaticHashTable/Test-staticHashTable.C deleted file mode 100644 index c21e6597deb..00000000000 --- a/applications/test/StaticHashTable/Test-staticHashTable.C +++ /dev/null @@ -1,170 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 "StaticHashTable.H" -#include "IOstreams.H" -#include "StringStream.H" - -using namespace Foam; - -// use define so we can easily test other implementations -#define HASHTABLE_CLASS StaticHashTable - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main() -{ - HASHTABLE_CLASS<double> table1(13); - - table1.insert("aaa", 1.0); - table1.insert("aba", 2.0); - table1.insert("aca", 3.0); - table1.insert("ada", 4.0); - table1.insert("aeq", 5.0); - table1.insert("aaw", 6.0); - table1.insert("abs", 7.0); - table1.insert("acr", 8.0); - table1.insert("adx", 9.0); - table1.insert("aec", 10.0); - - table1.erase("aaw"); - table1.erase("abs"); - - Info<< "\ntable1 toc: " << table1.toc() << endl; - table1.printInfo(Info) - << "table1 [" << table1.size() << "] " << endl; - forAllIter(HASHTABLE_CLASS<double>, table1, iter) - { - Info<< iter.key() << " => " << iter() << nl; - } - - table1.set("acr", 108); - table1.set("adx", 109); - table1.set("aec", 100); - table1("aaw") -= 1000; - table1("aeq") += 1000; - - Info<< "\noverwrote some values table1: " << table1 << endl; - - Info<< "\ntest find:" << endl; - Info<< table1.find("aaa")() << nl - << table1.find("aba")() << nl - << table1.find("aca")() << nl - << table1.find("ada")() << nl - << table1.find("aeq")() << nl - << table1.find("acr")() << nl - << table1.find("adx")() << nl - << table1.find("aec")() << nl - << table1["aaa"] << nl; - - { - OStringStream os; - os << table1; - HASHTABLE_CLASS<double> readTable(IStringStream(os.str())(), 100); - - Info<< "Istream constructor:" << readTable << endl; - } - - - HASHTABLE_CLASS<double> table2(table1); - HASHTABLE_CLASS<double> table3(table1.xfer()); - - Info<< "\ncopy table1 -> table2" << nl - << "transfer table1 -> table3 via the xfer() method" << nl; - - Info<< "\ntable1" << table1 << nl - << "\ntable2" << table2 << nl - << "\ntable3" << table3 << nl; - - Info<< "\nerase table2 by iterator" << nl; - forAllIter(HASHTABLE_CLASS<double>, table2, iter) - { - Info<< "erasing " << iter.key() << " => " << iter() << " ... "; - table2.erase(iter); - Info<< "erased" << endl; - } - - Info<< "\ntable1" << table1 << nl - << "\ntable2" << table2 << nl - << "\ntable3" << table3 << nl; - - table3.resize(1); - Info<< "\nresize(1) table3" << nl; - table3.printInfo(Info) - << table3 << nl; - - table3.resize(10000); - Info<< "\nresize(10000) table3" << nl; - table3.printInfo(Info) - << table3 << nl; - - HASHTABLE_CLASS<double> table4; - - table4 = table3; - Info<< "\ncopy table3 -> table4 " << table4 << nl; - - Info<< "\nclear table4 ... "; - table4.clear(); - Info<< "[" << table4.size() << "] " << table4 << nl; - - table1 = table3; - Info<< "\ncopy table3 -> table1 (previously transferred)" << table1 << nl; - - Info<< "test table1 == table3 : " << (table1 == table3) << nl; - table1.erase(table1.begin()); - Info<< "removed an element - test table1 != table3 : " - << (table1 != table3) << nl; - - // insert a few things into table2 - table2.set("ada", 14.0); - table2.set("aeq", 15.0); - table2.set("aaw", 16.0); - table2.set("abs", 17.0); - table2.set("adx", 20.0); - - Info<< "\ntable1" << table1 << nl - << "\ntable2" << table2 << nl; - - label nErased = table1.erase(table2); - - Info<< "\nerase table2 keys from table1 (removed " - << nErased << " elements)" << nl - << "\ntable1" << table1 << nl - << "\ntable2" << table2 << nl; - - - Info<< "\ntable3" << table3 - << "\nclearStorage table3 ... "; - table3.clearStorage(); - Info<< table3 << nl; - - Info<< "\nDone\n"; - - return 0; -} - - -// ************************************************************************* // diff --git a/etc/controlDict b/etc/controlDict index 37ebba2b46e..7b205e29bf5 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -337,7 +337,6 @@ DebugSwitches SpalartAllmarasIDDES 0; SphereDrag 0; StandardWallInteraction 0; - StaticHashTable 0; StochasticDispersionRAS 0; SuperBee 0; SuperBeeV 0; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 80b6239039a..782d12b42fa 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -147,7 +147,6 @@ primitives/Barycentric/barycentric/barycentric.C primitives/Barycentric2D/barycentric2D/barycentric2D.C containers/HashTables/HashTable/HashTableCore.C -containers/HashTables/StaticHashTable/StaticHashTableCore.C containers/Lists/SortableList/ParSortableListName.C containers/Lists/PackedList/PackedListCore.C containers/Lists/PackedList/PackedBoolList.C diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C deleted file mode 100644 index c024ff335e2..00000000000 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C +++ /dev/null @@ -1,530 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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/>. - -\*---------------------------------------------------------------------------*/ - -#ifndef StaticHashTable_C -#define StaticHashTable_C - -#include "StaticHashTable.H" -#include "List.H" -#include "IOstreams.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -Foam::StaticHashTable<T, Key, Hash>::StaticHashTable(const label size) -: - StaticHashTableCore(), - keys_(StaticHashTableCore::canonicalSize(size)), - objects_(keys_.size()), - nElmts_(0), - endIter_(*this, keys_.size(), 0), - endConstIter_(*this, keys_.size(), 0) -{ - if (size < 1) - { - FatalErrorInFunction - << "Illegal size " << size << " for StaticHashTable." - << " Minimum size is 1" << abort(FatalError); - } -} - - -template<class T, class Key, class Hash> -Foam::StaticHashTable<T, Key, Hash>::StaticHashTable -( - const StaticHashTable<T, Key, Hash>& ht -) -: - StaticHashTableCore(), - keys_(ht.keys_), - objects_(ht.objects_), - nElmts_(ht.nElmts_), - endIter_(*this, keys_.size(), 0), - endConstIter_(*this, keys_.size(), 0) -{} - - -template<class T, class Key, class Hash> -Foam::StaticHashTable<T, Key, Hash>::StaticHashTable -( - const Xfer<StaticHashTable<T, Key, Hash>>& ht -) -: - StaticHashTableCore(), - keys_(0), - objects_(0), - nElmts_(0), - endIter_(*this, 0, 0), - endConstIter_(*this, 0, 0) -{ - transfer(ht()); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -Foam::StaticHashTable<T, Key, Hash>::~StaticHashTable() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -bool Foam::StaticHashTable<T, Key, Hash>::found(const Key& key) const -{ - if (nElmts_) - { - const label hashIdx = hashKeyIndex(key); - const List<Key>& localKeys = keys_[hashIdx]; - - forAll(localKeys, elemIdx) - { - if (key == localKeys[elemIdx]) - { - return true; - } - } - } - - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "Entry " << key << " not found in hash table\n"; - } - #endif - - return false; -} - - -template<class T, class Key, class Hash> -typename Foam::StaticHashTable<T, Key, Hash>::iterator -Foam::StaticHashTable<T, Key, Hash>::find -( - const Key& key -) -{ - if (nElmts_) - { - const label hashIdx = hashKeyIndex(key); - const List<Key>& localKeys = keys_[hashIdx]; - - forAll(localKeys, elemIdx) - { - if (key == localKeys[elemIdx]) - { - return iterator(*this, hashIdx, elemIdx); - } - } - } - - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "Entry " << key << " not found in hash table\n"; - } - #endif - - return end(); -} - - -template<class T, class Key, class Hash> -typename Foam::StaticHashTable<T, Key, Hash>::const_iterator -Foam::StaticHashTable<T, Key, Hash>::find -( - const Key& key -) const -{ - return this->cfind(key); -} - - -template<class T, class Key, class Hash> -typename Foam::StaticHashTable<T, Key, Hash>::const_iterator -Foam::StaticHashTable<T, Key, Hash>::cfind -( - const Key& key -) const -{ - if (nElmts_) - { - const label hashIdx = hashKeyIndex(key); - const List<Key>& localKeys = keys_[hashIdx]; - - forAll(localKeys, elemIdx) - { - if (key == localKeys[elemIdx]) - { - return const_iterator(*this, hashIdx, elemIdx); - } - } - } - - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "Entry " << key << " not found in hash table\n"; - } - #endif - - return cend(); -} - - -template<class T, class Key, class Hash> -Foam::List<Key> Foam::StaticHashTable<T, Key, Hash>::toc() const -{ - List<Key> keys(nElmts_); - label keyI = 0; - - for (const_iterator iter = cbegin(); iter != cend(); ++iter) - { - keys[keyI++] = iter.key(); - } - - return keys; -} - - -template<class T, class Key, class Hash> -bool Foam::StaticHashTable<T, Key, Hash>::set -( - const Key& key, - const T& obj, - const bool protect -) -{ - const label hashIdx = hashKeyIndex(key); - List<Key>& localKeys = keys_[hashIdx]; - - label existing = localKeys.size(); - forAll(localKeys, elemIdx) - { - if (key == localKeys[elemIdx]) - { - existing = elemIdx; - break; - } - } - - if (existing == localKeys.size()) - { - // Not found, append - List<T>& localObjects = objects_[hashIdx]; - - localKeys.setSize(existing+1); - localObjects.setSize(existing+1); - - localKeys[existing] = key; - localObjects[existing] = obj; - - nElmts_++; - } - else if (protect) - { - // Found - but protected from overwriting - // this corresponds to the STL 'insert' convention - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction - << "Cannot insert " << key << " already in hash table\n"; - } - #endif - return false; - } - else - { - // Found - overwrite existing entry - // this corresponds to the Perl convention - objects_[hashIdx][existing] = obj; - } - - return true; -} - - -template<class T, class Key, class Hash> -bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit) -{ - if (cit != end()) - { - List<Key>& localKeys = keys_[cit.hashIndex_]; - List<T>& localObjects = objects_[cit.hashIndex_]; - - // Copy down - for (label i = cit.elemIndex_+1; i < localKeys.size(); i++) - { - localKeys[i-1] = localKeys[i]; - localObjects[i-1] = localObjects[i]; - } - localKeys.setSize(localKeys.size()-1); - localObjects.setSize(localObjects.size()-1); - - // Adjust iterator after erase - iterator& it = const_cast<iterator&>(cit); - - it.elemIndex_--; - if (it.elemIndex_ < 0) - { - // No previous element in the local list - // Mark with as special value (see notes in HashTable) - it.hashIndex_ = -it.hashIndex_ - 1; - it.elemIndex_ = 0; - } - - nElmts_--; - - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "hashedEntry removed.\n"; - } - #endif - - return true; - } - else - { - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction - << "Cannot remove hashedEntry from hash table\n"; - } - #endif - - return false; - } -} - - -template<class T, class Key, class Hash> -bool Foam::StaticHashTable<T, Key, Hash>::erase(const Key& key) -{ - iterator it = find(key); - - if (it != end()) - { - return erase(it); - } - else - { - return false; - } -} - - -template<class T, class Key, class Hash> -Foam::label Foam::StaticHashTable<T, Key, Hash>::erase -( - const StaticHashTable<T, Key, Hash>& rhs -) -{ - label count = 0; - - // Remove rhs elements from this table - // NOTE: could optimize depending on which hash is smaller - for (iterator iter = this->begin(); iter != this->end(); ++iter) - { - if (rhs.found(iter.key()) && erase(iter)) - { - count++; - } - } - - return count; -} - - -template<class T, class Key, class Hash> -void Foam::StaticHashTable<T, Key, Hash>::resize(const label sz) -{ - label newSize = StaticHashTableCore::canonicalSize(sz); - - if (newSize == keys_.size()) - { - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "New table size == old table size\n"; - } - #endif - - return; - } - - if (newSize < 1) - { - FatalErrorInFunction - << "Illegal size " << newSize << " for StaticHashTable." - << " Minimum size is 1" << abort(FatalError); - } - - - StaticHashTable<T, Key, Hash> newTable(newSize); - - for (const_iterator iter = cbegin(); iter != cend(); ++iter) - { - newTable.insert(iter.key(), *iter); - } - - transfer(newTable); - - // Adapt end() iterators - endIter_.hashIndex_ = keys_.size(); - endConstIter_.hashIndex_ = keys_.size(); -} - - -template<class T, class Key, class Hash> -void Foam::StaticHashTable<T, Key, Hash>::clear() -{ - forAll(keys_, hashIdx) - { - keys_[hashIdx].clear(); - objects_[hashIdx].clear(); - } - - nElmts_ = 0; -} - - -template<class T, class Key, class Hash> -void Foam::StaticHashTable<T, Key, Hash>::clearStorage() -{ - clear(); - resize(1); -} - - -template<class T, class Key, class Hash> -void Foam::StaticHashTable<T, Key, Hash>::transfer -( - StaticHashTable<T, Key, Hash>& ht -) -{ - // Remove existing elements - clear(); - - // Copy data from ht - keys_.transfer(ht.keys_); - objects_.transfer(ht.objects_); - - nElmts_ = ht.nElmts_; - ht.nElmts_ = 0; - - // Adapt end() iterators - endIter_.hashIndex_ = keys_.size(); - endConstIter_.hashIndex_ = keys_.size(); - - ht.endIter_.hashIndex_ = 0; - ht.endConstIter_.hashIndex_ = 0; -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -void Foam::StaticHashTable<T, Key, Hash>::operator= -( - const StaticHashTable<T, Key, Hash>& rhs -) -{ - // Check for assignment to self - if (this == &rhs) - { - FatalErrorInFunction - << "attempted assignment to self" - << abort(FatalError); - } - - - // keys could be empty from a previous transfer() - if (keys_.empty()) - { - keys_.setSize(rhs.keys_.size()); - objects_.setSize(keys_.size()); - - // Adapt end() iterators - endIter_.hashIndex_ = keys_.size(); - endConstIter_.hashIndex_ = keys_.size(); - } - else - { - clear(); - // keys_.size() does not change so neither does end() iterator. - } - - - for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) - { - insert(iter.key(), *iter); - } -} - -template<class T, class Key, class Hash> -bool Foam::StaticHashTable<T, Key, Hash>::operator== -( - const StaticHashTable<T, Key, Hash>& rhs -) const -{ - // Sizes (number of keys) must match - - for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) - { - const_iterator fnd = find(iter.key()); - - if (fnd == cend() || fnd() != iter()) - { - return false; - } - } - - return true; -} - - -template<class T, class Key, class Hash> -bool Foam::StaticHashTable<T, Key, Hash>::operator!= -( - const StaticHashTable<T, Key, Hash>& rhs -) const -{ - return !(operator==(rhs)); -} - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -#include "StaticHashTableIO.C" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H deleted file mode 100644 index 850eb1fc43d..00000000000 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ /dev/null @@ -1,415 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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::StaticHashTable - -Description - STL conforming hash table. - -Note - Uses straight lists as underlying type. - Is slower to insert than the standard HashTable, but should be more - memory efficient and faster to access. - -SourceFiles - StaticHashTableI.H - StaticHashTable.C - StaticHashTableIO.C - -\*---------------------------------------------------------------------------*/ - -#ifndef StaticHashTable_H -#define StaticHashTable_H - -#include "label.H" -#include "uLabel.H" -#include "word.H" -#include "Xfer.H" -#include "className.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declaration of friend functions and operators - -template<class T> class List; -template<class T, class Key, class Hash> class StaticHashTable; - -template<class T, class Key, class Hash> Istream& operator>> -( - Istream&, - StaticHashTable<T, Key, Hash>& -); - -template<class T, class Key, class Hash> Ostream& operator<< -( - Ostream&, - const StaticHashTable<T, Key, Hash>& -); - - -/*---------------------------------------------------------------------------*\ - Class StaticHashTableCore Declaration -\*---------------------------------------------------------------------------*/ - -//- Template-invariant bits for StaticHashTable -struct StaticHashTableCore -{ - //- Return a canonical (power-of-two) of the requested size. - static label canonicalSize(const label requested_size); - - //- Construct null - StaticHashTableCore() - {} - - //- Define template name and debug - ClassName("StaticHashTable"); - - //- A zero-sized end iterator - struct iteratorEnd - { - //- Construct null - iteratorEnd() - {} - }; -}; - - - -/*---------------------------------------------------------------------------*\ - Class StaticHashTable Declaration -\*---------------------------------------------------------------------------*/ - -template<class T, class Key=word, class Hash=string::hash> -class StaticHashTable -: - public StaticHashTableCore -{ - // Private data type for table entries - - //- The lookup keys, ordered per hash value - List<List<Key>> keys_; - - //- For each key the corresponding object. - List<List<T>> objects_; - - //- The current number of elements in table - label nElmts_; - - //- Return the hash index of the Key within the current table size. - // No checks for zero-sized tables. - inline label hashKeyIndex(const Key& key) const; - - //- Assign a new hashed entry to a possibly already existing key - bool set(const Key& key, const T& obj, bool protect); - - -public: - - - // Forward declaration of STL iterators - - template<class TRef, class TableRef> - class Iterator; - - typedef Iterator - < - T&, - StaticHashTable<T, Key, Hash>& - > iterator; - - typedef Iterator - < - const T&, - const StaticHashTable<T, Key, Hash>& - > const_iterator; - - - // Declare friendship with the iterators - - friend class Iterator - < - T&, - StaticHashTable<T, Key, Hash>& - >; - - friend class Iterator - < - const T&, - const StaticHashTable<T, Key, Hash>& - >; - - - // Constructors - - //- Construct given initial table size - StaticHashTable(const label size = 128); - - //- Construct from Istream - StaticHashTable(Istream&, const label size = 128); - - //- Construct as copy - StaticHashTable(const StaticHashTable<T, Key, Hash>&); - - //- Construct by transferring the parameter contents - StaticHashTable(const Xfer<StaticHashTable<T, Key, Hash>>&); - - - //- Destructor - ~StaticHashTable(); - - - // Member Functions - - // Access - - //- Return number of elements in table. - inline label size() const; - - //- Return true if the hash table is empty - inline bool empty() const; - - //- Return true if hashed entry is found in table - bool found(const Key& key) const; - - //- Find and return an iterator set at the hashed entry - // If not found iterator = end() - iterator find(const Key& key); - - //- Find and return an const_iterator set at the hashed entry - // If not found iterator = end() - const_iterator find(const Key& key) const; - - //- Find and return an const_iterator set at the hashed entry - // If not found iterator = end() - const_iterator cfind(const Key& key) const; - - //- Return the table of contents - List<Key> toc() const; - - //- Print information - Ostream& printInfo(Ostream&) const; - - - // Edit - - //- Insert a new hashed entry - bool insert(const Key& key, const T& newElmt); - - //- Assign a new hashed entry, overwriting existing entries - inline bool set(const Key&, const T& newElmt); - - //- Erase an hashed entry specified by given iterator - bool erase(const iterator& it); - - //- Erase an hashed entry specified by given key if in table - bool erase(const Key& key); - - //- Resize the hash table for efficiency - void resize(const label newSize); - - //- Remove entries in the given hash table from this hash table - // Return the number of elements removed - label erase(const StaticHashTable<T, Key, Hash>&); - - //- Clear all entries from table - void clear(); - - //- Clear the table entries and the table itself. - // Equivalent to clear() followed by resize(1) - void clearStorage(); - - //- Transfer the contents of the argument table into this table - // and annul the argument table. - void transfer(StaticHashTable<T, Key, Hash>&); - - //- Transfer contents to the Xfer container - inline Xfer<StaticHashTable<T, Key, Hash>> xfer(); - - - // Member Operators - - //- Find and return an hashed entry - inline T& operator[](const Key&); - - //- Find and return an hashed entry - inline const T& operator[](const Key&) const; - - //- Find and return an hashed entry, create it null if not present. - inline T& operator()(const Key&); - - //- Assignment - void operator=(const StaticHashTable<T, Key, Hash>&); - - //- Equality. Two hash tables are equal if all contents of first are - // also in second and vice versa. - bool operator==(const StaticHashTable<T, Key, Hash>&) const; - - //- The opposite of the equality operation. - bool operator!=(const StaticHashTable<T, Key, Hash>&) const; - - - // STL type definitions - - //- Type of values the StaticHashTable contains. - typedef T value_type; - - //- Type that can be used for storing into StaticHashTable::value_type - // objects. This type is usually List::value_type&. - typedef T& reference; - - //- Type that can be used for storing into constant - // StaticHashTable::value_type objects. This type is usually const - // StaticHashTable::value_type&. - typedef const T& const_reference; - - //- The type that can represent the size of a StaticHashTable. - typedef label size_type; - - - // STL iterator - - //- An STL iterator - template<class TRef, class TableRef> - class Iterator - { - friend class StaticHashTable; - - template<class TRef2, class TableRef2> - friend class Iterator; - - // Private data - - //- Reference to the StaticHashTable this is an iterator for - TableRef hashTable_; - - //- Current hash index - label hashIndex_; - - //- Index of current element at hashIndex - label elemIndex_; - - - public: - - // Constructors - - //- Construct from hash table, hash index and element index - inline Iterator - ( - TableRef, - label hashIndex_, - label elemIndex_ - ); - - //- Construct from the non-const iterator - inline Iterator(const iterator&); - - - // Member operators - - inline void operator=(const iterator&); - - inline bool operator==(const iterator&) const; - inline bool operator==(const const_iterator&) const; - - inline bool operator!=(const iterator&) const; - inline bool operator!=(const const_iterator&) const; - - inline TRef operator*(); - inline TRef operator()(); - - inline Iterator& operator++(); - inline Iterator operator++(int); - - inline const Key& key() const; - }; - - - //- Iterator set to the beginning of the StaticHashTable - inline iterator begin(); - - //- Iterator set to beyond the end of the StaticHashTable - inline const iterator& end(); - - //- const_iterator set to the beginning of the StaticHashTable - inline const_iterator cbegin() const; - - //- const_iterator set to beyond the end of the StaticHashTable - inline const const_iterator& cend() const; - - //- const_iterator set to the beginning of the StaticHashTable - inline const_iterator begin() const; - - //- const_iterator set to beyond the end of the StaticHashTable - inline const const_iterator& end() const; - - // IOstream Operator - - friend Istream& operator>> <T, Key, Hash> - ( - Istream&, - StaticHashTable<T, Key, Hash>& - ); - - friend Ostream& operator<< <T, Key, Hash> - ( - Ostream&, - const StaticHashTable<T, Key, Hash>& - ); - - -private: - - //- Iterator returned by end() - iterator endIter_; - - //- const_iterator returned by end() - const_iterator endConstIter_; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "StaticHashTableI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifndef NoStaticHashTableC -#ifdef NoRepository - #include "StaticHashTable.C" -#endif -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C deleted file mode 100644 index b53b5554bfa..00000000000 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C +++ /dev/null @@ -1,86 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 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 "StaticHashTable.H" -#include "uLabel.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -defineTypeNameAndDebug(StaticHashTableCore, 0); -} - - -// Approximately labelMax/4 -static const Foam::label maxTableSize(1L << (sizeof(Foam::label)*8-3)); - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -Foam::label Foam::StaticHashTableCore::canonicalSize(const label requested_size) -{ - if (requested_size < 1) - { - return 0; - } - else if (requested_size >= maxTableSize) - { - return maxTableSize; - } - - // Enforce power of two - makes for a very fast modulus. - // Use unsigned for these calculations. - // - // - The lower limit (8) is somewhat arbitrary, but if the hash table - // is too small, there will be many direct table collisions. - // - The upper limit (approx. labelMax/4) must be a power of two, - // need not be extremely large for hashing. - - uLabel powerOfTwo = 8u; // lower-limit - - const uLabel size = requested_size; - if (size <= powerOfTwo) - { - return powerOfTwo; - } - else if (size & (size-1)) // <- Modulus of i^2 - { - // Determine power-of-two. Brute-force is fast enough. - while (powerOfTwo < size) - { - powerOfTwo <<= 1; - } - - return powerOfTwo; - } - else - { - return size; - } -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H deleted file mode 100644 index e93e7e4861f..00000000000 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ /dev/null @@ -1,399 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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 "error.H" -#include "IOstreams.H" - -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline Foam::label -Foam::StaticHashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const -{ - // size is power of two - this is the modulus - return Hash()(key) & (keys_.size() - 1); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline Foam::label Foam::StaticHashTable<T, Key, Hash>::size() const -{ - return nElmts_; -} - - -template<class T, class Key, class Hash> -inline bool Foam::StaticHashTable<T, Key, Hash>::empty() const -{ - return !nElmts_; -} - - -template<class T, class Key, class Hash> -inline bool Foam::StaticHashTable<T, Key, Hash>::insert -( - const Key& key, - const T& obj -) -{ - return set(key, obj, true); -} - - -template<class T, class Key, class Hash> -inline bool Foam::StaticHashTable<T, Key, Hash>::set -( - const Key& key, - const T& obj -) -{ - return set(key, obj, false); -} - - -template<class T, class Key, class Hash> -inline Foam::Xfer<Foam::StaticHashTable<T, Key, Hash>> -Foam::StaticHashTable<T, Key, Hash>::xfer() -{ - return xferMove(*this); -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline T& Foam::StaticHashTable<T, Key, Hash>::operator[](const Key& key) -{ - iterator iter = find(key); - - if (iter == end()) - { - FatalErrorInFunction - << toc() - << exit(FatalError); - } - - return *iter; -} - - -template<class T, class Key, class Hash> -inline const T& Foam::StaticHashTable<T, Key, Hash>::operator[] -( - const Key& key -) const -{ - const_iterator iter = find(key); - - if (iter == cend()) - { - FatalErrorInFunction - << toc() - << exit(FatalError); - } - - return *iter; -} - - -template<class T, class Key, class Hash> -inline T& Foam::StaticHashTable<T, Key, Hash>::operator()(const Key& key) -{ - iterator iter = find(key); - - if (iter == end()) - { - insert(key, T()); - return *find(key); - } - else - { - return *iter; - } -} - - -// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::Iterator -( - TableRef hashTbl, - label hashIndex, - label elemIndex -) -: - hashTable_(hashTbl), - hashIndex_(hashIndex), - elemIndex_(elemIndex) -{} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::Iterator -( - const iterator& iter -) -: - hashTable_(iter.hashTable_), - hashIndex_(iter.hashIndex_), - elemIndex_(iter.elemIndex_) -{} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline void -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator= -( - const iterator& iter -) -{ - this->hashIndex_ = iter.hashIndex_; - this->elemIndex_ = iter.elemIndex_; -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline bool -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator== -( - const iterator& iter -) const -{ - return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_; -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline bool -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator== -( - const const_iterator& iter -) const -{ - return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_; -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline bool -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator!= -( - const iterator& iter -) const -{ - return !operator==(iter); -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline bool -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator!= -( - const const_iterator& iter -) const -{ - return !operator==(iter); -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline TRef -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator*() -{ - return hashTable_.objects_[hashIndex_][elemIndex_]; -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline TRef -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator()() -{ - return operator*(); -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline -typename Foam::StaticHashTable<T, Key, Hash>::template Iterator -< - TRef, - TableRef ->& -Foam::StaticHashTable<T, Key, Hash>::Iterator -< - TRef, - TableRef ->::operator++() -{ - // A negative index is a special value from erase - // (see notes in HashTable) - if (hashIndex_ < 0) - { - hashIndex_ = -(hashIndex_+1) - 1; - } - else - { - // Try the next element on the local list - elemIndex_++; - - if (elemIndex_ < hashTable_.objects_[hashIndex_].size()) - { - return *this; - } - } - - // Step to the next table entry - elemIndex_ = 0; - - while - ( - ++hashIndex_ < hashTable_.objects_.size() - && !hashTable_.objects_[hashIndex_].size() - ) - {} - - - if (hashIndex_ >= hashTable_.objects_.size()) - { - // make end iterator - hashIndex_ = hashTable_.keys_.size(); - } - - return *this; -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline -typename Foam::StaticHashTable<T, Key, Hash>::template Iterator -< - TRef, - TableRef -> -Foam::StaticHashTable<T, Key, Hash>::Iterator -< - TRef, - TableRef ->::operator++ -( - int -) -{ - iterator tmp = *this; - ++*this; - return tmp; -} - - -template<class T, class Key, class Hash> -template<class TRef, class TableRef> -inline const Key& -Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::key() const -{ - return hashTable_.keys_[hashIndex_][elemIndex_]; -} - - -template<class T, class Key, class Hash> -inline typename Foam::StaticHashTable<T, Key, Hash>::iterator -Foam::StaticHashTable<T, Key, Hash>::begin() -{ - // Find first non-empty entry - forAll(keys_, hashIdx) - { - if (keys_[hashIdx].size()) - { - return iterator(*this, hashIdx, 0); - } - } - - return StaticHashTable<T, Key, Hash>::endIter_; -} - - -template<class T, class Key, class Hash> -inline const typename Foam::StaticHashTable<T, Key, Hash>::iterator& -Foam::StaticHashTable<T, Key, Hash>::end() -{ - return StaticHashTable<T, Key, Hash>::endIter_; -} - - -template<class T, class Key, class Hash> -inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator -Foam::StaticHashTable<T, Key, Hash>::cbegin() const -{ - // Find first non-empty entry - forAll(keys_, hashIdx) - { - if (keys_[hashIdx].size()) - { - return const_iterator(*this, hashIdx, 0); - } - } - - return StaticHashTable<T, Key, Hash>::endConstIter_; -} - - -template<class T, class Key, class Hash> -inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator& -Foam::StaticHashTable<T, Key, Hash>::cend() const -{ - return StaticHashTable<T, Key, Hash>::endConstIter_; -} - - -template<class T, class Key, class Hash> -inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator -Foam::StaticHashTable<T, Key, Hash>::begin() const -{ - return this->cbegin(); -} - - -template<class T, class Key, class Hash> -inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator& -Foam::StaticHashTable<T, Key, Hash>::end() const -{ - return StaticHashTable<T, Key, Hash>::endConstIter_; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C deleted file mode 100644 index c7e06724530..00000000000 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C +++ /dev/null @@ -1,237 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 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 "StaticHashTable.H" -#include "Istream.H" -#include "Ostream.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -Foam::StaticHashTable<T, Key, Hash>::StaticHashTable -( - Istream& is, - const label size -) -: - StaticHashTableCore(), - keys_(StaticHashTableCore::canonicalSize(size)), - objects_(StaticHashTableCore::canonicalSize(size)), - nElmts_(0), - endIter_(*this, keys_.size(), 0), - endConstIter_(*this, keys_.size(), 0) -{ - if (size < 1) - { - FatalErrorInFunction - << "Illegal size " << size << " for StaticHashTable." - << " Minimum size is 1" << abort(FatalError); - } - - operator>>(is, *this); -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -Foam::Ostream& -Foam::StaticHashTable<T, Key, Hash>::printInfo(Ostream& os) const -{ - label used = 0; - label maxChain = 0; - unsigned avgChain = 0; - - // Find first non-empty entry - forAll(keys_, hashIdx) - { - const label count = keys_[hashIdx].size(); - if (count) - { - ++used; - avgChain += count; - - if (maxChain < count) - { - maxChain = count; - } - } - } - - os << "StaticHashTable<T,Key,Hash>" - << " elements:" << size() << " slots:" << used << "/" << keys_.size() - << " chaining(avg/max):" << (used ? float(avgChain/used) : 0) - << "/" << maxChain << endl; - - return os; -} - - -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L) -{ - is.fatalCheck(FUNCTION_NAME); - - // Anull list - L.clear(); - - is.fatalCheck(FUNCTION_NAME); - - token firstToken(is); - - is.fatalCheck - ( - "operator>>(Istream&, StaticHashTable<T, Key, Hash>&) : " - "reading first token" - ); - - if (firstToken.isLabel()) - { - label s = firstToken.labelToken(); - - // Read beginning of contents - char delimiter = is.readBeginList("StaticHashTable<T, Key, Hash>"); - - if (s) - { - if (2*s > L.keys_.size()) - { - L.resize(2*s); - } - - if (delimiter == token::BEGIN_LIST) - { - for (label i=0; i<s; i++) - { - Key key; - is >> key; - L.insert(key, pTraits<T>(is)); - - is.fatalCheck - ( - "operator>>(Istream&, StaticHashTable<T, Key, Hash>&)" - " : reading entry" - ); - } - } - else - { - FatalIOErrorInFunction - ( - is - ) << "incorrect first token, '(', found " << firstToken.info() - << exit(FatalIOError); - } - } - - // Read end of contents - is.readEndList("StaticHashTable"); - } - else if (firstToken.isPunctuation()) - { - if (firstToken.pToken() != token::BEGIN_LIST) - { - FatalIOErrorInFunction - ( - is - ) << "incorrect first token, '(', found " << firstToken.info() - << exit(FatalIOError); - } - - token lastToken(is); - while - ( - !( - lastToken.isPunctuation() - && lastToken.pToken() == token::END_LIST - ) - ) - { - is.putBack(lastToken); - - Key key; - is >> key; - - T element; - is >> element; - - L.insert(key, element); - - is.fatalCheck - ( - "operator>>(Istream&, StaticHashTable<T, Key, Hash>&) : " - "reading entry" - ); - - is >> lastToken; - } - } - else - { - FatalIOErrorInFunction - ( - is - ) << "incorrect first token, expected <int> or '(', found " - << firstToken.info() - << exit(FatalIOError); - } - - is.fatalCheck(FUNCTION_NAME); - - return is; -} - - -template<class T, class Key, class Hash> -Foam::Ostream& Foam::operator<< -( - Ostream& os, - const StaticHashTable<T, Key, Hash>& L) -{ - // Write size and start delimiter - os << nl << L.size() << nl << token::BEGIN_LIST << nl; - - // Write contents - for - ( - typename StaticHashTable<T, Key, Hash>::const_iterator iter = L.begin(); - iter != L.end(); - ++iter - ) - { - os << iter.key() << token::SPACE << iter() << nl; - } - - // Write end delimiter - os << token::END_LIST; - - os.check(FUNCTION_NAME); - return os; -} - - -// ************************************************************************* // -- GitLab From 053a648ee6432c589d661999084c0a7290df5077 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 31 Oct 2017 08:46:47 +0100 Subject: [PATCH 080/126] ENH: improvements to HashTable internals - make single-parameter construct (label) explicit - consolidate iterators - slightly reduced overhead for some HashSet types - improved resizing behaviour - compact output for empty Ptr hashes --- applications/test/HashTable/Make/files | 3 - applications/test/HashTable1/Make/files | 3 + .../{HashTable => HashTable1}/Make/options | 0 .../Test-HashTable1.C} | 0 applications/test/HashTable4/Make/files | 3 + applications/test/HashTable4/Make/options | 2 + .../test/HashTable4/Test-HashTable4.C | 312 +++++++++ .../HashTables/HashPtrTable/HashPtrTable.C | 8 + .../HashTables/HashPtrTable/HashPtrTable.H | 9 +- .../HashTables/HashPtrTable/HashPtrTableIO.C | 47 +- .../containers/HashTables/HashSet/HashSet.C | 14 +- .../containers/HashTables/HashSet/HashSet.H | 58 +- .../HashTables/HashTable/HashTable.C | 410 +++++------- .../HashTables/HashTable/HashTable.H | 591 ++++++++++++------ .../HashTables/HashTable/HashTableCore.C | 13 +- .../HashTables/HashTable/HashTableCore.H | 16 +- .../HashTables/HashTable/HashTableCoreI.H | 10 - .../HashTables/HashTable/HashTableI.H | 503 ++------------- .../HashTables/HashTable/HashTableIO.C | 61 +- .../HashTables/HashTable/HashTableIter.C | 123 ++++ .../HashTables/HashTable/HashTableIterI.H | 263 ++++++++ src/OpenFOAM/containers/HashTables/Map/Map.H | 19 +- .../containers/HashTables/PtrMap/PtrMap.H | 8 +- 23 files changed, 1470 insertions(+), 1006 deletions(-) delete mode 100644 applications/test/HashTable/Make/files create mode 100644 applications/test/HashTable1/Make/files rename applications/test/{HashTable => HashTable1}/Make/options (100%) rename applications/test/{HashTable/Test-hashTable.C => HashTable1/Test-HashTable1.C} (100%) create mode 100644 applications/test/HashTable4/Make/files create mode 100644 applications/test/HashTable4/Make/options create mode 100644 applications/test/HashTable4/Test-HashTable4.C create mode 100644 src/OpenFOAM/containers/HashTables/HashTable/HashTableIter.C create mode 100644 src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H diff --git a/applications/test/HashTable/Make/files b/applications/test/HashTable/Make/files deleted file mode 100644 index 53d1e076991..00000000000 --- a/applications/test/HashTable/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -Test-hashTable.C - -EXE = $(FOAM_USER_APPBIN)/Test-hashTable diff --git a/applications/test/HashTable1/Make/files b/applications/test/HashTable1/Make/files new file mode 100644 index 00000000000..05c776d65ce --- /dev/null +++ b/applications/test/HashTable1/Make/files @@ -0,0 +1,3 @@ +Test-HashTable1.C + +EXE = $(FOAM_USER_APPBIN)/Test-HashTable1 diff --git a/applications/test/HashTable/Make/options b/applications/test/HashTable1/Make/options similarity index 100% rename from applications/test/HashTable/Make/options rename to applications/test/HashTable1/Make/options diff --git a/applications/test/HashTable/Test-hashTable.C b/applications/test/HashTable1/Test-HashTable1.C similarity index 100% rename from applications/test/HashTable/Test-hashTable.C rename to applications/test/HashTable1/Test-HashTable1.C diff --git a/applications/test/HashTable4/Make/files b/applications/test/HashTable4/Make/files new file mode 100644 index 00000000000..fcc01c49bda --- /dev/null +++ b/applications/test/HashTable4/Make/files @@ -0,0 +1,3 @@ +Test-HashTable4.C + +EXE = $(FOAM_USER_APPBIN)/Test-HashTable4 diff --git a/applications/test/HashTable4/Make/options b/applications/test/HashTable4/Make/options new file mode 100644 index 00000000000..6a9e9810b3d --- /dev/null +++ b/applications/test/HashTable4/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ +/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/HashTable4/Test-HashTable4.C b/applications/test/HashTable4/Test-HashTable4.C new file mode 100644 index 00000000000..b9333f320db --- /dev/null +++ b/applications/test/HashTable4/Test-HashTable4.C @@ -0,0 +1,312 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + Test HashTable resizing + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "HashSet.H" +#include "HashTable.H" +#include "Map.H" +#include "cpuTime.H" +#include "memInfo.H" + +#include <map> +#include <set> +#include <unordered_map> +#include <unordered_set> + +// #undef ORDERED +// #define ORDERED + +using namespace Foam; + +template<class T> +Ostream& printInfo(Ostream& os, const HashTable<T, T, Hash<T>>& ht) +{ + os << " (size " << ht.size() << " capacity " << ht.capacity() << ") "; + return os; +} + + +template<class K, class V> +inline void insertElem +( + #ifdef ORDERED + std::set<K>& container, + #else + std::unordered_set<K, Hash<K>>& container, + #endif + K k, + V v +) +{ + container.insert(k); +} + + +template<class K, class V> +inline void insertElem +( + #ifdef ORDERED + std::map<K, V>& container, + #else + std::unordered_map<K, V, Hash<K>>& container, + #endif + K k, + V v +) +{ + container.insert(std::make_pair(k, v)); +} + + +template<class K, class V> +inline void insertElem +( + HashSet<K, Hash<K>>& container, + K k, + V v +) +{ + container.insert(k); +} + + +template<class K, class V> +inline void insertElem +( + HashTable<K, V, Hash<K>>& container, + K k, + V v +) +{ + container.insert(k, v); +} + + +template<class Container> +inline void loopInsert(Container& container, const label n) +{ + for (label i = 0; i < n; i++) + { + insertElem(container, i, i); + } +} + + +template<class Container> +inline unsigned long loopFind(const Container& container, const label n) +{ + const auto endIter = container.end(); + unsigned long sum = 0; + + for (label i = 0; i < n; i++) + { + if (container.find(i) != endIter) + { + ++sum; + } + } + + return sum; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + const label nLoops = 200; + const label nFind = 10; + const label nElem = 1000000; + + argList::noBanner(); + argList::addBoolOption("std", "use std::unordered_map or std::set"); + argList::addBoolOption("set", "test HashSet"); + argList::addBoolOption("find", "test find"); + + argList args(argc, argv); + + const bool optStd = args.optionFound("std"); + const bool optSet = args.optionFound("set"); + const bool optFnd = args.optionFound("find"); + + + cpuTime timer; + memInfo mem; + + Info<< "insert " << nElem << " (int) elements"; + if (optFnd) + { + Info<< ", then find " << (nFind*nLoops) << " times\n"; + } + else + { + Info<< " repeated " << nLoops << " times " << endl; + } + + if (false) + { + // verify that resizing around (0) doesn't fail + HashTable<label, label, Hash<label>> map(32); + printInfo(Info, map) << endl; + + map.insert(10, 1000); + + map.resize(0); + printInfo(Info, map) << endl; + + map.resize(10); + printInfo(Info, map) << endl; + + map.clear(); + printInfo(Info, map) << endl; + + map.resize(0); + printInfo(Info, map) << endl; + return 0; + } + + + if (optStd) + { + if (optFnd) + { + #ifdef ORDERED + Info<< "using stl::set" << endl; + std::set<label> map; + #else + Info<< "using stl::unordered_set" << endl; + std::unordered_set<label, Hash<label>> map(32); + #endif + + loopInsert(map, nElem); + (void)timer.cpuTimeIncrement(); + + unsigned long sum = 0; + for (label loopi = 0; loopi < nFind*nLoops; ++loopi) + { + sum += loopFind(map, nElem); + } + + // check result (suppress compiler optimizations?) + if (sum == 0) + { + Info<<"sum=0\n"; + } + } + else if (optSet) + { + #ifdef ORDERED + Info<< "using stl::set" << endl; + #else + Info<< "using stl::unordered_set" << endl; + #endif + + for (label loopi = 0; loopi < nLoops; ++loopi) + { + #ifdef ORDERED + std::set<label> map; + #else + std::unordered_set<label, Hash<label>> map(32); + #endif + + loopInsert(map, nElem); + } + } + else + { + #ifdef ORDERED + Info<< "using stl::map" << endl; + #else + Info<< "using stl::unordered_set" << endl; + #endif + + for (label loopi = 0; loopi < nLoops; ++loopi) + { + #ifdef ORDERED + std::map<label, label> map; + #else + std::unordered_map<label, label, Hash<label>> map(32); + #endif + + loopInsert(map, nElem); + } + } + } + else + { + if (optFnd) + { + Info<< "using HashSet" << endl; + + HashSet<label, Hash<label>> map(32); + + loopInsert(map, nElem); + (void)timer.cpuTimeIncrement(); + + unsigned long sum = 0; + for (label loopi = 0; loopi < nFind*nLoops; ++loopi) + { + sum += loopFind(map, nElem); + } + + // check result (suppress compiler optimizations?) + if (sum == 0) + { + Info<<"sum=0\n"; + } + } + else if (optSet) + { + Info<< "using HashSet" << endl; + for (label loopi = 0; loopi < nLoops; ++loopi) + { + HashSet<label, Hash<label>> map(32); + + loopInsert(map, nElem); + } + } + else + { + Info<< "using HashTable" << endl; + for (label loopi = 0; loopi < nLoops; ++loopi) + { + HashTable<label, label, Hash<label>> map(32); + + loopInsert(map, nElem); + } + } + } + + Info<< timer.cpuTimeIncrement() << " s\n"; + Info<< "mem info: " << mem.update() << endl; + + return 0; +} + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C index 9370dd26edf..e7ad07ec2fd 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C @@ -28,6 +28,13 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +template<class T, class Key, class Hash> +Foam::HashPtrTable<T, Key, Hash>::HashPtrTable() +: + parent_type() +{} + + template<class T, class Key, class Hash> Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(const label size) : @@ -157,6 +164,7 @@ void Foam::HashPtrTable<T, Key, Hash>::operator= } } + // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "HashPtrTableIO.C" diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H index f83c04e3139..daf19328d06 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H @@ -91,8 +91,11 @@ public: // Constructors + //- Construct null with default table size + HashPtrTable(); + //- Construct given initial table size - HashPtrTable(const label size = 128); + explicit HashPtrTable(const label size); //- Construct from Istream using given Istream constructor class template<class INew> @@ -102,7 +105,7 @@ public: HashPtrTable(Istream& is); //- Construct from dictionary with default dictionary constructor class - HashPtrTable(const dictionary& dict); + explicit HashPtrTable(const dictionary& dict); //- Construct as copy HashPtrTable(const this_type& ht); @@ -127,7 +130,7 @@ public: //- Erase an entry specified by the given key bool erase(const Key& key); - //- Clear all entries from table + //- Clear all entries from table and deleting any allocated pointers void clear(); //- Write diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C index 55004189fe0..bbc7351857e 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C @@ -41,7 +41,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt) is.fatalCheck ( - "HashPtrTable<T, Key, Hash>::read(Istream&, const INew&) : " + "HashPtrTable::read(Istream&, const INew&) : " "reading first token" ); @@ -50,7 +50,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt) const label s = firstToken.labelToken(); // Read beginning of contents - const char delimiter = is.readBeginList("HashPtrTable<T, Key, Hash>"); + const char delimiter = is.readBeginList("HashPtrTable"); if (s) { @@ -69,8 +69,8 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt) is.fatalCheck ( - "HashPtrTable<T, Key, Hash>::" - "read(Istream&, const INew&) : reading entry" + "HashPtrTable::read(Istream&, const INew&) : " + "reading entry" ); } } @@ -114,7 +114,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt) is.fatalCheck ( - "HashPtrTable<T, Key, Hash>::read(Istream&, const INew&) : " + "HashPtrTable::read(Istream&, const INew&) : " "reading entry" ); @@ -155,7 +155,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read template<class T, class Key, class Hash> void Foam::HashPtrTable<T, Key, Hash>::write(Ostream& os) const { - for (const_iterator iter = this->begin(); iter != this->end(); ++iter) + for (const_iterator iter = this->cbegin(); iter != this->cend(); ++iter) { const T* ptr = iter.object(); if (ptr) @@ -209,29 +209,34 @@ Foam::Ostream& Foam::operator<< const HashPtrTable<T, Key, Hash>& tbl ) { - using const_iterator = typename HashPtrTable<T, Key, Hash>::const_iterator; + const label sz = tbl.size(); - // Write size and start delimiter - os << nl << tbl.size() << nl << token::BEGIN_LIST << nl; - - // Write contents - for (const_iterator iter = tbl.cbegin(); iter != tbl.cend(); ++iter) + if (sz) { - const T* ptr = iter.object(); + // Size and start list delimiter + os << nl << sz << nl << token::BEGIN_LIST << nl; - os << iter.key(); - if (ptr) + // Contents + for (auto iter = tbl.cbegin(); iter != tbl.cend(); ++iter) { - os << token::SPACE << *ptr; + const T* ptr = iter.object(); + + os << iter.key(); + if (ptr) + { + os << token::SPACE << *ptr; + } + os << nl; } - os << nl; + os << token::END_LIST; // End list delimiter + } + else + { + // Empty hash table + os << sz << token::BEGIN_LIST << token::END_LIST; } - - // Write end delimiter - os << token::END_LIST; os.check(FUNCTION_NAME); - return os; } diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C index 020d3e36d9f..3070831f26a 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C @@ -79,7 +79,7 @@ inline Foam::label Foam::HashSet<Key, Hash>::assignMultiple template<class Key, class Hash> Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst) : - HashTable<nil, Key, Hash>(2*lst.size()) + parent_type(2*lst.size()) { for (const auto& k : lst) { @@ -92,7 +92,7 @@ template<class Key, class Hash> template<unsigned Size> Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& lst) : - HashTable<nil, Key, Hash>(2*lst.size()) + parent_type(2*lst.size()) { for (const auto& k : lst) { @@ -104,7 +104,7 @@ Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& lst) template<class Key, class Hash> Foam::HashSet<Key, Hash>::HashSet(std::initializer_list<Key> lst) : - HashTable<nil, Key, Hash>(2*lst.size()) + parent_type(2*lst.size()) { for (const auto& k : lst) { @@ -120,7 +120,7 @@ Foam::HashSet<Key, Hash>::HashSet const HashTable<AnyType, Key, AnyHash>& tbl ) : - HashTable<nil, Key, Hash>(tbl.capacity()) + parent_type(tbl.capacity()) { using other_iter = typename HashTable<AnyType, Key, AnyHash>::const_iterator; @@ -349,7 +349,7 @@ template<class Key, class Hash> inline typename Foam::HashSet<Key, Hash>::const_iterator Foam::HashSet<Key, Hash>::begin() const { - return HashTableCore::iterator_begin<const_iterator> + return HashTableCore::iterator_cbegin<const_iterator> ( static_cast<const parent_type&>(*this) ); @@ -360,7 +360,7 @@ template<class Key, class Hash> inline typename Foam::HashSet<Key, Hash>::const_iterator Foam::HashSet<Key, Hash>::cbegin() const { - return HashTableCore::iterator_begin<const_iterator> + return HashTableCore::iterator_cbegin<const_iterator> ( static_cast<const parent_type&>(*this) ); @@ -379,7 +379,7 @@ template<class Key, class Hash> inline const typename Foam::HashSet<Key, Hash>::const_iterator& Foam::HashSet<Key, Hash>::end() const { - return HashTableCore::iterator_end<const_iterator>(); + return HashTableCore::iterator_cend<const_iterator>(); } diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H index ace2ca6d7aa..f20e9059203 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H @@ -25,7 +25,24 @@ Class Foam::HashSet Description - A HashTable with keys but without contents. + A HashTable with keys but without contents that is similar to + \c std::unordered_set. + The entries are considered \a unordered since their placement + depends on the method used to generate the hash key index, the + table capacity, insertion order etc. When the key order is + important, use the sortedToc() method to obtain a list of sorted + keys and use that for further access. + +Note + The HashSet iterator dereferences to the key, so the following + range-for works as expected: + \code + HashSet<label> someLabels{10, 20, 30, 40, ...}; + for (const label i : someLabels) + { + Info<< "val:" << i << nl; + } + \endcode Typedef Foam::wordHashSet @@ -45,7 +62,6 @@ Description #define HashSet_H #include "HashTable.H" -#include "nil.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -66,7 +82,7 @@ Ostream& operator<<(Ostream& os, const HashSet<Key, Hash>& tbl); template<class Key=word, class Hash=string::hash> class HashSet : - public HashTable<nil, Key, Hash> + public HashTable<zero::null, Key, Hash> { // Private Member Functions @@ -94,7 +110,7 @@ public: typedef HashSet<Key, Hash> this_type; //- The template instance used for the parent HashTable - typedef HashTable<nil, Key, Hash> parent_type; + typedef HashTable<zero::null, Key, Hash> parent_type; //- An iterator, returning reference to the key using iterator = typename parent_type::key_iterator; @@ -105,13 +121,19 @@ public: // Constructors + //- Construct null with default (128) table size + HashSet() + : + parent_type() + {} + //- Construct given initial size - HashSet(const label size = 128) + explicit HashSet(const label size) : parent_type(size) {} - //- Construct from Istream + //- Construct from Istream with default table size HashSet(Istream& is) : parent_type(is) @@ -140,13 +162,13 @@ public: {} //- Construct by transferring the parameter contents - HashSet(const Xfer<HashSet<Key, Hash>>& hs) + HashSet(const Xfer<this_type>& hs) : parent_type(hs) {} //- Construct by transferring the parameter contents - HashSet(const Xfer<HashTable<nil, Key, Hash>>& hs) + HashSet(const Xfer<parent_type>& hs) : parent_type(hs) {} @@ -166,7 +188,7 @@ public: // not previously exist in the set. bool insert(const Key& key) { - return this->parent_type::insert(key, nil()); + return this->parent_type::insert(key, zero::null()); } //- Insert keys from the list of Key @@ -182,26 +204,26 @@ public: // \return The number of new elements inserted label insert(std::initializer_list<Key> lst); - //- Same as insert (cannot overwrite nil content) + //- Same as insert (no value to overwrite) bool set(const Key& key) { return insert(key); } - //- Same as insert (cannot overwrite nil content) + //- Same as insert (no value to overwrite) label set(const UList<Key>& lst) { return insert(lst); } - //- Same as insert (cannot overwrite nil content) + //- Same as insert (no value to overwrite) template<unsigned Size> label set(const FixedList<Key, Size>& lst) { return insert(lst); } - //- Same as insert (cannot overwrite nil content) + //- Same as insert (no value to overwrite) label set(std::initializer_list<Key> lst) { return insert(lst); @@ -331,22 +353,22 @@ public: // Logical operations //- Combine entries from HashSets - void operator|=(const HashSet<Key, Hash>& rhs); + void operator|=(const this_type& rhs); //- Only retain entries found in both HashSets - inline void operator&=(const HashSet<Key, Hash>& rhs); + inline void operator&=(const this_type& rhs); //- Only retain unique entries (xor) - void operator^=(const HashSet<Key, Hash>& rhs); + void operator^=(const this_type& rhs); //- Add entries listed in the given HashSet to this HashSet - inline void operator+=(const HashSet<Key, Hash>& rhs) + inline void operator+=(const this_type& rhs) { this->operator|=(rhs); } //- Remove entries listed in the given HashSet from this HashSet - inline void operator-=(const HashSet<Key, Hash>& rhs); + inline void operator-=(const this_type& rhs); // IOstream Operator diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index 1c1d7b43606..68faaafb49f 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -61,21 +61,27 @@ Foam::label Foam::HashTable<T, Key, Hash>::eraseMultiple // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +template<class T, class Key, class Hash> +Foam::HashTable<T, Key, Hash>::HashTable() +: + HashTable<T, Key, Hash>(128) +{} + + template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable(const label size) : HashTableCore(), - nElmts_(0), - tableSize_(HashTableCore::canonicalSize(size)), + size_(0), + capacity_(HashTableCore::canonicalSize(size)), table_(nullptr) { - if (tableSize_) + if (capacity_) { - table_ = new hashedEntry*[tableSize_]; - - for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx) + table_ = new node_type*[capacity_]; + for (label i=0; i < capacity_; ++i) { - table_[hashIdx] = nullptr; + table_[i] = nullptr; } } } @@ -84,7 +90,7 @@ Foam::HashTable<T, Key, Hash>::HashTable(const label size) template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht) : - HashTable<T, Key, Hash>(ht.tableSize_) + HashTable<T, Key, Hash>(ht.capacity_) { for (const_iterator iter = ht.cbegin(); iter != ht.cend(); ++iter) { @@ -96,10 +102,7 @@ Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht) template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable(HashTable<T, Key, Hash>&& ht) : - HashTableCore(), - nElmts_(0), - tableSize_(0), - table_(nullptr) + HashTable<T, Key, Hash>(0) { transfer(ht); } @@ -111,10 +114,7 @@ Foam::HashTable<T, Key, Hash>::HashTable const Xfer<HashTable<T, Key, Hash>>& ht ) : - HashTableCore(), - nElmts_(0), - tableSize_(0), - table_(nullptr) + HashTable<T, Key, Hash>(0) { transfer(ht()); } @@ -150,110 +150,10 @@ Foam::HashTable<T, Key, Hash>::~HashTable() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class T, class Key, class Hash> -bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const -{ - if (nElmts_) - { - const label hashIdx = hashKeyIndex(key); - - for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) - { - if (key == ep->key_) - { - return true; - } - } - } - - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "Entry " << key << " not found in hash table\n"; - } - #endif - - return false; -} - - -template<class T, class Key, class Hash> -typename Foam::HashTable<T, Key, Hash>::iterator -Foam::HashTable<T, Key, Hash>::find -( - const Key& key -) -{ - if (nElmts_) - { - const label hashIdx = hashKeyIndex(key); - - for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) - { - if (key == ep->key_) - { - return iterator(this, ep, hashIdx); - } - } - } - - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "Entry " << key << " not found in hash table\n"; - } - #endif - - return iterator(); -} - - -template<class T, class Key, class Hash> -typename Foam::HashTable<T, Key, Hash>::const_iterator -Foam::HashTable<T, Key, Hash>::find -( - const Key& key -) const -{ - return this->cfind(key); -} - - -template<class T, class Key, class Hash> -typename Foam::HashTable<T, Key, Hash>::const_iterator -Foam::HashTable<T, Key, Hash>::cfind -( - const Key& key -) const -{ - if (nElmts_) - { - const label hashIdx = hashKeyIndex(key); - - for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) - { - if (key == ep->key_) - { - return const_iterator(this, ep, hashIdx); - } - } - } - - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction << "Entry " << key << " not found in hash table\n"; - } - #endif - - return const_iterator(); -} - - template<class T, class Key, class Hash> Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const { - List<Key> keyLst(nElmts_); + List<Key> keyLst(size_); label count = 0; for (const_iterator iter = cbegin(); iter != cend(); ++iter) @@ -297,7 +197,7 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocKeys const bool invert ) const { - List<Key> keyLst(nElmts_); + List<Key> keyLst(size_); label count = 0; for (const_iterator iter = cbegin(); iter != cend(); ++iter) @@ -323,7 +223,7 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocValues const bool invert ) const { - List<Key> keyLst(nElmts_); + List<Key> keyLst(size_); label count = 0; for (const_iterator iter = cbegin(); iter != cend(); ++iter) @@ -349,7 +249,7 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocEntries const bool invert ) const { - List<Key> keyLst(nElmts_); + List<Key> keyLst(size_); label count = 0; for (const_iterator iter = cbegin(); iter != cend(); ++iter) @@ -438,36 +338,36 @@ bool Foam::HashTable<T, Key, Hash>::set ( const Key& key, const T& obj, - const bool protect + const bool overwrite ) { - if (!tableSize_) + if (!capacity_) { resize(2); } - const label hashIdx = hashKeyIndex(key); + const label index = hashKeyIndex(key); - hashedEntry* existing = nullptr; - hashedEntry* prev = nullptr; + node_type* curr = nullptr; + node_type* prev = nullptr; - for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) + for (node_type* ep = table_[index]; ep; ep = ep->next_) { - if (key == ep->key_) + if (key == ep->key()) { - existing = ep; + curr = ep; break; } prev = ep; } - if (!existing) + if (!curr) { // Not found, insert it at the head - table_[hashIdx] = new hashedEntry(key, obj, table_[hashIdx]); - nElmts_++; + table_[index] = new node_type(key, obj, table_[index]); + ++size_; - if (double(nElmts_)/tableSize_ > 0.8 && tableSize_ < maxTableSize) + if (double(size_)/capacity_ > 0.8 && capacity_ < maxTableSize) { #ifdef FULLDEBUG if (debug) @@ -476,115 +376,60 @@ bool Foam::HashTable<T, Key, Hash>::set } #endif - resize(2*tableSize_); + resize(2*capacity_); } } - else if (protect) + else if (overwrite) { - // Found - but protected from overwriting - // this corresponds to the STL 'insert' convention - #ifdef FULLDEBUG - if (debug) - { - InfoInFunction - << "Cannot insert " << key << " already in hash table\n"; - } - #endif - return false; - } - else - { - // Found - overwrite existing entry - // this corresponds to the Perl convention - hashedEntry* ep = new hashedEntry(key, obj, existing->next_); + // Overwrite current entry (Perl convention). - // Replace existing element - within list or insert at the head - if (prev) - { - prev->next_ = ep; - } - else - { - table_[hashIdx] = ep; - } + node_type* ep = curr->next_; // next in the linked list - delete existing; - } + // In some cases the delete/new could be avoided in favour of move + // assignment, but cannot be certain that all objects support this + // or that it behaves the same as a copy construct. - return true; -} - - -template<class T, class Key, class Hash> -bool Foam::HashTable<T, Key, Hash>::iterator_base::erase() -{ - // Note: entryPtr_ is nullptr for end(), so this catches that too - if (entryPtr_) - { - // Search element before entryPtr_ - entry_type* prev = nullptr; - - for - ( - entry_type* ep = hashTable_->table_[hashIndex_]; - ep; - ep = ep->next_ - ) - { - if (ep == entryPtr_) - { - break; - } - prev = ep; - } + delete curr; + ep = new node_type(key, obj, ep); + // Replace current element - within list or insert at the head if (prev) { - // Has an element before entryPtr - reposition to there - prev->next_ = entryPtr_->next_; - delete entryPtr_; - entryPtr_ = prev; + prev->next_ = ep; } else { - // entryPtr was first element on SLList - hashTable_->table_[hashIndex_] = entryPtr_->next_; - delete entryPtr_; - - // Assign any non-nullptr value so it doesn't look like end() - entryPtr_ = reinterpret_cast<hashedEntry*>(this); - - // Mark with special hashIndex value to signal it has been rewound. - // The next increment will bring it back to the present location. - // - // From the current position 'curPos', we wish to continue at - // prevPos='curPos-1', which we mark as markPos='-curPos-1'. - // The negative lets us notice it is special, the extra '-1' - // is needed to avoid ambiguity for position '0'. - // To retrieve prevPos, we would later use '-(markPos+1) - 1' - hashIndex_ = -hashIndex_ - 1; + table_[index] = ep; } - - hashTable_->nElmts_--; - - return true; } else { + // Do not overwrite existing entry (STL 'insert' convention) + #ifdef FULLDEBUG + if (debug) + { + InfoInFunction + << "Cannot insert " << key << " already in hash table\n"; + } + #endif return false; } + + return true; } template<class T, class Key, class Hash> bool Foam::HashTable<T, Key, Hash>::erase(const iterator& iter) { - // NOTE: We use (const iterator&) here, but manipulate its contents anyhow. + // NOTE: we use (const iterator&) here, but treat its contents as mutable. + // // The parameter should be (iterator&), but then the compiler doesn't find // it correctly and tries to call as (iterator) instead. - // - // Adjust iterator after erase - return const_cast<iterator&>(iter).erase(); + + iterator& it = const_cast<iterator&>(iter); + + return iterator_erase(it.entry_, it.index_); } @@ -599,7 +444,7 @@ bool Foam::HashTable<T, Key, Hash>::erase(const Key& key) template<class T, class Key, class Hash> Foam::label Foam::HashTable<T, Key, Hash>::erase(const UList<Key>& keys) { - return eraseMultiple(keys.begin(), keys.end()); + return eraseMultiple(keys.cbegin(), keys.cend()); } @@ -610,7 +455,7 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase const FixedList<Key, Size>& keys ) { - return eraseMultiple(keys.begin(), keys.end()); + return eraseMultiple(keys.cbegin(), keys.cend()); } @@ -634,17 +479,14 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase const label nTotal = this->size(); label changed = 0; - using other_iter = - typename HashTable<AnyType, Key, AnyHash>::const_iterator; - if (other.size() <= nTotal) { // The other is smaller/same-size, use its keys for removal for ( - other_iter iter = other.begin(); - changed < nTotal && iter != other.end(); // terminate early + auto iter = other.cbegin(); + changed < nTotal && iter != other.cend(); // Terminate early ++iter ) { @@ -660,7 +502,7 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase for ( iterator iter = begin(); - changed < nTotal && iter != end(); // terminate early + changed < nTotal && iter != end(); // Terminate early ++iter ) { @@ -711,9 +553,10 @@ Foam::label Foam::HashTable<T, Key, Hash>::retain template<class T, class Key, class Hash> void Foam::HashTable<T, Key, Hash>::resize(const label sz) { - const label newSize = HashTableCore::canonicalSize(sz); + const label newCapacity = HashTableCore::canonicalSize(sz); + const label oldCapacity = capacity_; - if (newSize == tableSize_) + if (newCapacity == oldCapacity) { #ifdef FULLDEBUG if (debug) @@ -724,46 +567,85 @@ void Foam::HashTable<T, Key, Hash>::resize(const label sz) return; } + else if (!newCapacity) + { + // Special treatment for resize(0) + if (size_) + { + WarningInFunction + << "HashTable contains " << size_ << " cannot resize(0)" + << endl; + } + else + { + if (table_) + { + delete[] table_; + capacity_ = 0; + } - HashTable<T, Key, Hash>* tmpTable = new HashTable<T, Key, Hash>(newSize); + table_ = nullptr; + } - for (const_iterator iter = cbegin(); iter != cend(); ++iter) + return; + } + + // Swap primary table entries: size_ is left untouched + + auto oldTable = table_; + capacity_ = newCapacity; + + table_ = new node_type*[capacity_]; + for (label i=0; i < capacity_; ++i) { - tmpTable->insert(iter.key(), iter.object()); + table_[i] = nullptr; } - const label oldSize = tableSize_; - tableSize_ = tmpTable->tableSize_; - tmpTable->tableSize_ = oldSize; + // Move to new table[] but with new chaining. + + label nMove = size_; // Allow early completion + for (label i=0; nMove && i < oldCapacity; ++i) + { + for (node_type* ep = oldTable[i]; ep; /*nil*/) + { + node_type* next = ep->next_; + + // Move to new location + { + const label newIdx = hashKeyIndex(ep->key()); + + ep->next_ = table_[newIdx]; // add to head + table_[newIdx] = ep; + } - hashedEntry** oldTable = table_; - table_ = tmpTable->table_; - tmpTable->table_ = oldTable; + ep = next; // continue in the linked-list + --nMove; // note any early completion + } + oldTable[i] = nullptr; + } - delete tmpTable; + if (oldTable) + { + delete[] oldTable; + } } template<class T, class Key, class Hash> void Foam::HashTable<T, Key, Hash>::clear() { - if (nElmts_) + for (label i=0; size_ && i<capacity_; ++i) { - for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++) + for (node_type* ep = table_[i]; ep; /*nil*/) { - if (table_[hashIdx]) - { - hashedEntry* ep = table_[hashIdx]; - while (hashedEntry* next = ep->next_) - { - delete ep; - ep = next; - } - delete ep; - table_[hashIdx] = nullptr; - } + node_type* next = ep->next_; + + delete ep; + + ep = next; // continue in the linked-list + --size_; // note any early completion } - nElmts_ = 0; + table_[i] = nullptr; } } @@ -779,30 +661,31 @@ void Foam::HashTable<T, Key, Hash>::clearStorage() template<class T, class Key, class Hash> void Foam::HashTable<T, Key, Hash>::swap(HashTable<T, Key, Hash>& ht) { - Foam::Swap(table_, ht.table_); - Foam::Swap(tableSize_, ht.tableSize_); - Foam::Swap(nElmts_, ht.nElmts_); + Foam::Swap(size_, ht.size_); + Foam::Swap(capacity_, ht.capacity_); + Foam::Swap(table_, ht.table_); } template<class T, class Key, class Hash> void Foam::HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) { - // As per the Destructor + // As per destructor if (table_) { clear(); delete[] table_; } - tableSize_ = ht.tableSize_; - ht.tableSize_ = 0; + size_ = ht.size_; + ht.size_ = 0; + + capacity_ = ht.capacity_; + ht.capacity_ = 0; table_ = ht.table_; ht.table_ = nullptr; - nElmts_ = ht.nElmts_; - ht.nElmts_ = 0; } @@ -904,9 +787,9 @@ void Foam::HashTable<T, Key, Hash>::operator= } // Could be zero-sized from a previous transfer() - if (!tableSize_) + if (!capacity_) { - resize(rhs.tableSize_); + resize(rhs.capacity_); } else { @@ -927,7 +810,7 @@ void Foam::HashTable<T, Key, Hash>::operator= ) { // Could be zero-sized from a previous transfer() - if (!tableSize_) + if (!capacity_) { resize(2*lst.size()); } @@ -975,7 +858,7 @@ bool Foam::HashTable<T, Key, Hash>::operator== for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { - const_iterator other = this->cfind(iter.key()); + const const_iterator other(this->cfind(iter.key())); if (!other.found() || other.object() != iter.object()) { @@ -997,8 +880,11 @@ bool Foam::HashTable<T, Key, Hash>::operator!= } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Iterators, Friend Operators +#include "HashTableIter.C" #include "HashTableIO.C" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 1c42c9426a1..a496b6b630f 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -25,14 +25,15 @@ Class Foam::HashTable Description - An STL-conforming hash table. + A HashTable similar to \c std::unordered_map. + The entries are considered \a unordered since their placement + depends on the method used to generate the hash key index, the + table capacity, insertion order etc. When the key order is + important, use the sortedToc() method to obtain a list of sorted + keys and use that for further access. -Note - Hashing index collisions are handled via chaining using a singly-linked - list with the colliding entry being added to the head of the linked - list. Thus copying the hash table (or indeed even resizing it) will - often result in a different hash order. Use a sorted table-of-contents - when the hash order is important. + Internally the table uses closed addressing into a flat storage space + with collisions handled by linked-list chaining. The end iterator of all hash-tables has a nullptr to the hash entry. Thus avoid separate allocation for each table and use a single one with @@ -41,10 +42,38 @@ Note a nullptr as its first data member. The nullObject is such an item (with a nullptr data member). +Note + For historical reasons, dereferencing the table iterator + (eg, \a *iter) returns a reference to the stored object value + value rather than the stored key/object value like std::unordered_map + does. + + The HashTable iterator: + \code + forAllConstIters(table, iter) + { + Info<< "val:" << *iter << nl + << "key:" << iter.key() << nl; + << "val:" << iter.object() << nl; + } + \endcode + whereas for the \c std::unordered_map iterator: + \code + forAllConstIters(stdmap, iter) + { + Info<< "key/val:" << *iter << nl + << "key:" << iter->first << nl + << "val:" << iter->second << nl; + } + \endcode + This difference is most evident when using range-for syntax. + SourceFiles HashTableI.H + HashTableIterI.H HashTable.C HashTableIO.C + HashTableIter.C \*---------------------------------------------------------------------------*/ @@ -52,6 +81,7 @@ SourceFiles #define HashTable_H #include "word.H" +#include "zero.H" #include "Xfer.H" #include "Hash.H" #include "HashTableCore.H" @@ -80,7 +110,7 @@ Ostream& operator<<(Ostream& os, const HashTable<T, Key, Hash>& tbl); /*---------------------------------------------------------------------------*\ - Class HashTable Declaration + Class HashTable Declaration \*---------------------------------------------------------------------------*/ template<class T, class Key=word, class Hash=string::hash> @@ -88,86 +118,127 @@ class HashTable : public HashTableCore { -public: - - //- The template instance used for this HashTable - typedef HashTable<T, Key, Hash> this_type; + // Private types for table entries + //- Structure with a (K,V) tuple and a linked-list for collisions + // Could store key/object as std::pair, but no particular advantage + // unless the iterator dereference type changes. + struct pair_entry + { + //- Type of key + typedef Key key_type; - // STL type definitions + //- Object content type + typedef T mapped_type; - //- Type of keys that the HashTable uses. - typedef Key key_type; + //- The lookup key + key_type key_; - //- Type of values that the HashTable contains. - typedef T value_type; + //- The data object + mapped_type obj_; - //- The type used for storing into value_type objects. - // This type is usually value_type&. - typedef T* pointer; + //- Addressing (next in collision list) + pair_entry* next_; - //- The type used for storing into value_type objects. - // This type is usually value_type&. - typedef T& reference; + //- Construct from key, object, next pointer + pair_entry(const Key& key, const T& obj, pair_entry* next) + : + key_(key), + obj_(obj), + next_(next) + {} + + //- The key + const key_type& key() const + { + return key_; + } + + //- The mapped object + const mapped_type& mapped() const + { + return obj_; + } + mapped_type& mapped() + { + return obj_; + } - //- The type used for reading from constant value_type objects. - typedef const T* const_pointer; + private: + //- Disallow default bitwise copy construct / assignment + pair_entry(const pair_entry&) = delete; + void operator=(const pair_entry&) = delete; + }; - //- The type used for reading from constant value_type objects. - typedef const T& const_reference; - //- The type to represent the difference between two iterators - typedef label difference_type; + //- Structure with a single (K) value and a linked-list for collisions + struct unary_entry + { + //- Type of key + typedef Key key_type; - //- The type that can represent the size of a HashTable. - typedef label size_type; + //- Object content type + typedef zero::null mapped_type; + //- Content storage type to the entry + typedef key_type value_type; - //- Forward iterator with non-const access - class iterator; + //- The lookup key == content + key_type key_; - //- Forward iterator with const access - class const_iterator; + //- Addressing (next in collision list) + unary_entry* next_; + //- Construct from key, (ununsed) object, next pointer + unary_entry(const Key& key, const T&, unary_entry* next) + : + key_(key), + next_(next) + {} -private: + //- The key + const key_type& key() const + { + return key_; + } - // Private data type for table entries + //- Dummy mapped object + const mapped_type& mapped() const + { + return zeroNullElement; + } + mapped_type& mapped() + { + return zeroNullElement; + } - //- Structure to hold a hashed entry, with a linked-list for collisions - struct hashedEntry - { - //- The lookup key - Key key_; - - //- The data object - T obj_; - - //- Pointer to next hashedEntry in sub-list - hashedEntry* next_; - - //- Construct from key, object, next pointer - inline hashedEntry(const Key& key, const T& obj, hashedEntry* next); private: - //- Disallow default bitwise copy construct - hashedEntry(const hashedEntry&) = delete; - - //- Disallow default bitwise assignment - void operator=(const hashedEntry&) = delete; + //- Disallow default bitwise copy construct / assignment + unary_entry(const unary_entry&) = delete; + void operator=(const unary_entry&) = delete; }; - // Private data: size of table, the table and current number of elements + //- Hashed node with a linked-list for collisions + typedef typename std::conditional + < + std::is_same<zero::null, typename std::remove_cv<T>::type>::value, + unary_entry, + pair_entry + >::type node_type; - //- The current number of elements in table - label nElmts_; - //- Number of primary entries allocated in table - label tableSize_; + // Private Data - //- The table of primary entries - hashedEntry** table_; + //- The number of nodes currently stored in table + label size_; + + //- Number of nodes allocated in table + label capacity_; + + //- The table of primary nodes + node_type** table_; // Private Member Functions @@ -178,16 +249,65 @@ private: //- Assign a new hash-entry to a possibly already existing key. // \return True if the new entry was set. - bool set(const Key& key, const T& obj, const bool protect); + bool set(const Key& key, const T& obj, const bool overwrite); + + +public: + + //- The template instance used for this HashTable + typedef HashTable<T, Key, Hash> this_type; + + + // STL type definitions + + //- The second template parameter, type of keys used. + typedef Key key_type; + + //- The first template parameter, type of objects contained. + typedef T mapped_type; + + //- Same as mapped_type for OpenFOAM HashTables + // Note that this is different than the std::map definition. + typedef T value_type; + + //- The third template parameter, the hash index method. + typedef Hash hasher; + + //- The type used for storing into value_type objects. + // This type is usually 'value_type*'. + typedef T* pointer; + + //- The type used for storing into value_type objects. + // This type is usually 'value_type&'. + typedef T& reference; + + //- The type used for reading from constant value_type objects. + typedef const T* const_pointer; + + //- The type used for reading from constant value_type objects. + typedef const T& const_reference; + + //- The type to represent the difference between two iterators + typedef label difference_type; + + //- The type that can represent the size of a HashTable. + typedef label size_type; + + + //- Forward iterator with non-const access + class iterator; + //- Forward iterator with const access + class const_iterator; protected: //- Internally used base for iterator and const_iterator - class iterator_base; + template<bool Const> class Iterator; - //- Friendship with the iterator_base is required. - friend class iterator_base; + //- Friendship with the base iterator is required. + friend class Iterator<true>; + friend class Iterator<false>; // Protected Member Functions @@ -205,20 +325,23 @@ public: // Constructors + //- Construct null with default (128) table size + HashTable(); + //- Construct given initial table size - HashTable(const label size = 128); + explicit HashTable(const label size); - //- Construct from Istream + //- Construct from Istream with default table size HashTable(Istream& is, const label size = 128); //- Construct as copy - HashTable(const HashTable<T, Key, Hash>& ht); + HashTable(const this_type& ht); //- Move construct - HashTable(HashTable<T, Key, Hash>&& ht); + HashTable(this_type&& ht); //- Construct by transferring the parameter contents - HashTable(const Xfer<HashTable<T, Key, Hash>>& ht); + HashTable(const Xfer<this_type>& ht); //- Construct from an initializer list HashTable(std::initializer_list<std::pair<Key, T>> lst); @@ -242,19 +365,19 @@ public: inline bool empty() const; //- Return true if hashed entry is found in table - bool found(const Key& key) const; + inline bool found(const Key& key) const; //- Find and return an iterator set at the hashed entry // If not found iterator = end() - iterator find(const Key& key); + inline iterator find(const Key& key); //- Find and return an const_iterator set at the hashed entry // If not found iterator = end() - const_iterator find(const Key& key) const; + inline const_iterator find(const Key& key) const; //- Find and return an const_iterator set at the hashed entry // If not found iterator = end() - const_iterator cfind(const Key& key) const; + inline const_iterator cfind(const Key& key) const; //- Return hashed entry if it exists, or return the given default inline const T& lookup(const Key& key, const T& deflt) const; @@ -512,149 +635,157 @@ protected: // and prevent most external usage. // iterator and const_iterator have the same size, allowing // us to reinterpret_cast between them (if desired) - class iterator_base + + template<bool Const> + class Iterator { public: - // Public typedefs - using table_type = this_type; - using key_type = this_type::key_type; + // Typedefs using iterator_category = std::forward_iterator_tag; - using difference_type = this_type::difference_type; + using difference_type = this_type::difference_type; + + //- The HashTable container type + using table_type = typename std::conditional + < + Const, + const this_type, + this_type + >::type; + + //- The node-type being addressed + using node_type = typename std::conditional + < + Const, + const this_type::node_type, + this_type::node_type + >::type; + + //- The key type + using key_type = this_type::key_type; + + //- The object type being addressed + using mapped_type = typename std::conditional + < + Const, + const this_type::mapped_type, + this_type::mapped_type + >::type; + + + // Member Functions - private: - using entry_type = hashedEntry; + //- True if iterator points to an entry + // This can be used directly instead of comparing to end() + inline bool found() const; - // Private Data + //- The key associated with the iterator + inline const Key& key() const; - //- Currently selected entry. - // MUST be the first member for easy comparison between iterators - // and for reinterpret_cast from nullObject - entry_type* entryPtr_; + // Member Operators - //- Pointer to the hash-table for which this is an iterator - // This allows use of the default bitwise copy/assignment - table_type* hashTable_; + //- Compare hash-entry element pointers. + // Independent of const/non-const access + inline bool operator==(const Iterator<true>& iter) const; + inline bool operator!=(const Iterator<true>& iter) const; - //- Current hash index within the hash-table data. - // A signed value, since erase() uses a negative value to signal - // the erasure state. - label hashIndex_; + inline bool operator==(const Iterator<false>& iter) const; + inline bool operator!=(const Iterator<false>& iter) const; - protected: - // Protected Member Functions + protected: + friend class HashTable; // For begin/find constructors - //- Increment to the next position - inline void increment(); + // Protected Data - //- The referenced object/value element - inline T& element() const; + //- The selected entry. + // MUST be the first member for easy comparison between iterators + // and for reinterpret_cast from nullObject + node_type* entry_; - //- Erase the entry at the current position - bool erase(); + //- The hash-table container being iterated on. + // Using a pointer allows default bitwise copy/assignment + table_type* container_; + //- Index within the hash-table data. + // A signed value, since iterator_erase() needs a negative value + // to mark the position. + label index_; - public: - // Constructors + // Protected Constructors //- Construct null (end iterator) - inline iterator_base(); + inline Iterator(); //- Construct from begin of hash-table - inline explicit iterator_base(const table_type* hashTbl); + inline Iterator(bool, table_type* tbl); - //- Construct from hash table, element and hash index - inline iterator_base - ( - const table_type* hashTbl, - const entry_type* elmt, - const label hashIndex - ); + //- Construct by finding key in hash table + inline Iterator(table_type* tbl, const Key& key); - // Member functions/operators - //- True if iterator points to an entry - // This can be used directly instead of comparing to end() - inline bool found() const; + // Protected Member Functions - //- Return the Key corresponding to the iterator - inline const Key& key() const; + //- Increment to the next position + inline void increment(); - //- Compare hash-entry element pointers - inline bool operator==(const iterator_base& iter) const; - inline bool operator!=(const iterator_base& iter) const; + //- The object associated with the iterator + inline mapped_type& object() const + { + return entry_->mapped(); + } + + //- Permit an explicit cast to the other (const/non-const) searcher + inline explicit operator const Iterator<!Const>&() const + { + return *reinterpret_cast<const Iterator<!Const>*>(this); + } }; -public: - - //- An iterator wrapper for returning a reference to the key - template<class WrappedIterator> - class key_iterator_base - : - public WrappedIterator - { - public: - using value_type = this_type::key_type; - using pointer = const Key*; - using reference = const Key&; - - //- Implicit conversion - inline key_iterator_base(const WrappedIterator& iter); - - //- Return the key - inline reference operator*() const; - inline reference operator()() const; - - inline key_iterator_base& operator++(); - inline key_iterator_base operator++(int); - }; - + //- Low-level entry erasure using iterator internals. + // This invalidates the iterator until the next ++ operation. + // \return True if the corresponding entry existed and was removed + bool iterator_erase(node_type*& entry, label& index); - // STL iterator +public: //- Forward iterator with non-const access class iterator : - public iterator_base + public Iterator<false> { - friend class HashTable; // Uses iterator::erase() method - using entry_type = hashedEntry; - public: + // Typedefs + using iterator_category = std::forward_iterator_tag; + using difference_type = this_type::difference_type; - // Public typedefs - using table_type = this_type; - using value_type = this_type::value_type; - using pointer = this_type::pointer; - using reference = this_type::reference; + using key_type = this_type::key_type; + using mapped_type = this_type::mapped_type; + using value_type = this_type::value_type; + using pointer = this_type::pointer; + using reference = this_type::reference; // Constructors //- Construct null (end iterator) - inline iterator(); + inline iterator() {} - //- Construct from begin of hash-table - inline explicit iterator(table_type* hashTbl); + //- Copy construct from similar access type + inline explicit iterator(const Iterator<false>& iter) + : + Iterator<false>(iter) + {} - //- Construct from hash table, element and hash index - // Used by the hash-table find() method. - inline iterator - ( - table_type* hashTbl, - entry_type* elmt, - const label hashIndex - ); // Member functions/operators - //- Return non-const access to referenced object - inline reference object() const; + //- Non-const access to referenced object + using Iterator<false>::object; - //- Return non-const access to referenced object - inline reference operator*() const; - inline reference operator()() const; + //- Non-const access to referenced object + inline reference operator*() const { return this->object(); } + inline reference operator()() const { return this->object(); } inline iterator& operator++(); inline iterator operator++(int); @@ -666,54 +797,111 @@ public: //- Forward iterator with const access class const_iterator : - public iterator_base + public Iterator<true> { - using entry_type = const hashedEntry; - public: + // Typedefs + using iterator_category = std::forward_iterator_tag; + using difference_type = this_type::difference_type; - // Public typedefs - using table_type = const this_type; - using value_type = const this_type::value_type; - using pointer = this_type::const_pointer; - using reference = this_type::const_reference; + using key_type = this_type::key_type; + using mapped_type = const this_type::mapped_type; + using value_type = const this_type::value_type; + using pointer = this_type::const_pointer; + using reference = this_type::const_reference; // Constructors //- Construct null (end iterator) - inline const_iterator(); - - //- Construct from begin of hash-table - inline explicit const_iterator(table_type* hashTbl); + inline const_iterator() {} + + //- Copy construct from similar access type + inline explicit const_iterator(const Iterator<true>& iter) + : + Iterator<true>(iter) + {} + + //- Copy construct from dissimilar access type + inline explicit const_iterator(const Iterator<false>& iter) + : + Iterator<true> + ( + static_cast<const Iterator<true>&>(iter) + ) + {} + + //- Implicit conversion from dissimilar access type + inline const_iterator(const iterator& iter) + : + const_iterator(reinterpret_cast<const const_iterator&>(iter)) + {} - //- Construct from hash table, element and hash index. - // Used by the hash-table find() method. - inline const_iterator - ( - table_type* hashTbl, - entry_type* elmt, - const label hashIndex - ); - - //- Copy construct from iterator - inline const_iterator(const iterator& iter); // Member functions/operators - //- Return const access to referenced object - inline reference object() const; + //- Const access to referenced object + using Iterator<true>::object; - //- Return const access to referenced object - inline reference operator*() const; - inline reference operator()() const; + //- Const access to referenced object + inline reference operator*() const { return this->object(); } + inline reference operator()() const { return this->object(); } inline const_iterator& operator++(); inline const_iterator operator++(int); + + // Assignment + + const_iterator& operator=(const const_iterator&) = default; + + // Allow assign from iterator to const_iterator + const_iterator& operator=(const iterator& iter) + { + return this->operator= + ( + reinterpret_cast<const const_iterator&>(iter) + ); + } }; //- Iterating over keys only + //- An iterator wrapper for returning a reference to the key + template<class Iter> + class key_iterator_base + : + public Iter + { + public: + using value_type = this_type::key_type; + using pointer = const Key*; + using reference = const Key&; + + //- Implicit conversion + inline key_iterator_base(const Iter& iter) + : + Iter(iter) + {} + + //- Return the key + inline reference operator*() const { return this->key(); } + inline reference operator()() const { return this->key(); } + + inline key_iterator_base& operator++() + { + this->increment(); + return *this; + } + + inline key_iterator_base operator++(int) + { + key_iterator_base iter(*this); + this->increment(); + return iter; + } + }; + + //- Forward iterator returning the key using key_iterator = key_iterator_base<iterator>; @@ -793,6 +981,7 @@ inline void Swap // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "HashTableI.H" +#include "HashTableIterI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C index d6d7bef31d7..059be27e3e0 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C @@ -36,6 +36,8 @@ defineTypeNameAndDebug(HashTableCore, 0); // Approximately labelMax/4 const Foam::label Foam::HashTableCore::maxTableSize(1L << (sizeof(label)*8-3)); +Foam::zero::null Foam::HashTableCore::zeroNullElement; + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // @@ -50,7 +52,7 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size) return maxTableSize; } - // Enforce power of two - makes for a very fast modulus. + // Enforce power of two for fast modulus in hash index calculations. // Use unsigned for these calculations. // // - The lower limit (8) is somewhat arbitrary, but if the hash table @@ -65,7 +67,8 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size) { return powerOfTwo; } - else if (size & (size-1)) // <- Modulus of i^2 + + if (size & (size-1)) // <- Modulus of i^2 { // Determine power-of-two. Brute-force is fast enough. while (powerOfTwo < size) @@ -75,10 +78,8 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size) return powerOfTwo; } - else - { - return size; - } + + return size; } diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H index 46cc0c3f463..76feeb2105f 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H @@ -40,6 +40,7 @@ SourceFiles #include "uLabel.H" #include "className.H" #include "nullObject.H" +#include "zero.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -77,20 +78,16 @@ struct HashTableCore template<class IteratorType, class TableType> inline static IteratorType iterator_begin(TableType& table); - //- Factory method to create a const iterator begin - template<class IteratorType, class TableType> - inline static IteratorType iterator_begin(const TableType& table); - //- Factory method to create a const iterator begin template<class IteratorType, class TableType> inline static IteratorType iterator_cbegin(const TableType& table); - //- Factory method to create a non-const iterator end + //- Factory method to return an iterator end // Simply reinterprets a NullObject as a hash-table iterator. template<class IteratorType> inline static const IteratorType& iterator_end(); - //- Factory method to create a const iterator cend + //- Factory method to return an iterator cend // Simply reinterprets a NullObject as a hash-table iterator. template<class IteratorType> inline static const IteratorType& iterator_cend(); @@ -116,6 +113,13 @@ struct HashTableCore inline const IteratorType& end() const; inline const IteratorType& cend() const; }; + + +protected: + + //- A static zero::null for dereferencing as a dummy HashSet element + static zero::null zeroNullElement; + }; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H index 8198e2e4c33..1e59a0baa5a 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H @@ -35,16 +35,6 @@ inline IteratorType Foam::HashTableCore::iterator_begin } -template<class IteratorType, class TableType> -inline IteratorType Foam::HashTableCore::iterator_begin -( - const TableType& table -) -{ - return IteratorType(table.begin()); -} - - template<class IteratorType, class TableType> inline IteratorType Foam::HashTableCore::iterator_cbegin ( diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index 50f0c42d1e7..27ac1340065 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -25,30 +25,14 @@ License #include "error.H" -// * * * * * * * * * * * * * Private Member Classes * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::hashedEntry::hashedEntry -( - const Key& key, - const T& obj, - hashedEntry* next -) -: - key_(key), - obj_(obj), - next_(next) -{} - - // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // template<class T, class Key, class Hash> inline Foam::label Foam::HashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const { - // size is power of two - this is the modulus - return Hash()(key) & (tableSize_ - 1); + // capacity is always a power of two - this is the modulus + return Hash()(key) & (capacity_ - 1); } @@ -57,21 +41,76 @@ Foam::HashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const template<class T, class Key, class Hash> inline Foam::label Foam::HashTable<T, Key, Hash>::capacity() const { - return tableSize_; + return capacity_; } template<class T, class Key, class Hash> inline Foam::label Foam::HashTable<T, Key, Hash>::size() const { - return nElmts_; + return size_; } template<class T, class Key, class Hash> inline bool Foam::HashTable<T, Key, Hash>::empty() const { - return !nElmts_; + return !size_; +} + + +template<class T, class Key, class Hash> +bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const +{ + if (size_) + { + return Iterator<true>(this, key).found(); + } + + return false; +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::iterator +Foam::HashTable<T, Key, Hash>::find +( + const Key& key +) +{ + if (size_) + { + return iterator(Iterator<false>(this, key)); + } + + return iterator(); +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::const_iterator +Foam::HashTable<T, Key, Hash>::find +( + const Key& key +) const +{ + return this->cfind(key); +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::const_iterator +Foam::HashTable<T, Key, Hash>::cfind +( + const Key& key +) const +{ + if (size_) + { + return const_iterator(Iterator<true>(this, key)); + } + + return const_iterator(); } @@ -82,7 +121,7 @@ inline bool Foam::HashTable<T, Key, Hash>::insert const T& obj ) { - return this->set(key, obj, true); + return this->set(key, obj, false); // No overwrite } @@ -93,7 +132,7 @@ inline bool Foam::HashTable<T, Key, Hash>::set const T& obj ) { - return this->set(key, obj, false); + return this->set(key, obj, true); // Overwrite } @@ -112,7 +151,7 @@ inline const T& Foam::HashTable<T, Key, Hash>::lookup const T& deflt ) const { - const_iterator iter = this->find(key); + const const_iterator iter(this->cfind(key)); return iter.found() ? iter.object() : deflt; } @@ -122,7 +161,7 @@ inline const T& Foam::HashTable<T, Key, Hash>::lookup template<class T, class Key, class Hash> inline T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key) { - iterator iter = this->find(key); + const iterator iter(this->find(key)); if (!iter.found()) { @@ -139,7 +178,7 @@ inline T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key) template<class T, class Key, class Hash> inline const T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key) const { - const_iterator iter = this->find(key); + const const_iterator iter(this->cfind(key)); if (!iter.found()) { @@ -156,14 +195,14 @@ inline const T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key) const template<class T, class Key, class Hash> inline T& Foam::HashTable<T, Key, Hash>::operator()(const Key& key) { - iterator iter = this->find(key); + const iterator iter(this->find(key)); if (iter.found()) { return iter.object(); } - this->insert(key, T()); + this->insert(key, mapped_type()); return find(key).object(); } @@ -175,7 +214,7 @@ inline T& Foam::HashTable<T, Key, Hash>::operator() const T& deflt ) { - iterator iter = this->find(key); + const iterator iter(this->find(key)); if (iter.found()) { @@ -198,412 +237,6 @@ inline const T& Foam::HashTable<T, Key, Hash>::operator() } -// * * * * * * * * * * * * * * * iterator base * * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::iterator_base::iterator_base() -: - entryPtr_(nullptr), - hashTable_(nullptr), - hashIndex_(0) -{} - - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::iterator_base::iterator_base -( - const table_type* hashTbl, - const entry_type* elmt, - const label hashIndex -) -: - entryPtr_(const_cast<entry_type*>(elmt)), - hashTable_(const_cast<table_type*>(hashTbl)), - hashIndex_(hashIndex) -{} - - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::iterator_base::iterator_base -( - const table_type* hashTbl -) -: - entryPtr_(nullptr), - hashTable_(const_cast<table_type*>(hashTbl)), - hashIndex_(0) -{ - if (hashTable_ && hashTable_->nElmts_) - { - // find first non-nullptr table entry - while - ( - !(entryPtr_ = hashTable_->table_[hashIndex_]) - && ++hashIndex_ < hashTable_->tableSize_ - ) - {} - - if (hashIndex_ >= hashTable_->tableSize_) - { - // make into an end iterator - entryPtr_ = nullptr; - hashIndex_ = 0; - } - } -} - - -template<class T, class Key, class Hash> -inline void -Foam::HashTable<T, Key, Hash>::iterator_base::increment() -{ - // A negative index is a special value from erase - if (hashIndex_ < 0) - { - // the markPos='-curPos-1', but we wish to continue at 'curPos-1' - // thus use '-(markPos+1) -1' - hashIndex_ = -(hashIndex_+1) - 1; - } - else if (entryPtr_) - { - if (entryPtr_->next_) - { - // Move to next element on the SLList - entryPtr_ = entryPtr_->next_; - return; - } - } - // else - // { - // // if we reach here (entryPtr_ is nullptr) it is already at the end() - // // we should probably stop - // } - - - // Step to the next table entry - while - ( - ++hashIndex_ < hashTable_->tableSize_ - && !(entryPtr_ = hashTable_->table_[hashIndex_]) - ) - {} - - if (hashIndex_ >= hashTable_->tableSize_) - { - // make into an end iterator - entryPtr_ = nullptr; - hashIndex_ = 0; - } -} - - -template<class T, class Key, class Hash> -inline bool -Foam::HashTable<T, Key, Hash>::iterator_base::found() const -{ - return entryPtr_; -} - - -template<class T, class Key, class Hash> -inline const Key& Foam::HashTable<T, Key, Hash>::iterator_base::key() const -{ - return entryPtr_->key_; -} - - -template<class T, class Key, class Hash> -inline T& Foam::HashTable<T, Key, Hash>::iterator_base::element() const -{ - return entryPtr_->obj_; -} - - -template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::iterator_base::operator== -( - const iterator_base& iter -) const -{ - return entryPtr_ == iter.entryPtr_; -} - - -template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::iterator_base::operator!= -( - const iterator_base& iter -) const -{ - return entryPtr_ != iter.entryPtr_; -} - - -// * * * * * * * * * * * * * * key iterator base * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -template<class WrappedIterator> -inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator> -::key_iterator_base -( - const WrappedIterator& iter -) -: - WrappedIterator(iter) -{} - - -template<class T, class Key, class Hash> -template<class WrappedIterator> -inline const Key& -Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator> -::operator*() const -{ - return this->key(); -} - - -template<class T, class Key, class Hash> -template<class WrappedIterator> -inline const Key& -Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator> -::operator()() const -{ - return this->key(); -} - - -template<class T, class Key, class Hash> -template<class WrappedIterator> -inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>& -Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator> -::operator++() -{ - this->increment(); - return *this; -} - - -template<class T, class Key, class Hash> -template<class WrappedIterator> -inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator> -Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator> -::operator++(int) -{ - key_iterator_base old = *this; - this->increment(); - return old; -} - - -// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::iterator::iterator() -: - iterator_base() -{} - - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::iterator::iterator -( - table_type* hashTbl -) -: - iterator_base(hashTbl) -{} - - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::iterator::iterator -( - table_type* hashTbl, - entry_type* elmt, - const label hashIndex -) -: - iterator_base(hashTbl, elmt, hashIndex) -{} - - -template<class T, class Key, class Hash> -inline T& -Foam::HashTable<T, Key, Hash>::iterator::object() const -{ - return this->element(); -} - - -template<class T, class Key, class Hash> -inline T& -Foam::HashTable<T, Key, Hash>::iterator::operator*() const -{ - return this->object(); -} - - -template<class T, class Key, class Hash> -inline T& -Foam::HashTable<T, Key, Hash>::iterator::operator()() const -{ - return this->object(); -} - - -template<class T, class Key, class Hash> -inline typename Foam::HashTable<T, Key, Hash>::iterator& -Foam::HashTable<T, Key, Hash>::iterator::operator++() -{ - this->increment(); - return *this; -} - - -template<class T, class Key, class Hash> -inline typename Foam::HashTable<T, Key, Hash>::iterator -Foam::HashTable<T, Key, Hash>::iterator::operator++(int) -{ - iterator old = *this; - this->increment(); - return old; -} - - -// * * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator() -: - iterator_base() -{} - - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator -( - const HashTable<T, Key, Hash>::iterator& iter -) -: - iterator_base(iter) -{} - - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator -( - table_type* hashTbl -) -: - iterator_base(hashTbl) -{} - - -template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator -( - table_type* hashTbl, - entry_type* elmt, - const label hashIndex -) -: - iterator_base(hashTbl, elmt, hashIndex) -{} - - -template<class T, class Key, class Hash> -inline const T& -Foam::HashTable<T, Key, Hash>::const_iterator::object() const -{ - return this->element(); -} - - -template<class T, class Key, class Hash> -inline const T& -Foam::HashTable<T, Key, Hash>::const_iterator::operator*() const -{ - return this->object(); -} - - -template<class T, class Key, class Hash> -inline const T& -Foam::HashTable<T, Key, Hash>::const_iterator::operator()() const -{ - return this->object(); -} - - -template<class T, class Key, class Hash> -inline typename Foam::HashTable<T, Key, Hash>::const_iterator& -Foam::HashTable<T, Key, Hash>::const_iterator::operator++() -{ - this->increment(); - return *this; -} - - -template<class T, class Key, class Hash> -inline typename Foam::HashTable<T, Key, Hash>::const_iterator -Foam::HashTable<T, Key, Hash>::const_iterator::operator++(int) -{ - const_iterator old = *this; - this->increment(); - return old; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -inline typename Foam::HashTable<T, Key, Hash>::iterator -Foam::HashTable<T, Key, Hash>::begin() -{ - return iterator(this); -} - - -template<class T, class Key, class Hash> -inline typename Foam::HashTable<T, Key, Hash>::const_iterator -Foam::HashTable<T, Key, Hash>::begin() const -{ - return const_iterator(this); -} - - -template<class T, class Key, class Hash> -inline typename Foam::HashTable<T, Key, Hash>::const_iterator -Foam::HashTable<T, Key, Hash>::cbegin() const -{ - return const_iterator(this); -} - - -template<class T, class Key, class Hash> -inline const typename Foam::HashTable<T, Key, Hash>::iterator& -Foam::HashTable<T, Key, Hash>::end() -{ - return iterator_end<iterator>(); -} - - -template<class T, class Key, class Hash> -inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& -Foam::HashTable<T, Key, Hash>::end() const -{ - return iterator_end<const_iterator>(); -} - - -template<class T, class Key, class Hash> -inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& -Foam::HashTable<T, Key, Hash>::cend() const -{ - return iterator_cend<const_iterator>(); -} - - // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // template<class T, class Key, class Hash> diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C index 54cd7ed9220..34392da5ee4 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C @@ -33,17 +33,17 @@ template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable(Istream& is, const label size) : HashTableCore(), - nElmts_(0), - tableSize_(HashTableCore::canonicalSize(size)), + size_(0), + capacity_(HashTableCore::canonicalSize(size)), table_(nullptr) { - if (tableSize_) + if (capacity_) { - table_ = new hashedEntry*[tableSize_]; + table_ = new node_type*[capacity_]; - for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx) + for (label i=0; i < capacity_; ++i) { - table_[hashIdx] = nullptr; + table_[i] = nullptr; } } @@ -60,10 +60,10 @@ Foam::Ostream& Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const label maxChain = 0; unsigned avgChain = 0; - for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx) + for (label i=0; i < capacity_; ++i) { label count = 0; - for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) + for (node_type* ep = table_[i]; ep; ep = ep->next_) { ++count; } @@ -81,7 +81,7 @@ Foam::Ostream& Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const } os << "HashTable<T,Key,Hash>" - << " elements:" << size() << " slots:" << used << "/" << tableSize_ + << " elements:" << size() << " slots:" << used << "/" << capacity_ << " chaining(avg/max):" << (used ? (float(avgChain)/used) : 0) << "/" << maxChain << endl; @@ -145,7 +145,7 @@ Foam::Istream& Foam::operator>> { is.fatalCheck(FUNCTION_NAME); - // Anull list + // Anull existing table L.clear(); is.fatalCheck(FUNCTION_NAME); @@ -154,7 +154,7 @@ Foam::Istream& Foam::operator>> is.fatalCheck ( - "operator>>(Istream&, HashTable<T, Key, Hash>&) : " + "operator>>(Istream&, HashTable&) : " "reading first token" ); @@ -163,11 +163,11 @@ Foam::Istream& Foam::operator>> const label s = firstToken.labelToken(); // Read beginning of contents - const char delimiter = is.readBeginList("HashTable<T, Key, Hash>"); + const char delimiter = is.readBeginList("HashTable"); if (s) { - if (2*s > L.tableSize_) + if (2*s > L.capacity_) { L.resize(2*s); } @@ -182,7 +182,7 @@ Foam::Istream& Foam::operator>> is.fatalCheck ( - "operator>>(Istream&, HashTable<T, Key, Hash>&) : " + "operator>>(Istream&, HashTable&) : " "reading entry" ); } @@ -224,15 +224,11 @@ Foam::Istream& Foam::operator>> Key key; is >> key; - - T element; - is >> element; - - L.insert(key, element); + L.insert(key, pTraits<T>(is)); is.fatalCheck ( - "operator>>(Istream&, HashTable<T, Key, Hash>&) : " + "operator>>(Istream&, HashTable&) : " "reading entry" ); @@ -262,20 +258,27 @@ Foam::Ostream& Foam::operator<< const HashTable<T, Key, Hash>& tbl ) { - using const_iterator = typename HashTable<T, Key, Hash>::const_iterator; + const label sz = tbl.size(); - // Write size and start delimiter - os << nl << tbl.size() << nl << token::BEGIN_LIST << nl; + if (sz) + { + // Size and start list delimiter + os << nl << sz << nl << token::BEGIN_LIST << nl; - // Write contents - for (const_iterator iter = tbl.cbegin(); iter != tbl.cend(); ++iter) + // Contents + for (auto iter = tbl.cbegin(); iter != tbl.cend(); ++iter) + { + os << iter.key() << token::SPACE << iter.object() << nl; + } + + os << token::END_LIST; // End list delimiter + } + else { - os << iter.key() << token::SPACE << iter.object() << nl; + // Empty hash table + os << sz << token::BEGIN_LIST << token::END_LIST; } - // Write end delimiter - os << token::END_LIST; - os.check(FUNCTION_NAME); return os; } diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIter.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIter.C new file mode 100644 index 00000000000..9a1b792fcab --- /dev/null +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIter.C @@ -0,0 +1,123 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class T, class Key, class Hash> +template<bool Const> +Foam::HashTable<T, Key, Hash>::Iterator<Const>::Iterator +( + table_type* tbl, + const Key& key +) +: + entry_(nullptr), + container_(tbl), + index_(0) +{ + if (tbl->size()) + { + const label index = container_->hashKeyIndex(key); + + for (node_type* ep = container_->table_[index]; ep; ep = ep->next_) + { + if (key == ep->key()) + { + entry_ = ep; + index_ = index; + break; + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// +// Any changes here may need changes in the iterator increment() method +// +template<class T, class Key, class Hash> +bool Foam::HashTable<T, Key, Hash>::iterator_erase +( + node_type*& entry, + label& index +) +{ + // Safeguard against the following: + // - empty table + // - nullptr entry + // - end iterator (which is also a nullptr) + // - negative index from a previous erase. See comment below. + if (!size_ || !entry || index < 0) + { + return false; + } + + // Decrease count + size_--; + + // The previous element in the singly linked list + node_type* prev = nullptr; + + for (node_type* ep = table_[index]; ep; ep = ep->next_) + { + if (ep == entry) + { + break; + } + prev = ep; + } + + if (prev) + { + // Had previous element in linked list - reposition to there + prev->next_ = entry->next_; + delete entry; + entry = prev; + + return true; + } + + // Was first element on linked list + table_[index] = entry->next_; + delete entry; + + // Assign any non-nullptr value so it doesn't look like end() + entry = reinterpret_cast<node_type*>(this); + + // Mark the present index to continue and bring it back to the present + // location with the next index. + // + // Save: (-index-1), which has no ambiguity for index 0. + // Retrieve: (-(index+1)) + + index = (-index - 1); + + return true; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H new file mode 100644 index 00000000000..cc85a8b9140 --- /dev/null +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H @@ -0,0 +1,263 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * iterator base * * * * * * * * * * * * * * * // + +template<class T, class Key, class Hash> +template<bool Const> +inline Foam::HashTable<T, Key, Hash>::Iterator<Const>::Iterator() +: + entry_(nullptr), + container_(nullptr), + index_(0) +{} + + +template<class T, class Key, class Hash> +template<bool Const> +inline Foam::HashTable<T, Key, Hash>::Iterator<Const>::Iterator +( + bool, // Future use and to avoid implicit construct + table_type* tbl +) +: + entry_(nullptr), + container_(tbl), + index_(0) +{ + if (container_ && container_->size_) + { + // Locate the first non-nullptr table entry + while + ( + !(entry_ = container_->table_[index_]) + && ++index_ < container_->capacity_ + ) + {} + + if (index_ >= container_->capacity_) + { + // Nothing found - make it an end iterator + entry_ = nullptr; + index_ = 0; + } + } +} + + +// +// Any changes here may need changes in iterator_erase() method too +// +template<class T, class Key, class Hash> +template<bool Const> +inline void +Foam::HashTable<T, Key, Hash>::Iterator<Const>::increment() +{ + if (index_ < 0) + { + // Negative index is a special value from erase + // + // Saved as (-index-1), retrieved as (-(index-1)) but to with an + // extra (-1) to compensate for the ++ in the following while loop + index_ = -(index_+1) - 1; + } + else if (index_ < container_->capacity_ && entry_ && entry_->next_) + { + // Move to next element on the linked-list + entry_ = entry_->next_; + return; + } + + // Move to the next non-nullptr table entry + while + ( + ++index_ < container_->capacity_ + && !(entry_ = container_->table_[index_]) + ) + {} + + if (index_ >= container_->capacity_) + { + // Nothing found - make it an end iterator + entry_ = nullptr; + index_ = 0; + } +} + + +template<class T, class Key, class Hash> +template<bool Const> +inline bool +Foam::HashTable<T, Key, Hash>::Iterator<Const>::found() const +{ + return entry_; +} + + +template<class T, class Key, class Hash> +template<bool Const> +inline const Key& Foam::HashTable<T, Key, Hash>::Iterator<Const>::key() const +{ + return entry_->key(); +} + + +template<class T, class Key, class Hash> +template<bool Const> +inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator== +( + const Iterator<true>& iter +) const +{ + return entry_ == iter.entry_; +} + + +template<class T, class Key, class Hash> +template<bool Const> +inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator!= +( + const Iterator<true>& iter +) const +{ + return entry_ != iter.entry_; +} + + +template<class T, class Key, class Hash> +template<bool Const> +inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator== +( + const Iterator<false>& iter +) const +{ + return entry_ == iter.entry_; +} + + +template<class T, class Key, class Hash> +template<bool Const> +inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator!= +( + const Iterator<false>& iter +) const +{ + return entry_ != iter.entry_; +} + + +// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * // + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::iterator& +Foam::HashTable<T, Key, Hash>::iterator::operator++() +{ + this->increment(); + return *this; +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::iterator +Foam::HashTable<T, Key, Hash>::iterator::operator++(int) +{ + iterator iter(*this); + this->increment(); + return iter; +} + + +// * * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * // + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::const_iterator& +Foam::HashTable<T, Key, Hash>::const_iterator::operator++() +{ + this->increment(); + return *this; +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::const_iterator +Foam::HashTable<T, Key, Hash>::const_iterator::operator++(int) +{ + const_iterator iter(*this); + this->increment(); + return iter; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::iterator +Foam::HashTable<T, Key, Hash>::begin() +{ + return iterator(Iterator<false>(true, this)); +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::const_iterator +Foam::HashTable<T, Key, Hash>::begin() const +{ + return const_iterator(Iterator<true>(true, this)); +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::const_iterator +Foam::HashTable<T, Key, Hash>::cbegin() const +{ + return const_iterator(Iterator<true>(true, this)); +} + + +template<class T, class Key, class Hash> +inline const typename Foam::HashTable<T, Key, Hash>::iterator& +Foam::HashTable<T, Key, Hash>::end() +{ + return iterator_end<iterator>(); +} + + +template<class T, class Key, class Hash> +inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& +Foam::HashTable<T, Key, Hash>::end() const +{ + return iterator_cend<const_iterator>(); +} + + +template<class T, class Key, class Hash> +inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& +Foam::HashTable<T, Key, Hash>::cend() const +{ + return iterator_cend<const_iterator>(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H index e862ff97e39..784a123a74f 100644 --- a/src/OpenFOAM/containers/HashTables/Map/Map.H +++ b/src/OpenFOAM/containers/HashTables/Map/Map.H @@ -27,6 +27,11 @@ Class Description A HashTable to objects of type \<T\> with a label key. +Note + The Map contents are unordered. + When the key order is important, use the sortedToc() method to obtain + a list of sorted keys and use that for further access. + See also PtrMap @@ -65,13 +70,19 @@ public: // Constructors - //- Construct given initial size - Map(const label size = 128) + //- Construct null with default table size + Map() + : + parent_type() + {} + + //- Construct with given table size + explicit Map(const label size) : parent_type(size) {} - //- Construct from Istream + //- Construct from Istream with default table size Map(Istream& is) : parent_type(is) @@ -96,7 +107,7 @@ public: {} //- Construct by transferring the parameter contents - Map(const Xfer<HashTable<T, label, Hash<label>>>& map) + Map(const Xfer<parent_type>& map) : parent_type(map) {} diff --git a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H index 178bc670989..4e86e1aae92 100644 --- a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H +++ b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H @@ -62,8 +62,14 @@ public: // Constructors + //- Construct null with default table size + PtrMap() + : + parent_type() + {} + //- Construct given initial map size - PtrMap(const label size = 128) + explicit PtrMap(const label size) : parent_type(size) {} -- GitLab From 46e85436535e7689cfe9077d310c9662402ffab0 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 1 Nov 2017 17:46:12 +0000 Subject: [PATCH 081/126] ENH: cell cutting: less verbose. Allow cutting single face. See #631. --- src/dynamicMesh/meshCut/cellCuts/cellCuts.C | 220 +++++++++++++------- src/dynamicMesh/meshCut/cellCuts/cellCuts.H | 23 +- 2 files changed, 155 insertions(+), 88 deletions(-) diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C index 98347f981bb..32e36d279c7 100644 --- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C +++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -596,9 +596,12 @@ void Foam::cellCuts::calcFaceCuts() const if (allVerticesCut) { - WarningInFunction - << "Face " << facei << " vertices " << f - << " has all its vertices cut. Not cutting face." << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Face " << facei << " vertices " << f + << " has all its vertices cut. Not cutting face." << endl; + } cutI = 0; } @@ -808,13 +811,17 @@ bool Foam::cellCuts::addCut labelList truncVisited(visited); truncVisited.setSize(nVisited); - Pout<< "For cell " << celli << " : trying to add duplicate cut " << cut; - labelList cuts(1, cut); - writeCuts(Pout, cuts, loopWeights(cuts)); + if (verbose_ || debug) + { + Pout<< "For cell " << celli << " : trying to add duplicate cut " + << cut; + labelList cuts(1, cut); + writeCuts(Pout, cuts, loopWeights(cuts)); - Pout<< " to path:"; - writeCuts(Pout, truncVisited, loopWeights(truncVisited)); - Pout<< endl; + Pout<< " to path:"; + writeCuts(Pout, truncVisited, loopWeights(truncVisited)); + Pout<< endl; + } return false; } @@ -905,9 +912,12 @@ bool Foam::cellCuts::walkFace } else { - WarningInFunction - << "In middle of cut. cell:" << celli << " face:" << facei - << " cuts:" << fCuts << " current cut:" << cut << endl; + if (verbose_ || debug) + { + WarningInFunction + << "In middle of cut. cell:" << celli << " face:" << facei + << " cuts:" << fCuts << " current cut:" << cut << endl; + } return false; } @@ -1163,7 +1173,7 @@ void Foam::cellCuts::calcCellLoops(const labelList& cutCells) bool validLoop = false; // Quick rejection: has enough faces that are cut? - if (nCutFaces[celli] >= 3) + if (nCutFaces[celli] >= 1) { const labelList& cFaces = mesh().cells()[celli]; @@ -1249,11 +1259,14 @@ void Foam::cellCuts::calcCellLoops(const labelList& cutCells) { // Invalid loop. Leave cellLoops_[celli] zero size which // flags this. - Pout<< "calcCellLoops(const labelList&) : did not find valid" - << " loop for cell " << celli << endl; - // Dump cell and cuts on cell. - writeUncutOBJ(".", celli); - + if (verbose_ || debug) + { + Pout<< "calcCellLoops(const labelList&) :" + << " did not find valid" + << " loop for cell " << celli << endl; + // Dump cell and cuts on cell. + writeUncutOBJ(".", celli); + } cellLoops_[celli].setSize(0); } } @@ -1427,12 +1440,15 @@ bool Foam::cellCuts::calcAnchors if (uncutIndex == -1) { - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli << endl - << "Can not find point on cell which is not cut by loop." - << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " << celli << endl + << "Can not find point on cell which is not cut by loop." + << endl; - writeOBJ(".", celli, loopPts, labelList(0)); + writeOBJ(".", celli, loopPts, labelList(0)); + } return false; } @@ -1447,12 +1463,15 @@ bool Foam::cellCuts::calcAnchors { // All vertices either in loop or in anchor. So split is along single // face. - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli << endl - << "All vertices of cell are either in loop or in anchor set" - << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " << celli << endl + << "All vertices of cell are either in loop or in anchor set" + << endl; - writeOBJ(".", celli, loopPts, labelList(0)); + writeOBJ(".", celli, loopPts, labelList(0)); + } return false; } @@ -1484,11 +1503,14 @@ bool Foam::cellCuts::calcAnchors if (uncutIndex != -1) { - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli - << " since it splits the cell into more than two cells" << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " << celli + << " since it splits the cell into more than two cells" << endl; - writeOBJ(".", celli, loopPts, connectedPoints); + writeOBJ(".", celli, loopPts, connectedPoints); + } return false; } @@ -1528,24 +1550,30 @@ bool Foam::cellCuts::calcAnchors if (connectedFaces.size() < 3) { - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli - << " since would have too few faces on one side." << nl - << "All faces:" << cFaces << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " << celli + << " since would have too few faces on one side." << nl + << "All faces:" << cFaces << endl; - writeOBJ(".", celli, loopPts, connectedPoints); + writeOBJ(".", celli, loopPts, connectedPoints); + } return false; } if (otherFaces.size() < 3) { - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli - << " since would have too few faces on one side." << nl - << "All faces:" << cFaces << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " << celli + << " since would have too few faces on one side." << nl + << "All faces:" << cFaces << endl; - writeOBJ(".", celli, loopPts, otherPoints); + writeOBJ(".", celli, loopPts, otherPoints); + } return false; } @@ -1584,13 +1612,16 @@ bool Foam::cellCuts::calcAnchors if (hasSet1) { // Second occurence of set1. - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli - << " since face " << f << " would be split into" - << " more than two faces" << endl; - - writeOBJ(".", celli, loopPts, otherPoints); + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " + << celli + << " since face " << f << " would be split into" + << " more than two faces" << endl; + writeOBJ(".", celli, loopPts, otherPoints); + } return false; } @@ -1601,13 +1632,16 @@ bool Foam::cellCuts::calcAnchors if (hasSet2) { // Second occurence of set1. - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli - << " since face " << f << " would be split into" - << " more than two faces" << endl; - - writeOBJ(".", celli, loopPts, otherPoints); + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " + << celli + << " since face " << f << " would be split into" + << " more than two faces" << endl; + writeOBJ(".", celli, loopPts, otherPoints); + } return false; } @@ -1639,12 +1673,16 @@ bool Foam::cellCuts::calcAnchors if (hasSet1) { // Second occurence of set1. - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli - << " since face " << f << " would be split into" - << " more than two faces" << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " + << celli + << " since face " << f << " would be split into" + << " more than two faces" << endl; - writeOBJ(".", celli, loopPts, otherPoints); + writeOBJ(".", celli, loopPts, otherPoints); + } return false; } @@ -1656,13 +1694,16 @@ bool Foam::cellCuts::calcAnchors if (hasSet2) { // Second occurence of set1. - WarningInFunction - << "Invalid loop " << loop << " for cell " << celli - << " since face " << f << " would be split into" - << " more than two faces" << endl; - - writeOBJ(".", celli, loopPts, otherPoints); + if (verbose_ || debug) + { + WarningInFunction + << "Invalid loop " << loop << " for cell " + << celli + << " since face " << f << " would be split into" + << " more than two faces" << endl; + writeOBJ(".", celli, loopPts, otherPoints); + } return false; } @@ -2083,9 +2124,12 @@ bool Foam::cellCuts::validLoop if (faceContainingLoop != -1) { - WarningInFunction - << "Found loop on cell " << celli << " with all points" - << " on face " << faceContainingLoop << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Found loop on cell " << celli << " with all points" + << " on face " << faceContainingLoop << endl; + } //writeOBJ(".", celli, loopPoints(loop, loopWeights), labelList(0)); @@ -2137,12 +2181,14 @@ void Foam::cellCuts::setFromCellLoops() ) { //writeOBJ(".", celli, loopPoints(celli), anchorPoints); - - WarningInFunction - << "Illegal loop " << loop - << " when recreating cut-addressing" - << " from existing cellLoops for cell " << celli - << endl; + if (verbose_ || debug) + { + WarningInFunction + << "Illegal loop " << loop + << " when recreating cut-addressing" + << " from existing cellLoops for cell " << celli + << endl; + } cellLoops_[celli].setSize(0); cellAnchorPoints_[celli].setSize(0); @@ -2822,10 +2868,12 @@ Foam::cellCuts::cellCuts const labelList& cutCells, const labelList& meshVerts, const labelList& meshEdges, - const scalarField& meshEdgeWeights + const scalarField& meshEdgeWeights, + const bool verbose ) : edgeVertex(mesh), + verbose_(verbose), pointIsCut_(expand(mesh.nPoints(), meshVerts)), edgeIsCut_(expand(mesh.nEdges(), meshEdges)), edgeWeight_(expand(mesh.nEdges(), meshEdges, meshEdgeWeights)), @@ -2864,10 +2912,12 @@ Foam::cellCuts::cellCuts const polyMesh& mesh, const labelList& meshVerts, const labelList& meshEdges, - const scalarField& meshEdgeWeights + const scalarField& meshEdgeWeights, + const bool verbose ) : edgeVertex(mesh), + verbose_(verbose), pointIsCut_(expand(mesh.nPoints(), meshVerts)), edgeIsCut_(expand(mesh.nEdges(), meshEdges)), edgeWeight_(expand(mesh.nEdges(), meshEdges, meshEdgeWeights)), @@ -2911,10 +2961,12 @@ Foam::cellCuts::cellCuts const polyMesh& mesh, const labelList& cellLabels, const labelListList& cellLoops, - const List<scalarField>& cellEdgeWeights + const List<scalarField>& cellEdgeWeights, + const bool verbose ) : edgeVertex(mesh), + verbose_(verbose), pointIsCut_(mesh.nPoints(), false), edgeIsCut_(mesh.nEdges(), false), edgeWeight_(mesh.nEdges(), -GREAT), @@ -2956,10 +3008,12 @@ Foam::cellCuts::cellCuts ( const polyMesh& mesh, const cellLooper& cellCutter, - const List<refineCell>& refCells + const List<refineCell>& refCells, + const bool verbose ) : edgeVertex(mesh), + verbose_(verbose), pointIsCut_(mesh.nPoints(), false), edgeIsCut_(mesh.nEdges(), false), edgeWeight_(mesh.nEdges(), -GREAT), @@ -3002,10 +3056,12 @@ Foam::cellCuts::cellCuts const polyMesh& mesh, const cellLooper& cellCutter, const labelList& cellLabels, - const List<plane>& cutPlanes + const List<plane>& cutPlanes, + const bool verbose ) : edgeVertex(mesh), + verbose_(verbose), pointIsCut_(mesh.nPoints(), false), edgeIsCut_(mesh.nEdges(), false), edgeWeight_(mesh.nEdges(), -GREAT), @@ -3054,10 +3110,12 @@ Foam::cellCuts::cellCuts const Map<edge>& faceSplitCut, const labelListList& cellLoops, const label nLoops, - const labelListList& cellAnchorPoints + const labelListList& cellAnchorPoints, + const bool verbose ) : edgeVertex(mesh), + verbose_(verbose), pointIsCut_(pointIsCut), edgeIsCut_(edgeIsCut), edgeWeight_(edgeWeight), diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.H b/src/dynamicMesh/meshCut/cellCuts/cellCuts.H index 33760cdb9a3..90dbd212ff8 100644 --- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.H +++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.H @@ -112,6 +112,10 @@ class cellCuts { // Private data + //- Warn for illegal cuts + const bool verbose_; + + // Per point/edge status //- Is mesh point cut @@ -472,7 +476,8 @@ public: const labelList& cutCells, const labelList& meshVerts, const labelList& meshEdges, - const scalarField& meshEdgeWeights + const scalarField& meshEdgeWeights, + const bool verbose = true ); //- Construct from pattern of cuts. Detect cells to cut. @@ -481,7 +486,8 @@ public: const polyMesh& mesh, const labelList& meshVerts, const labelList& meshEdges, - const scalarField& meshEdgeWeights + const scalarField& meshEdgeWeights, + const bool verbose = true ); //- Construct from complete cellLoops through specified cells. @@ -492,7 +498,8 @@ public: const polyMesh& mesh, const labelList& cellLabels, const labelListList& cellLoops, - const List<scalarField>& cellEdgeWeights + const List<scalarField>& cellEdgeWeights, + const bool verbose = true ); //- Construct from list of cells to cut and direction to cut in @@ -501,7 +508,8 @@ public: ( const polyMesh& mesh, const cellLooper& cellCutter, - const List<refineCell>& refCells + const List<refineCell>& refCells, + const bool verbose = true ); //- Construct from list of cells to cut and plane to cut with and @@ -511,7 +519,8 @@ public: const polyMesh& mesh, const cellLooper& cellCutter, const labelList& cellLabels, - const List<plane>& cutPlanes + const List<plane>& cutPlanes, + const bool verbose = true ); //- Construct from components @@ -524,7 +533,8 @@ public: const Map<edge>& faceSplitCut, const labelListList& cellLoops, const label nLoops, - const labelListList& cellAnchorPoints + const labelListList& cellAnchorPoints, + const bool verbose = true ); @@ -630,7 +640,6 @@ public: //- debugging:Write edges of cell and loop void writeCellOBJ(const fileName& dir, const label celli) const; - }; -- GitLab From f5795afabae4e3331252728720af2fade25a2c1b Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Fri, 3 Nov 2017 11:09:17 +0000 Subject: [PATCH 082/126] STYLE: More use of constexpr for namespace variables --- src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H | 4 +-- .../mathematical/mathematicalConstants.H | 2 +- .../Scalar/doubleScalar/doubleScalar.H | 14 +++++----- .../Scalar/floatScalar/floatScalar.H | 14 +++++----- .../primitives/Scalar/scalar/scalar.H | 28 +++++++++---------- src/OpenFOAM/primitives/ints/label/label.H | 4 +-- src/OpenFOAM/primitives/ints/uLabel/uLabel.H | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index 916bae22787..c8eb66976f3 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -329,8 +329,8 @@ inline Ostream& endEntry(Ostream& os) // Useful aliases for tab and newline characters -static const char tab = '\t'; -static const char nl = '\n'; +constexpr char tab = '\t'; +constexpr char nl = '\n'; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H b/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H index c7faae1bd27..a7121751479 100644 --- a/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H +++ b/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H @@ -45,7 +45,7 @@ namespace mathematical // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - static const char* const group = "mathematical"; + constexpr const char* const group = "mathematical"; constexpr scalar e(M_E); constexpr scalar pi(M_PI); diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H index b7a0b8fd562..143245890e4 100644 --- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H +++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H @@ -51,13 +51,13 @@ typedef double doubleScalar; // Largest and smallest scalar values allowed in certain parts of the code. // (15 is the number of significant figures in an // IEEE double precision number. See limits.h or float.h) -static const doubleScalar doubleScalarGREAT = 1.0e+15; -static const doubleScalar doubleScalarVGREAT = 1.0e+300; -static const doubleScalar doubleScalarROOTVGREAT = 1.0e+150; -static const doubleScalar doubleScalarSMALL = 1.0e-15; -static const doubleScalar doubleScalarROOTSMALL = 3.0e-8; -static const doubleScalar doubleScalarVSMALL = 1.0e-300; -static const doubleScalar doubleScalarROOTVSMALL = 1.0e-150; +constexpr doubleScalar doubleScalarGREAT = 1.0e+15; +constexpr doubleScalar doubleScalarVGREAT = 1.0e+300; +constexpr doubleScalar doubleScalarROOTVGREAT = 1.0e+150; +constexpr doubleScalar doubleScalarSMALL = 1.0e-15; +constexpr doubleScalar doubleScalarROOTSMALL = 3.0e-8; +constexpr doubleScalar doubleScalarVSMALL = 1.0e-300; +constexpr doubleScalar doubleScalarROOTVSMALL = 1.0e-150; #define Scalar doubleScalar diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H index 07c8a4aa660..951de0f84fb 100644 --- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H +++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H @@ -51,13 +51,13 @@ typedef float floatScalar; // Largest and smallest scalar values allowed in certain parts of the code. // (6 is the number of significant figures in an // IEEE single precision number. See limits.h or float.h) -static const floatScalar floatScalarGREAT = 1.0e+6; -static const floatScalar floatScalarVGREAT = 1.0e+37; -static const floatScalar floatScalarROOTVGREAT = 1.0e+18; -static const floatScalar floatScalarSMALL = 1.0e-6; -static const floatScalar floatScalarROOTSMALL = 1.0e-3; -static const floatScalar floatScalarVSMALL = 1.0e-37; -static const floatScalar floatScalarROOTVSMALL = 1.0e-18; +constexpr floatScalar floatScalarGREAT = 1.0e+6; +constexpr floatScalar floatScalarVGREAT = 1.0e+37; +constexpr floatScalar floatScalarROOTVGREAT = 1.0e+18; +constexpr floatScalar floatScalarSMALL = 1.0e-6; +constexpr floatScalar floatScalarROOTSMALL = 1.0e-3; +constexpr floatScalar floatScalarVSMALL = 1.0e-37; +constexpr floatScalar floatScalarROOTVSMALL = 1.0e-18; #define Scalar floatScalar diff --git a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H index e705dc8550a..33b7a61c18b 100644 --- a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H +++ b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H @@ -49,13 +49,13 @@ namespace Foam { typedef floatScalar scalar; - static const scalar GREAT = floatScalarGREAT; - static const scalar VGREAT = floatScalarVGREAT; - static const scalar ROOTVGREAT = floatScalarROOTVGREAT; - static const scalar SMALL = floatScalarSMALL; - static const scalar ROOTSMALL = floatScalarROOTSMALL; - static const scalar VSMALL = floatScalarVSMALL; - static const scalar ROOTVSMALL = floatScalarROOTVSMALL; + constexpr scalar GREAT = floatScalarGREAT; + constexpr scalar VGREAT = floatScalarVGREAT; + constexpr scalar ROOTVGREAT = floatScalarROOTVGREAT; + constexpr scalar SMALL = floatScalarSMALL; + constexpr scalar ROOTSMALL = floatScalarROOTSMALL; + constexpr scalar VSMALL = floatScalarVSMALL; + constexpr scalar ROOTVSMALL = floatScalarROOTVSMALL; scalar readScalar(Istream& is); @@ -73,13 +73,13 @@ namespace Foam { typedef doubleScalar scalar; - static const scalar GREAT = doubleScalarGREAT; - static const scalar VGREAT = doubleScalarVGREAT; - static const scalar ROOTVGREAT = doubleScalarROOTVGREAT; - static const scalar SMALL = doubleScalarSMALL; - static const scalar ROOTSMALL = doubleScalarROOTSMALL; - static const scalar VSMALL = doubleScalarVSMALL; - static const scalar ROOTVSMALL = doubleScalarROOTVSMALL; + constexpr scalar GREAT = doubleScalarGREAT; + constexpr scalar VGREAT = doubleScalarVGREAT; + constexpr scalar ROOTVGREAT = doubleScalarROOTVGREAT; + constexpr scalar SMALL = doubleScalarSMALL; + constexpr scalar ROOTSMALL = doubleScalarROOTSMALL; + constexpr scalar VSMALL = doubleScalarVSMALL; + constexpr scalar ROOTVSMALL = doubleScalarROOTVSMALL; scalar readScalar(Istream& is); diff --git a/src/OpenFOAM/primitives/ints/label/label.H b/src/OpenFOAM/primitives/ints/label/label.H index 08b4d1ff39c..11a862fd7cb 100644 --- a/src/OpenFOAM/primitives/ints/label/label.H +++ b/src/OpenFOAM/primitives/ints/label/label.H @@ -58,8 +58,8 @@ namespace Foam typedef INT_SIZE(int, _t) label; -static const label labelMin = INT_SIZE(INT, _MIN); -static const label labelMax = INT_SIZE(INT, _MAX); +constexpr label labelMin = INT_SIZE(INT, _MIN); +constexpr label labelMax = INT_SIZE(INT, _MAX); //- Read label from stream. // Uses readInt32 or readInt64 according to WM_LABEL_SIZE diff --git a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H index 9a8713f7338..afdf9f39e6c 100644 --- a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H +++ b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H @@ -58,7 +58,7 @@ namespace Foam typedef UINT_SIZE(uint, _t) uLabel; -static const uLabel uLabelMax = UINT_SIZE(UINT, _MAX); +constexpr uLabel uLabelMax = UINT_SIZE(UINT, _MAX); //- Read uLabel from stream. // Uses readUint32 or readUint64 according to WM_LABEL_SIZE -- GitLab From c5344c31617557307ad6c4ef0b0b3e0dbe319c52 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Fri, 3 Nov 2017 11:10:34 +0000 Subject: [PATCH 083/126] COMP: Resolved clang compiler error in transport model updates --- .../viscosityModels/Arrhenius/Arrhenius.H | 8 ++++---- .../viscosityModels/Arrhenius/Arrheniuss.C | 1 + .../viscosityModels/Arrhenius/makeArrheniusTypes.H | 14 +++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H index a3b973e6e69..57ed3f2a102 100644 --- a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H +++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H @@ -68,12 +68,12 @@ class Arrhenius dimensionedScalar Talpha_; //- Field used for as temperature - word fieldName_; + word fieldName_; //- Auto pointer for scalar field autoPtr<volScalarField> field_; - //- Refernce to mesh + //- Reference to mesh const fvMesh& mesh_; @@ -85,8 +85,8 @@ class Arrhenius public: -// //- Runtime type information - TypeName("Arrhenius"); + //- Runtime type information + TypeName("Arrhenius"); // Constructors diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C index a19e7fa585f..c150706d142 100644 --- a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C +++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C @@ -26,6 +26,7 @@ License #include "makeArrheniusTypes.H" #include "Arrhenius.H" + #include "BirdCarreau.H" #include "Casson.H" #include "CrossPowerLaw.H" diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H b/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H index 7be96ecefc8..242758ec597 100644 --- a/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H +++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H @@ -44,15 +44,15 @@ License ArrheniusType##visType, \ dictionary, \ ArrheniusType##visType \ - ); \ - \ - defineTemplateTypeNameAndDebugWithName \ - ( \ - ArrheniusType##visType, \ - #ArrheniusType"<"#visType">", \ - 0 \ ); \ } \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + viscosityModels::ArrheniusType##visType, \ + #ArrheniusType"<"#visType">", \ + 0 \ + ); \ } -- GitLab From 2ecfb3e9864d858b283487acc8544bfd40f2241c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 3 Nov 2017 14:43:33 +0100 Subject: [PATCH 084/126] CONFIG: update clang versions --- etc/bashrc | 2 +- etc/config.csh/compiler | 5 ++++- etc/config.sh/compiler | 5 ++++- etc/cshrc | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 597d5494d6c..dbe16c9d7a9 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -65,7 +65,7 @@ export WM_COMPILER_TYPE=system #- Compiler: # WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL -# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL | Cray +# | Clang | Clang3[8-9] | Gcc[45]0 | Icc | IccKNL | Cray export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH diff --git a/etc/config.csh/compiler b/etc/config.csh/compiler index 7494af8f452..fa9915788b8 100644 --- a/etc/config.csh/compiler +++ b/etc/config.csh/compiler @@ -82,7 +82,10 @@ case ThirdParty: set clang_version=llvm-3.9.1 breaksw case Clang40: - set clang_version=llvm-4.0.0 + set clang_version=llvm-4.0.1 + breaksw + case Clang50: + set clang_version=llvm-5.0.0 breaksw default: /bin/cat << UNKNOWN_COMPILER diff --git a/etc/config.sh/compiler b/etc/config.sh/compiler index cb45f303940..3a1aefd63f0 100644 --- a/etc/config.sh/compiler +++ b/etc/config.sh/compiler @@ -81,7 +81,10 @@ ThirdParty) clang_version=llvm-3.9.1 ;; Clang40) - clang_version=llvm-4.0.0 + clang_version=llvm-4.0.1 + ;; + Clang50) + clang_version=llvm-5.0.0 ;; *) /bin/cat << UNKNOWN_COMPILER 1>&2 diff --git a/etc/cshrc b/etc/cshrc index 7cefb2f3830..4b186c3fce3 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -61,7 +61,7 @@ setenv WM_COMPILER_TYPE system #- Compiler: # WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL -# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL | Cray +# | Clang | Clang3[8-9] | Gcc[45]0 | Icc | IccKNL | Cray setenv WM_COMPILER Gcc setenv WM_COMPILER_ARCH # defined but empty unsetenv WM_COMPILER_LIB_ARCH -- GitLab From 695716d5ccc314e19d09650b3deeafb723b5eaf3 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 9 Aug 2017 11:58:43 +0200 Subject: [PATCH 085/126] STYLE: use local variables in aliases/functions --- etc/config.sh/aliases | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases index 23b8b636e80..0543a09a708 100644 --- a/etc/config.sh/aliases +++ b/etc/config.sh/aliases @@ -72,10 +72,10 @@ alias run='cd $FOAM_RUN' unset -f wmRefresh 2>/dev/null wmRefresh() { - wmProjectDir=$WM_PROJECT_DIR - foamSettings=$FOAM_SETTINGS + local projectDir=$WM_PROJECT_DIR + local foamSettings=$FOAM_SETTINGS wmUnset - . $wmProjectDir/etc/bashrc $foamSettings + . $projectDir/etc/bashrc $foamSettings } @@ -84,12 +84,25 @@ wmRefresh() unset -f foamVersion 2>/dev/null foamVersion() { - if [ "$1" ]; then + if [ "$#" -gt 0 ] + then + local ver=$1 + shift + # The variable foamInstDir had meaning for older OpenFOAM versions foamInstDir=$FOAM_INST_DIR - wmUnset - . $foamInstDir/OpenFOAM-$1/etc/bashrc - foam - echo "Changed to OpenFOAM-$1" 1>&2 + if [ -f "$foamInstDir/OpenFOAM-$ver/etc/bashrc" ] + then + wmUnset + . $foamInstDir/OpenFOAM-$ver/etc/bashrc + unset foamInstDir + foam + echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2 + else + unset foamInstDir + echo "No OpenFOAM-$ver available" 1>&2 + echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2 + return 1 + fi else echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2 fi -- GitLab From 4fc4f49cef9a4b2ceda8804cd8ba68ec273581cd Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Wed, 9 Aug 2017 16:52:03 +0100 Subject: [PATCH 086/126] ENH: Updated fieldAverage FO windowing. See #525 When specifying the averaging data, a new `windowType` option is available, taking the values: - none: no windowing - approximate: past functionality (v1706 and earlier) - exact: exact moving average - will store and write (for restart) all fields in the window --- .../functionObjectList/functionObjectList.C | 3 +- .../field/fieldAverage/fieldAverage.C | 131 +++---- .../field/fieldAverage/fieldAverage.H | 31 +- .../fieldAverageItem/fieldAverageItem.C | 128 ++++++- .../fieldAverageItem/fieldAverageItem.H | 180 +++++---- .../fieldAverageItem/fieldAverageItemI.H | 212 +++++++++++ .../fieldAverageItem/fieldAverageItemIO.C | 62 ++- .../fieldAverageItemTemplates.C | 291 ++++++++++++++ .../fieldAverage/fieldAverageTemplates.C | 356 ++++++++++-------- 9 files changed, 1061 insertions(+), 333 deletions(-) create mode 100644 src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H create mode 100644 src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 0082266d5b0..56782ea6eef 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -579,9 +579,8 @@ bool Foam::functionObjectList::execute() } } } - // Force writing of state dictionary after function object execution - if (time_.outputTime()) + if (time_.writeTime()) { label oldPrecision = IOstream::precision_; IOstream::precision_ = 16; diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.C b/src/functionObjects/field/fieldAverage/fieldAverage.C index be75c66f09b..769775639b7 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.C +++ b/src/functionObjects/field/fieldAverage/fieldAverage.C @@ -44,21 +44,21 @@ namespace functionObjects void Foam::functionObjects::fieldAverage::resetFields() { - forAll(faItems_, i) + for (const fieldAverageItem& item : faItems_) { - if (faItems_[i].mean()) + if (item.mean()) { - if (obr().found(faItems_[i].meanFieldName())) + if (obr().found(item.meanFieldName())) { - obr().checkOut(*obr()[faItems_[i].meanFieldName()]); + obr().checkOut(*obr()[item.meanFieldName()]); } } - if (faItems_[i].prime2Mean()) + if (item.prime2Mean()) { - if (obr().found(faItems_[i].prime2MeanFieldName())) + if (obr().found(item.prime2MeanFieldName())) { - obr().checkOut(*obr()[faItems_[i].prime2MeanFieldName()]); + obr().checkOut(*obr()[item.prime2MeanFieldName()]); } } } @@ -67,25 +67,9 @@ void Foam::functionObjects::fieldAverage::resetFields() void Foam::functionObjects::fieldAverage::initialize() { - if (!totalIter_.size()) + for (fieldAverageItem& item : faItems_) { - totalIter_.setSize(faItems_.size(), 1); - } - - if (!totalTime_.size()) - { - totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue()); - } - else - { - // Check if totalTime_ has been set otherwise initialize - forAll(totalTime_, fieldi) - { - if (totalTime_[fieldi] < 0) - { - totalTime_[fieldi] = obr_.time().deltaTValue(); - } - } + item.restart(0, false); } resetFields(); @@ -93,28 +77,39 @@ void Foam::functionObjects::fieldAverage::initialize() Log << type() << " " << name() << ":" << nl; // Add mean fields to the field lists - forAll(faItems_, fieldi) + for (fieldAverageItem& item : faItems_) { - addMeanField<scalar>(fieldi); - addMeanField<vector>(fieldi); - addMeanField<sphericalTensor>(fieldi); - addMeanField<symmTensor>(fieldi); - addMeanField<tensor>(fieldi); + addMeanField<scalar>(item); + addMeanField<vector>(item); + addMeanField<sphericalTensor>(item); + addMeanField<symmTensor>(item); + addMeanField<tensor>(item); } // Add prime-squared mean fields to the field lists - forAll(faItems_, fieldi) + for (fieldAverageItem& item : faItems_) { - addPrime2MeanField<scalar, scalar>(fieldi); - addPrime2MeanField<vector, symmTensor>(fieldi); + addPrime2MeanField<scalar, scalar>(item); + addPrime2MeanField<vector, symmTensor>(item); } - forAll(faItems_, fieldi) + // Add window fields to the field lists + for (const fieldAverageItem& item : faItems_) + { + restoreWindowFields<scalar>(item); + restoreWindowFields<vector>(item); + restoreWindowFields<sphericalTensor>(item); + restoreWindowFields<symmTensor>(item); + restoreWindowFields<tensor>(item); + } + + + for (const fieldAverageItem& item : faItems_) { - if (!faItems_[fieldi].active()) + if (!item.active()) { WarningInFunction - << "Field " << faItems_[fieldi].fieldName() + << "Field " << item.fieldName() << " not found in database for averaging"; } } @@ -133,8 +128,10 @@ void Foam::functionObjects::fieldAverage::restart() << obr().time().timeOutputValue() << nl << endl; - totalIter_.clear(); - totalTime_.clear(); + for (fieldAverageItem& item : faItems_) + { + item.restart(0, true); + } initialize(); } @@ -180,6 +177,17 @@ void Foam::functionObjects::fieldAverage::calcAverages() Log << type() << " " << name() << " write:" << nl << " Calculating averages" << nl; + forAll(faItems_, fieldi) + { + faItems_[fieldi].evolve(obr()); + } + + storeWindowFields<scalar>(); + storeWindowFields<vector>(); + storeWindowFields<sphericalTensor>(); + storeWindowFields<symmTensor>(); + storeWindowFields<tensor>(); + addMeanSqrToPrime2Mean<scalar, scalar>(); addMeanSqrToPrime2Mean<vector, symmTensor>(); @@ -192,12 +200,6 @@ void Foam::functionObjects::fieldAverage::calcAverages() calculatePrime2MeanFields<scalar, scalar>(); calculatePrime2MeanFields<vector, symmTensor>(); - forAll(faItems_, fieldi) - { - totalIter_[fieldi]++; - totalTime_[fieldi] += obr().time().deltaTValue(); - } - Log << endl; } @@ -218,28 +220,17 @@ void Foam::functionObjects::fieldAverage::writeAverages() const void Foam::functionObjects::fieldAverage::writeAveragingProperties() { - forAll(faItems_, fieldi) + for (const fieldAverageItem& item : faItems_) { - const word& fieldName = faItems_[fieldi].fieldName(); - dictionary propsDict; - propsDict.add("totalIter", totalIter_[fieldi]); - propsDict.add("totalTime", totalTime_[fieldi]); - setProperty(fieldName, propsDict); + item.writeState(propsDict); + setProperty(item.fieldName(), propsDict); } } void Foam::functionObjects::fieldAverage::readAveragingProperties() { - totalIter_.clear(); - totalIter_.setSize(faItems_.size(), 1); - - // Initialize totalTime with negative values - // to indicate that it has not been set - totalTime_.clear(); - totalTime_.setSize(faItems_.size(), -1); - if (restartOnRestart_ || restartOnOutput_) { Info<< " Starting averaging at time " @@ -251,22 +242,20 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties() Info<< " Restarting averaging for fields:" << nl; - forAll(faItems_, fieldi) + for (fieldAverageItem& item : faItems_) { - const word& fieldName = faItems_[fieldi].fieldName(); + const word& fieldName = item.fieldName(); if (foundProperty(fieldName)) { dictionary fieldDict; getDict(fieldName, fieldDict); - - totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter")); - totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime")); + item.readState(fieldDict); scalar userTotalTime = - obr().time().timeToUserTime(totalTime_[fieldi]); + obr().time().timeToUserTime(item.totalTime()); Info<< " " << fieldName - << " iters = " << totalIter_[fieldi] + << " iters = " << item.totalIter() << " time = " << userTotalTime << nl; } else @@ -298,8 +287,6 @@ Foam::functionObjects::fieldAverage::fieldAverage restartTime_(GREAT), initialised_(false), faItems_(), - totalIter_(), - totalTime_(), periodIndex_(1) { read(dict); @@ -321,10 +308,10 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) // Make certain that the values are consistent with the defaults: initialised_ = false; restartOnRestart_ = false; - restartOnOutput_ = false; - periodicRestart_ = false; - restartPeriod_ = GREAT; - restartTime_ = GREAT; + restartOnOutput_ = false; + periodicRestart_ = false; + restartPeriod_ = GREAT; + restartTime_ = GREAT; Info<< type() << " " << name() << ":" << nl; diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.H b/src/functionObjects/field/fieldAverage/fieldAverage.H index e0de5ee6fbc..52a907a4051 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.H +++ b/src/functionObjects/field/fieldAverage/fieldAverage.H @@ -86,6 +86,7 @@ Usage mean on; prime2Mean on; base time; + windowType exact; window 10.0; windowName w1; } @@ -131,6 +132,7 @@ SourceFiles #define functionObjects_fieldAverage_H #include "fvMeshFunctionObject.H" +#include "FIFOStack.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -208,19 +210,19 @@ protected: //- Add mean average field to database template<class Type> - void addMeanFieldType(const label fieldi); + void addMeanFieldType(fieldAverageItem& item); //- Add mean average field to database template<class Type> - void addMeanField(const label fieldi); + void addMeanField(fieldAverageItem& item); //- Add prime-squared average field to database template<class Type1, class Type2> - void addPrime2MeanFieldType(const label fieldi); + void addPrime2MeanFieldType(fieldAverageItem& item); //- Add prime-squared average field to database template<class Type1, class Type2> - void addPrime2MeanField(const label fieldi); + void addPrime2MeanField(fieldAverageItem& item); // Calculation functions @@ -228,30 +230,33 @@ protected: //- Main calculation routine virtual void calcAverages(); - //- Calculate mean average fields - template<class Type> - void calculateMeanFieldType(const label fieldi) const; - //- Calculate mean average fields template<class Type> void calculateMeanFields() const; - //- Calculate prime-squared average fields - template<class Type1, class Type2> - void calculatePrime2MeanFieldType(const label fieldi) const; - //- Calculate prime-squared average fields template<class Type1, class Type2> void calculatePrime2MeanFields() const; //- Add mean-squared field value to prime-squared mean field template<class Type1, class Type2> - void addMeanSqrToPrime2MeanType(const label fieldi) const; + void addMeanSqrToPrime2MeanType(const fieldAverageItem& item) const; //- Add mean-squared field value to prime-squared mean field template<class Type1, class Type2> void addMeanSqrToPrime2Mean() const; + template<class Type> + void storeWindowFieldType(fieldAverageItem& item); + + template<class Type> + void storeWindowFields(); + + template<class Type> + void restoreWindowFieldsType(const fieldAverageItem& item); + + template<class Type> + void restoreWindowFields(const fieldAverageItem& item); // I-O diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C index f42858f1f69..d96261d7631 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,6 +32,7 @@ const Foam::word Foam::functionObjects::fieldAverageItem::EXT_MEAN "Mean" ); + const Foam::word Foam::functionObjects::fieldAverageItem::EXT_PRIME2MEAN ( "Prime2Mean" @@ -49,6 +50,18 @@ Foam::functionObjects::fieldAverageItem::baseTypeNames_ }; +const Foam::Enum +< + Foam::functionObjects::fieldAverageItem::windowType +> +Foam::functionObjects::fieldAverageItem::windowTypeNames_ +{ + { windowType::NONE, "none" }, + { windowType::APPROXIMATE, "approximate" }, + { windowType::EXACT, "exact" }, +}; + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::fieldAverageItem::fieldAverageItem() @@ -59,9 +72,15 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem() meanFieldName_("unknown"), prime2Mean_(0), prime2MeanFieldName_("unknown"), - base_(ITER), - window_(-1.0), - windowName_("") + base_(baseType::ITER), + totalIter_(0), + totalTime_(-1), + window_(-1), + windowName_(""), + windowType_(windowType::NONE), + + windowTimes_(), + windowFieldNames_() {} @@ -77,8 +96,14 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem prime2Mean_(faItem.prime2Mean_), prime2MeanFieldName_(faItem.prime2MeanFieldName_), base_(faItem.base_), + totalIter_(faItem.totalIter_), + totalTime_(faItem.totalTime_), window_(faItem.window_), - windowName_(faItem.windowName_) + windowName_(faItem.windowName_), + windowType_(faItem.windowType_), + + windowTimes_(faItem.windowTimes_), + windowFieldNames_(faItem.windowFieldNames_) {} @@ -88,6 +113,94 @@ Foam::functionObjects::fieldAverageItem::~fieldAverageItem() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::functionObjects::fieldAverageItem::addToWindow +( + const word& fieldName, + const scalar deltaT +) +{ + windowTimes_.push(deltaT); + windowFieldNames_.push(fieldName); +} + + +void Foam::functionObjects::fieldAverageItem::evolve(const objectRegistry& obr) +{ + totalIter_++; + totalTime_ += obr.time().deltaTValue(); + forAllIters(windowTimes_, timeIter) + { + timeIter() += obr.time().deltaTValue(); + } + + // Remove any fields that have passed out of the window + bool removeItem = true; + + while (removeItem && windowTimes_.size()) + { + removeItem = !(inWindow(windowTimes_.first())); + + if (removeItem) + { + windowTimes_.pop(); + const word fieldName = windowFieldNames_.pop(); + + //Info<< "evolve: removing field: " << fieldName << endl; + obr.checkOut(*obr[fieldName]); + } + } +} + + +void Foam::functionObjects::fieldAverageItem::restart +( + const scalar time0, + const bool override +) +{ + if (totalTime_ < 0 || override) + { + totalIter_ = 0; + totalTime_ = time0; + windowTimes_.clear(); + windowFieldNames_.clear(); + } +} + + +bool Foam::functionObjects::fieldAverageItem::readState(const dictionary& dict) +{ + dict.lookup("totalIter") >> totalIter_; + dict.lookup("totalTime") >> totalTime_; + + if (window_ > 0) + { + dict.lookup("windowTimes") >> windowTimes_; + dict.lookup("windowFieldNames") >> windowFieldNames_; + } + + return true; +} + + +void Foam::functionObjects::fieldAverageItem::writeState +( + dictionary& dict +) const +{ + dict.add("totalIter", totalIter_); + dict.add("totalTime", totalTime_); + + if (window_ > 0) + { + dict.add("windowTimes", windowTimes_); + dict.add("windowFieldNames", windowFieldNames_); + } +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // void Foam::functionObjects::fieldAverageItem::operator= @@ -111,8 +224,13 @@ void Foam::functionObjects::fieldAverageItem::operator= prime2Mean_ = rhs.prime2Mean_; prime2MeanFieldName_ = rhs.prime2MeanFieldName_; base_ = rhs.base_; + totalIter_ = rhs.totalIter_; + totalTime_ = rhs.totalTime_; window_ = rhs.window_; windowName_ = rhs.windowName_; + windowType_ = rhs.windowType_; + windowTimes_ = rhs.windowTimes_; + windowFieldNames_ = rhs.windowFieldNames_; } diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H index d683cafea7a..c54bc668668 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,12 +35,19 @@ Description base time; // iteration window 200; // optional averaging window windowName w1; // optional window name (default = "") + windowType approximate; // window type } \endverbatim The averaging window corresponds to the averaging interval (iters or time) If not specified, the averaging is over 'all iters/time' + Available window types: + - \c none : no windowing + - \c exact : exact windowing - additional files will be stored and written + - \c approximate : approximate variant that does not store/write additional + fields + SourceFiles fieldAverageItem.C fieldAverageItemIO.C @@ -52,6 +59,7 @@ SourceFiles #include "Enum.H" #include "Switch.H" +#include "FIFOStack.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,6 +69,7 @@ namespace Foam // Forward declaration of classes class Istream; class Ostream; +class objectRegistry; namespace functionObjects { @@ -88,13 +97,22 @@ public: //- Prime-squared average static const word EXT_PRIME2MEAN; + //- Enumeration defining the averaging base type - enum baseType + enum class baseType { ITER, TIME }; + //- Enumeration defining the averaging window type + enum class windowType + { + NONE, + APPROXIMATE, + EXACT + }; + private: @@ -124,12 +142,30 @@ private: //- Averaging base type baseType base_; + //- Total number of iterations item has been evolved + label totalIter_; + + //- Total time item has been evolved + scalar totalTime_; + //- Averaging window - defaults to -1 for 'all iters/time' scalar window_; //- Averaging window name - defaults to 'window' word windowName_; + //- Averaging window type + windowType windowType_; + + //- Averaging window type names + static const Enum<windowType> windowTypeNames_; + + //- List of window times (windowType = EXACT) + FIFOStack<scalar> windowTimes_; + + //- List of window field names (windowType = EXACT) + FIFOStack<word> windowFieldNames_; + public: @@ -154,86 +190,87 @@ public: // Access //- Return const access to the active flag - bool active() const - { - return active_; - } + inline bool active() const; //- Return non-const access to the active flag - bool& active() - { - return active_; - } + inline bool& active(); //- Return const access to the field name - const word& fieldName() const - { - return fieldName_; - } + inline const word& fieldName() const; //- Return const access to the mean flag - bool mean() const - { - return mean_; - } + inline bool mean() const; //- Return non-const access to the mean flag - bool& mean() - { - return mean_; - } + inline bool& mean(); //- Return const access to the mean field name - const word& meanFieldName() const - { - return meanFieldName_; - } + inline const word& meanFieldName() const; //- Return const access to the prime-squared mean flag - bool prime2Mean() const - { - return prime2Mean_; - } + inline bool prime2Mean() const; //- Return non-const access to the prime-squared mean flag - bool& prime2Mean() - { - return prime2Mean_; - } + inline bool& prime2Mean(); //- Return const access to the prime-squared mean field name - const word& prime2MeanFieldName() const - { - return prime2MeanFieldName_; - } + inline const word& prime2MeanFieldName() const; //- Return averaging base type name - const word base() const - { - return baseTypeNames_[base_]; - } - - //- Return true if base is ITER - bool iterBase() const - { - return base_ == ITER; - } - - //- Return true if base is time - bool timeBase() const - { - return base_ == TIME; - } - - scalar window() const - { - return window_; - } - - const word& windowName() const - { - return windowName_; - } + inline const word& base() const; + + //- Return the total number of iterations item has been evolved + inline label totalIter() const; + + //- Return the total time item has been evolved + inline scalar totalTime() const; + + //- Return the window length (iterations or seconds) + inline scalar window() const; + + //- Return the (optional) window name + inline const word& windowName() const; + + //- Return the list of window times (windowType = EXACT) + inline const FIFOStack<scalar>& windowTimes() const; + + //- Return the list of window field names (windowType = EXACT) + inline const FIFOStack<word>& windowFieldNames() const; + + //- Return the current time interval + inline scalar dt(const scalar deltaT) const; + + //- Return the total time interval + inline scalar Dt() const; + + //- Helper function to construct a window field name + inline word windowFieldName(const word& prefix) const; + + //- Return true if time is inside window (including boundaries) + inline bool inWindow(const scalar t) const; + + //- Add field to window + void addToWindow(const word& fieldName, const scalar deltaT); + + //- Evolve and update + void evolve(const objectRegistry& obr); + + //- Restart + void restart(const scalar time0, const bool override); + + //- Read state and re-initialise values + bool readState(const dictionary& dict); + + //- Write state for restart + void writeState(dictionary& dict) const; + + //- Calculate the mean field value + template<class Type> + bool calculateMeanField(const objectRegistry& obr) const; + + //- Calculate prime-squared average fields + template<class Type1, class Type2> + bool calculatePrime2MeanField(const objectRegistry& obr) const; // Member Operators @@ -257,8 +294,11 @@ public: && a.prime2Mean_ == b.prime2Mean_ && a.prime2MeanFieldName_ == b.prime2MeanFieldName_ && a.base_ == b.base_ + && a.totalIter_ == b.totalIter_ + && a.totalTime_ == b.totalTime_ && a.window_ == b.window_ - && a.windowName_ == b.windowName_; + && a.windowName_ == b.windowName_ + && a.windowType_ == b.windowType_; } friend bool operator!= @@ -285,6 +325,16 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "fieldAverageItemI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "fieldAverageItemTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H new file mode 100644 index 00000000000..b7426dd06ed --- /dev/null +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H @@ -0,0 +1,212 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + + +\*---------------------------------------------------------------------------*/ + + +bool Foam::functionObjects::fieldAverageItem::active() const +{ + return active_; +} + + +bool& Foam::functionObjects::fieldAverageItem::active() +{ + return active_; +} + + +const Foam::word& Foam::functionObjects::fieldAverageItem::fieldName() const +{ + return fieldName_; +} + + +bool Foam::functionObjects::fieldAverageItem::mean() const +{ + return mean_; +} + + +bool& Foam::functionObjects::fieldAverageItem::mean() +{ + return mean_; +} + + +const Foam::word& +Foam::functionObjects::fieldAverageItem::meanFieldName() const +{ + return meanFieldName_; +} + + +bool Foam::functionObjects::fieldAverageItem::prime2Mean() const +{ + return prime2Mean_; +} + + +bool& Foam::functionObjects::fieldAverageItem::prime2Mean() +{ + return prime2Mean_; +} + + +const Foam::word& Foam::functionObjects::fieldAverageItem::prime2MeanFieldName() const +{ + return prime2MeanFieldName_; +} + + +const Foam::word& Foam::functionObjects::fieldAverageItem::base() const +{ + return baseTypeNames_[base_]; +} + + +Foam::label Foam::functionObjects::fieldAverageItem::totalIter() const +{ + return totalIter_; +} + + +Foam::scalar Foam::functionObjects::fieldAverageItem::totalTime() const +{ + return totalTime_; +} + + +Foam::scalar Foam::functionObjects::fieldAverageItem::window() const +{ + return window_; +} + + +const Foam::word& Foam::functionObjects::fieldAverageItem::windowName() const +{ + return windowName_; +} + + +const Foam::FIFOStack<Foam::scalar>& +Foam::functionObjects::fieldAverageItem::windowTimes() const +{ + return windowTimes_; +} + + +const Foam::FIFOStack<Foam::word>& +Foam::functionObjects::fieldAverageItem::windowFieldNames() const +{ + return windowFieldNames_; +} + + +Foam::scalar Foam::functionObjects::fieldAverageItem::dt +( + const scalar deltaT +) const +{ + switch (base_) + { + case baseType::TIME: + { + return deltaT; + } + case baseType::ITER: + { + return scalar(1); + } + default: + { + FatalErrorInFunction + << "Unhandled enumeration " << baseTypeNames_[base_] + << abort(FatalError); + } + } + + return 0.0; +} + + +Foam::scalar Foam::functionObjects::fieldAverageItem::Dt() const +{ + switch (base_) + { + case baseType::TIME: + { + return totalTime_; + } + case baseType::ITER: + { + return scalar(totalIter_); + } + default: + { + FatalErrorInFunction + << "Unhandled enumeration " << baseTypeNames_[base_] + << abort(FatalError); + } + } + + return 0.0; +} + + +Foam::word Foam::functionObjects::fieldAverageItem::windowFieldName +( + const word& prefix +) const +{ + return prefix + ':' + fieldName_ + ':' + Foam::name(totalIter_); +} + + +bool Foam::functionObjects::fieldAverageItem::inWindow(const scalar t) const +{ + switch (base_) + { + case baseType::ITER: + { + return round(t) <= round(window_) + 1; + } + case baseType::TIME: + { + return t <= window_; + } + default: + { + FatalErrorInFunction + << "Unhandled baseType enumeration " + << baseTypeNames_[base_] + << abort(FatalError); + } + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C index a057aba5762..faef22d688f 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.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 | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,8 +37,15 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is) meanFieldName_("unknown"), prime2Mean_(0), prime2MeanFieldName_("unknown"), - base_(ITER), - window_(-1.0) + base_(baseType::ITER), + totalIter_(0), + totalTime_(-1), + window_(-1.0), + windowName_(""), + windowType_(windowType::NONE), + + windowTimes_(), + windowFieldNames_() { is.check(FUNCTION_NAME); @@ -49,11 +56,21 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is) prime2Mean_ = readBool(entry.lookup("prime2Mean")); base_ = baseTypeNames_.lookup("base", entry); window_ = entry.lookupOrDefault<scalar>("window", -1.0); - windowName_ = entry.lookupOrDefault<word>("windowName", ""); + + if (window_ > 0) + { + windowName_ = entry.lookupOrDefault<word>("windowName", ""); + windowType_ = windowTypeNames_.lookup("windowType", entry); + + if (windowType_ == windowType::NONE) + { + window_ = -1; + } + } meanFieldName_ = fieldName_ + EXT_MEAN; prime2MeanFieldName_ = fieldName_ + EXT_PRIME2MEAN; - if ((window_ > 0) && (windowName_ != "")) + if ((window_ > 0) && (!windowName_.empty())) { meanFieldName_ = meanFieldName_ + "_" + windowName_; prime2MeanFieldName_ = prime2MeanFieldName_ + "_" + windowName_; @@ -79,13 +96,24 @@ Foam::Istream& Foam::functionObjects::operator>> faItem.prime2Mean_ = readBool(entry.lookup("prime2Mean")); faItem.base_ = faItem.baseTypeNames_.lookup("base", entry); faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0); - faItem.windowName_ = entry.lookupOrDefault<word>("windowName", ""); + + if (faItem.window_ > 0) + { + faItem.windowName_ = entry.lookupOrDefault<word>("windowName", ""); + faItem.windowType_ = + faItem.windowTypeNames_.lookup("windowType", entry); + + if (faItem.windowType_ == fieldAverageItem::windowType::NONE) + { + faItem.window_ = -1; + } + } faItem.meanFieldName_ = faItem.fieldName_ + fieldAverageItem::EXT_MEAN; faItem.prime2MeanFieldName_ = faItem.fieldName_ + fieldAverageItem::EXT_PRIME2MEAN; - if ((faItem.window_ > 0) && (faItem.windowName_ != "")) + if ((faItem.window_ > 0) && (!faItem.windowName_.empty())) { faItem.meanFieldName_ = faItem.meanFieldName_ + "_" + faItem.windowName_; @@ -105,7 +133,8 @@ Foam::Ostream& Foam::functionObjects::operator<< { os.check(FUNCTION_NAME); - os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl; + os.beginBlock(faItem.fieldName_); + os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl; os.writeKeyword("prime2Mean") << faItem.prime2Mean_ << token::END_STATEMENT << nl; @@ -114,19 +143,24 @@ Foam::Ostream& Foam::functionObjects::operator<< if (faItem.window_ > 0) { - os.writeKeyword("window") << faItem.window_ - << token::END_STATEMENT << nl; + os.writeEntry("window", faItem.window_); - if (faItem.windowName_ != "") + if (!faItem.windowName_.empty()) { - os.writeKeyword("windowName") << faItem.windowName_ - << token::END_STATEMENT << nl; + os.writeEntry("windowName", faItem.windowName_); } + + os.writeEntry + ( + "windowType", + faItem.windowTypeNames_[faItem.windowType_] + ); } - os << token::END_BLOCK << nl; + os.endBlock() << flush; os.check(FUNCTION_NAME); + return os; } diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C new file mode 100644 index 00000000000..f7a752b993d --- /dev/null +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C @@ -0,0 +1,291 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "objectRegistry.H" +#include "Time.H" + +template<class Type> +bool Foam::functionObjects::fieldAverageItem::calculateMeanField +( + const objectRegistry& obr +) const +{ + if (!mean_) + { + return false; + } + + const Type* baseFieldPtr = obr.lookupObjectPtr<Type>(fieldName_); + + if (!baseFieldPtr) + { + return false; + } + + const Type& baseField = *baseFieldPtr; + Type& meanField = obr.lookupObjectRef<Type>(meanFieldName_); + + switch (windowType_) + { + case windowType::NONE: + { + scalar dt = this->dt(obr.time().deltaTValue()); + scalar Dt = this->Dt(); + scalar beta = dt/Dt; + + meanField = (1 - beta)*meanField + beta*baseField; + + break; + } + case windowType::APPROXIMATE: + { + scalar dt = this->dt(obr.time().deltaTValue()); + scalar Dt = this->Dt(); + scalar beta = dt/Dt; + + if (Dt - dt >= window_) + { + beta = dt/window_; + } + + meanField = (1 - beta)*meanField + beta*baseField; + + break; + } + case windowType::EXACT: + { + switch (base_) + { + case baseType::ITER: + { + // Uniform time step - can use simplified algorithm + // Note: stores an additional old time field, but only + // needs to do 1 field lookup + + label n = windowTimes_.size(); + const Type& lastField = + obr.lookupObject<Type>(windowFieldNames_.first()); + + if (n <= round(window_)) + { + scalar beta = 1.0/scalar(n); + meanField = (1 - beta)*meanField + beta*baseField; + } + else + { + meanField += (baseField - lastField)/scalar(n - 1); + } + + break; + } + case baseType::TIME: + { + // Assuming non-uniform time step + // Note: looks up all window fields from the registry + + meanField = 0*baseField; + FIFOStack<scalar>::const_iterator timeIter = + windowTimes_.begin(); + FIFOStack<word>::const_iterator nameIter = + windowFieldNames_.begin(); + + const Type* wOld = nullptr; + + for + ( + ; + timeIter != windowTimes_.end(); + ++timeIter, ++nameIter + ) + { + const word& fieldName = nameIter(); + const scalar dt = timeIter(); + const Type* w = obr.lookupObjectPtr<Type>(fieldName); + + meanField += dt*(*w); + + if (wOld) + { + meanField -= dt*(*wOld); + } + + wOld = w; + } + + meanField /= windowTimes_.first(); + + break; + } + default: + { + FatalErrorInFunction + << "Unhandled baseType enumeration " + << baseTypeNames_[base_] + << abort(FatalError); + } + } + + break; + } + default: + { + FatalErrorInFunction + << "Unhandled windowType enumeration " + << windowTypeNames_[windowType_] + << abort(FatalError); + } + } + + return true; +} + + +template<class Type1, class Type2> +bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField +( + const objectRegistry& obr +) const +{ + if (!prime2Mean_) + { + return false; + } + + const Type1* baseFieldPtr = obr.lookupObjectPtr<Type1>(fieldName_); + + if (!baseFieldPtr) + { + return false; + } + + const Type1& baseField = *baseFieldPtr; + const Type1& meanField = obr.lookupObject<Type1>(meanFieldName_); + + Type2& prime2MeanField = + obr.lookupObjectRef<Type2>(prime2MeanFieldName_); + + switch (windowType_) + { + case windowType::NONE: + { + scalar dt = this->dt(obr.time().deltaTValue()); + scalar Dt = this->Dt(); + scalar beta = dt/Dt; + + prime2MeanField = + (1 - beta)*prime2MeanField + + beta*sqr(baseField) + - sqr(meanField); + + break; + } + case windowType::APPROXIMATE: + { + scalar dt = this->dt(obr.time().deltaTValue()); + scalar Dt = this->Dt(); + scalar beta = dt/Dt; + + if (Dt - dt >= window_) + { + beta = dt/window_; + } + + prime2MeanField = + (1 - beta)*prime2MeanField + + beta*sqr(baseField) + - sqr(meanField); + + break; + } + case windowType::EXACT: + { + // Not storing old time mean fields - treat all as TIME (integrated) + prime2MeanField = 0*prime2MeanField; + FIFOStack<scalar>::const_iterator timeIter = + windowTimes_.begin(); + FIFOStack<word>::const_iterator nameIter = + windowFieldNames_.begin(); + + switch (base_) + { + case baseType::ITER: + { + // ITER method stores an additional entry compared to TIME + ++timeIter; + ++nameIter; + + if (timeIter == windowTimes_.end()) return false; + + break; + } + default: + {} + } + + + scalar windowLength = timeIter(); + + const Type1* wOld = nullptr; + + for + ( + ; + timeIter != windowTimes_.end(); + ++timeIter, ++nameIter + ) + { + const word& fieldName = nameIter(); + const scalar dt = timeIter(); + const Type1* w = obr.lookupObjectPtr<Type1>(fieldName); + + prime2MeanField += dt*(sqr((*w) - meanField)); + + if (wOld) + { + prime2MeanField -= dt*(sqr((*wOld) - meanField)); + } + + wOld = w; + } + + prime2MeanField /= windowLength; + + + break; + } + default: + { + FatalErrorInFunction + << "Unhandled windowType enumeration " + << windowTypeNames_[windowType_] + << abort(FatalError); + } + } + + return true; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C index 490325d8095..9946d67a211 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,13 +32,22 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template<class Type> -void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi) +void Foam::functionObjects::fieldAverage::addMeanFieldType +( + fieldAverageItem& item +) { + const word& fieldName = item.fieldName(); + + if (!foundObject<Type>(fieldName)) + { + return; + } + // Field has been found, so set active flag to true - faItems_[fieldi].active() = true; + item.active() = true; - const word& fieldName = faItems_[fieldi].fieldName(); - const word& meanFieldName = faItems_[fieldi].meanFieldName(); + const word& meanFieldName = item.meanFieldName(); Log << " Reading/initialising field " << meanFieldName << endl; @@ -50,7 +59,7 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi) << " since an object with that name already exists." << " Disabling averaging for field." << endl; - faItems_[fieldi].mean() = false; + item.mean() = false; } else { @@ -66,9 +75,9 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi) meanFieldName, obr().time().timeName(obr().time().startTime().value()), obr(), - restartOnOutput_ - ? IOobject::NO_READ - : IOobject::READ_IF_PRESENT, + restartOnOutput_ ? + IOobject::NO_READ + : IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), 1*baseField @@ -79,41 +88,102 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi) template<class Type> -void Foam::functionObjects::fieldAverage::addMeanField(const label fieldi) +void Foam::functionObjects::fieldAverage::addMeanField +( + fieldAverageItem& item +) { typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; - if (faItems_[fieldi].mean()) + if (item.mean()) { - const word& fieldName = faItems_[fieldi].fieldName(); + addMeanFieldType<VolFieldType>(item); + addMeanFieldType<SurfaceFieldType>(item); + addMeanFieldType<SurfFieldType>(item); + } +} - if (foundObject<VolFieldType>(fieldName)) - { - addMeanFieldType<VolFieldType>(fieldi); - } - else if (foundObject<SurfaceFieldType>(fieldName)) - { - addMeanFieldType<SurfaceFieldType>(fieldi); - } - else if (foundObject<SurfFieldType>(fieldName)) + +template<class Type> +void Foam::functionObjects::fieldAverage::restoreWindowFieldsType +( + const fieldAverageItem& item +) +{ + if (restartOnOutput_) + { + return; + } + + const word& fieldName = item.fieldName(); + + const Type* fieldPtr = lookupObjectPtr<Type>(fieldName); + + if (!fieldPtr) + { + return; + } + + const FIFOStack<word>& fieldNames = item.windowFieldNames(); + + forAllConstIters(fieldNames, fieldIter) + { + const word& name = fieldIter(); + + IOobject io + ( + name, + obr().time().timeName(obr().time().startTime().value()), + obr(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (io.typeHeaderOk<dictionary>(false)) { - addMeanFieldType<SurfFieldType>(fieldi); + DebugInfo << "Read and store: " << name << endl; + obr().store(new Type(io, fieldPtr->mesh())); } } } +template<class Type> +void Foam::functionObjects::fieldAverage::restoreWindowFields +( + const fieldAverageItem& item +) +{ + typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; + typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; + typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; + + if (item.window() > 0) + { + restoreWindowFieldsType<VolFieldType>(item); + restoreWindowFieldsType<SurfaceFieldType>(item); + restoreWindowFieldsType<SurfFieldType>(item); + } +} + + template<class Type1, class Type2> void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType ( - const label fieldi + fieldAverageItem& item ) { - const word& fieldName = faItems_[fieldi].fieldName(); - const word& meanFieldName = faItems_[fieldi].meanFieldName(); - const word& prime2MeanFieldName = faItems_[fieldi].prime2MeanFieldName(); + const word& fieldName = item.fieldName(); + + if (!foundObject<Type1>(fieldName)) + { + return; + } + + const word& meanFieldName = item.meanFieldName(); + const word& prime2MeanFieldName = item.prime2MeanFieldName(); Log << " Reading/initialising field " << prime2MeanFieldName << nl; @@ -125,7 +195,7 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType << " since an object with that name already exists." << " Disabling averaging for field." << endl; - faItems_[fieldi].prime2Mean() = false; + item.prime2Mean() = false; } else { @@ -142,9 +212,9 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType prime2MeanFieldName, obr().time().timeName(obr().time().startTime().value()), obr(), - restartOnOutput_ - ? IOobject::NO_READ - : IOobject::READ_IF_PRESENT, + restartOnOutput_? + IOobject::NO_READ + : IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), sqr(baseField) - sqr(meanField) @@ -155,7 +225,10 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType template<class Type1, class Type2> -void Foam::functionObjects::fieldAverage::addPrime2MeanField(const label fieldi) +void Foam::functionObjects::fieldAverage::addPrime2MeanField +( + fieldAverageItem& item +) { typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1; typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1; @@ -165,144 +238,96 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanField(const label fieldi) typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2; typedef DimensionedField<Type2, surfGeoMesh> SurfFieldType2; - if (faItems_[fieldi].prime2Mean()) + if (item.prime2Mean()) { - const word& fieldName = faItems_[fieldi].fieldName(); - - if (!faItems_[fieldi].mean()) + if (!item.mean()) { FatalErrorInFunction << "To calculate the prime-squared average, the " << "mean average must also be selected for field " - << fieldName << nl << exit(FatalError); + << item.fieldName() << nl << exit(FatalError); } - if (foundObject<VolFieldType1>(fieldName)) - { - addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(fieldi); - } - else if (foundObject<SurfaceFieldType1>(fieldName)) - { - addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2> - ( - fieldi - ); - } - else if (foundObject<SurfFieldType1>(fieldName)) - { - addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2> - ( - fieldi - ); - } + addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(item); + addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>(item); + addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>(item); } } template<class Type> -void Foam::functionObjects::fieldAverage::calculateMeanFieldType +void Foam::functionObjects::fieldAverage::storeWindowFieldType ( - const label fieldi -) const + fieldAverageItem& item +) { - const word& fieldName = faItems_[fieldi].fieldName(); + const word& fieldName = item.fieldName(); - if (foundObject<Type>(fieldName)) + if (!foundObject<Type>(fieldName)) { - const Type& baseField = lookupObject<Type>(fieldName); - - Type& meanField = const_cast<Type&> - ( - lookupObject<Type>(faItems_[fieldi].meanFieldName()) - ); - - scalar dt = obr().time().deltaTValue(); - scalar Dt = totalTime_[fieldi]; + return; + } - if (faItems_[fieldi].iterBase()) - { - dt = 1; - Dt = scalar(totalIter_[fieldi]); - } + const Type& baseField = lookupObject<Type>(fieldName); - scalar beta = dt/Dt; + const word windowFieldName = item.windowFieldName(this->name()); - if (faItems_[fieldi].window() > 0) - { - const scalar w = faItems_[fieldi].window(); + // Store on registry + obr().store + ( + new Type + ( + IOobject + ( + windowFieldName, + obr().time().timeName(obr().time().startTime().value()), + obr(), + restartOnOutput_ ? + IOobject::NO_READ + : IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + 1*baseField + ) + ); - if (Dt - dt >= w) - { - beta = dt/w; - } - } + DebugInfo << "Create and store: " << windowFieldName << endl; - meanField = (1 - beta)*meanField + beta*baseField; - } + item.addToWindow(windowFieldName, obr().time().deltaTValue()); } template<class Type> -void Foam::functionObjects::fieldAverage::calculateMeanFields() const +void Foam::functionObjects::fieldAverage::storeWindowFields() { typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; - forAll(faItems_, i) + for (fieldAverageItem& item : faItems_) { - if (faItems_[i].mean()) + if (item.window() > 0) { - calculateMeanFieldType<VolFieldType>(i); - calculateMeanFieldType<SurfaceFieldType>(i); - calculateMeanFieldType<SurfFieldType>(i); + storeWindowFieldType<VolFieldType>(item); + storeWindowFieldType<SurfaceFieldType>(item); + storeWindowFieldType<SurfFieldType>(item); } } } -template<class Type1, class Type2> -void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType -( - const label fieldi -) const +template<class Type> +void Foam::functionObjects::fieldAverage::calculateMeanFields() const { - const word& fieldName = faItems_[fieldi].fieldName(); + typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; + typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; + typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; - if (foundObject<Type1>(fieldName)) + for (const fieldAverageItem& item : faItems_) { - const Type1& baseField = lookupObject<Type1>(fieldName); - const Type1& meanField = - lookupObject<Type1>(faItems_[fieldi].meanFieldName()); - - Type2& prime2MeanField = - lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName()); - - scalar dt = obr().time().deltaTValue(); - scalar Dt = totalTime_[fieldi]; - - if (faItems_[fieldi].iterBase()) - { - dt = 1; - Dt = scalar(totalIter_[fieldi]); - } - - scalar beta = dt/Dt; - - if (faItems_[fieldi].window() > 0) - { - const scalar w = faItems_[fieldi].window(); - - if (Dt - dt >= w) - { - beta = dt/w; - } - } - - prime2MeanField = - (1 - beta)*prime2MeanField - + beta*sqr(baseField) - - sqr(meanField); + item.calculateMeanField<VolFieldType>(obr()); + item.calculateMeanField<SurfaceFieldType>(obr()); + item.calculateMeanField<SurfFieldType>(obr()); } } @@ -318,21 +343,14 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2; typedef DimensionedField<Type2, surfGeoMesh> SurfFieldType2; - forAll(faItems_, i) + for (const fieldAverageItem& item : faItems_) { - if (faItems_[i].prime2Mean()) - { - calculatePrime2MeanFieldType<VolFieldType1, VolFieldType2>(i); - calculatePrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2> - ( - i - ); - - calculatePrime2MeanFieldType<SurfFieldType1, SurfFieldType2> - ( - i - ); - } + item.calculatePrime2MeanField<VolFieldType1, VolFieldType2>(obr()); + item.calculatePrime2MeanField<SurfaceFieldType1, SurfaceFieldType2> + ( + obr() + ); + item.calculatePrime2MeanField<SurfFieldType1, SurfFieldType2>(obr()); } } @@ -340,21 +358,21 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const template<class Type1, class Type2> void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType ( - const label fieldi + const fieldAverageItem& item ) const { - const word& fieldName = faItems_[fieldi].fieldName(); + const word& fieldName = item.fieldName(); - if (foundObject<Type1>(fieldName)) + if (!foundObject<Type1>(fieldName)) { - const Type1& meanField = - lookupObject<Type1>(faItems_[fieldi].meanFieldName()); + return; + } - Type2& prime2MeanField = - lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName()); + const Type1& meanField = lookupObject<Type1>(item.meanFieldName()); - prime2MeanField += sqr(meanField); - } + Type2& prime2MeanField = lookupObjectRef<Type2>(item.prime2MeanFieldName()); + + prime2MeanField += sqr(meanField); } @@ -369,13 +387,16 @@ void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2; typedef DimensionedField<Type2, surfGeoMesh> SurfFieldType2; - forAll(faItems_, i) + for (const fieldAverageItem& item : faItems_) { - if (faItems_[i].prime2Mean()) + if (item.prime2Mean()) { - addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(i); - addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2>(i); - addMeanSqrToPrime2MeanType<SurfFieldType1, SurfFieldType2>(i); + addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(item); + addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2> + ( + item + ); + addMeanSqrToPrime2MeanType<SurfFieldType1, SurfFieldType2>(item); } } } @@ -402,22 +423,33 @@ void Foam::functionObjects::fieldAverage::writeFields() const typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; - forAll(faItems_, i) + for (const fieldAverageItem& item : faItems_) { - if (faItems_[i].mean()) + if (item.mean()) { - const word& fieldName = faItems_[i].meanFieldName(); + const word& fieldName = item.meanFieldName(); writeFieldType<VolFieldType>(fieldName); writeFieldType<SurfaceFieldType>(fieldName); writeFieldType<SurfFieldType>(fieldName); } - if (faItems_[i].prime2Mean()) + if (item.prime2Mean()) { - const word& fieldName = faItems_[i].prime2MeanFieldName(); + const word& fieldName = item.prime2MeanFieldName(); writeFieldType<VolFieldType>(fieldName); writeFieldType<SurfaceFieldType>(fieldName); writeFieldType<SurfFieldType>(fieldName); } + if (item.window() > 0) + { + FIFOStack<word> fieldNames = item.windowFieldNames(); + forAllConstIters(fieldNames, fieldNameIter) + { + const word& fieldName = fieldNameIter(); + writeFieldType<VolFieldType>(fieldName); + writeFieldType<SurfaceFieldType>(fieldName); + writeFieldType<SurfFieldType>(fieldName); + } + } } } -- GitLab From f7ff26bd2d26a7d1a54a9d9398b37f23cb3924ee Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Mon, 30 Oct 2017 13:47:32 +0000 Subject: [PATCH 087/126] ENH: fieldAverage - enable suppressing of intermediate field writing for the exact method Also updated/corrected restart behaviour --- .../field/fieldAverage/fieldAverage.C | 53 +++++------ .../field/fieldAverage/fieldAverage.H | 4 - .../fieldAverageItem/fieldAverageItem.C | 39 ++++++-- .../fieldAverageItem/fieldAverageItem.H | 21 ++++- .../fieldAverageItem/fieldAverageItemI.H | 18 ++++ .../fieldAverageItem/fieldAverageItemIO.C | 88 +++++++++++-------- .../fieldAverage/fieldAverageTemplates.C | 16 +++- 7 files changed, 148 insertions(+), 91 deletions(-) diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.C b/src/functionObjects/field/fieldAverage/fieldAverage.C index 769775639b7..7c8aa89d080 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.C +++ b/src/functionObjects/field/fieldAverage/fieldAverage.C @@ -42,38 +42,14 @@ namespace functionObjects // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::functionObjects::fieldAverage::resetFields() -{ - for (const fieldAverageItem& item : faItems_) - { - if (item.mean()) - { - if (obr().found(item.meanFieldName())) - { - obr().checkOut(*obr()[item.meanFieldName()]); - } - } - - if (item.prime2Mean()) - { - if (obr().found(item.prime2MeanFieldName())) - { - obr().checkOut(*obr()[item.prime2MeanFieldName()]); - } - } - } -} - - void Foam::functionObjects::fieldAverage::initialize() { for (fieldAverageItem& item : faItems_) { - item.restart(0, false); + // Note: not clearing data needed for restart + item.clear(obr(), false); } - resetFields(); - Log << type() << " " << name() << ":" << nl; // Add mean fields to the field lists @@ -130,7 +106,7 @@ void Foam::functionObjects::fieldAverage::restart() for (fieldAverageItem& item : faItems_) { - item.restart(0, true); + item.clear(obr(), true); } initialize(); @@ -251,12 +227,23 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties() getDict(fieldName, fieldDict); item.readState(fieldDict); - scalar userTotalTime = - obr().time().timeToUserTime(item.totalTime()); - - Info<< " " << fieldName - << " iters = " << item.totalIter() - << " time = " << userTotalTime << nl; + if (item.allowRestart()) + { + scalar userTotalTime = + obr().time().timeToUserTime(item.totalTime()); + + Info<< " " << fieldName + << ": iters = " << item.totalIter() + << " time = " << userTotalTime << nl; + } + else + { + item.clear(obr(), true); + + Info<< " " << fieldName + << ": starting averaging at time " + << obr().time().timeOutputValue() << endl; + } } else { diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.H b/src/functionObjects/field/fieldAverage/fieldAverage.H index 52a907a4051..b169bfa0512 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.H +++ b/src/functionObjects/field/fieldAverage/fieldAverage.H @@ -197,10 +197,6 @@ protected: // Initialisation routines - //- Checkout fields (causes deletion) from the database - // and reset lists - void resetFields(); - //- Reset lists (clear existing values) and initialize averaging. // Check requested field averages are valid, populate field lists void initialize(); diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C index d96261d7631..74927ea91f8 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C @@ -68,9 +68,9 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem() : active_(false), fieldName_("unknown"), - mean_(0), + mean_(false), meanFieldName_("unknown"), - prime2Mean_(0), + prime2Mean_(false), prime2MeanFieldName_("unknown"), base_(baseType::ITER), totalIter_(0), @@ -80,7 +80,8 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem() windowType_(windowType::NONE), windowTimes_(), - windowFieldNames_() + windowFieldNames_(), + allowRestart_(true) {} @@ -103,7 +104,8 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem windowType_(faItem.windowType_), windowTimes_(faItem.windowTimes_), - windowFieldNames_(faItem.windowFieldNames_) + windowFieldNames_(faItem.windowFieldNames_), + allowRestart_(faItem.allowRestart_) {} @@ -154,16 +156,34 @@ void Foam::functionObjects::fieldAverageItem::evolve(const objectRegistry& obr) } -void Foam::functionObjects::fieldAverageItem::restart +void Foam::functionObjects::fieldAverageItem::clear ( - const scalar time0, - const bool override + const objectRegistry& obr, + bool fullClean ) { - if (totalTime_ < 0 || override) + if (mean_ && obr.found(meanFieldName_)) + { + obr.checkOut(*obr[meanFieldName_]); + } + + if (prime2Mean_ && obr.found(prime2MeanFieldName_)) + { + obr.checkOut(*obr[prime2MeanFieldName_]); + } + + for (const word& fieldName : windowFieldNames_) + { + if (obr.found(fieldName)) + { + obr.checkOut(*obr[fieldName]); + } + } + + if (totalTime_ < 0 || fullClean) { totalIter_ = 0; - totalTime_ = time0; + totalTime_ = 0; windowTimes_.clear(); windowFieldNames_.clear(); } @@ -231,6 +251,7 @@ void Foam::functionObjects::fieldAverageItem::operator= windowType_ = rhs.windowType_; windowTimes_ = rhs.windowTimes_; windowFieldNames_ = rhs.windowFieldNames_; + allowRestart_ = rhs.allowRestart_; } diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H index c54bc668668..24fecbae7ce 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H @@ -36,6 +36,8 @@ Description window 200; // optional averaging window windowName w1; // optional window name (default = "") windowType approximate; // window type + + allowRestart yes; // optional, used for windowType 'exact' } \endverbatim @@ -166,6 +168,9 @@ private: //- List of window field names (windowType = EXACT) FIFOStack<word> windowFieldNames_; + //- Switch to write all necessary files for clean restart + bool allowRestart_; + public: @@ -237,6 +242,9 @@ public: //- Return the list of window field names (windowType = EXACT) inline const FIFOStack<word>& windowFieldNames() const; + //- Return the allow restart flag + inline bool allowRestart() const; + //- Return the current time interval inline scalar dt(const scalar deltaT) const; @@ -249,14 +257,20 @@ public: //- Return true if time is inside window (including boundaries) inline bool inWindow(const scalar t) const; + //- Return true if we wish to store window fields + inline bool storeWindowFields() const; + + //- Return true if we wish to write window fields + inline bool writeWindowFields() const; + //- Add field to window void addToWindow(const word& fieldName, const scalar deltaT); //- Evolve and update void evolve(const objectRegistry& obr); - //- Restart - void restart(const scalar time0, const bool override); + //- Clear out all mean fields and (optionally) supporting data + void clear(const objectRegistry& obr, const bool fullClean); //- Read state and re-initialise values bool readState(const dictionary& dict); @@ -298,7 +312,8 @@ public: && a.totalTime_ == b.totalTime_ && a.window_ == b.window_ && a.windowName_ == b.windowName_ - && a.windowType_ == b.windowType_; + && a.windowType_ == b.windowType_ + && a.allowRestart_ == b.allowRestart_; } friend bool operator!= diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H index b7426dd06ed..371a3091e88 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H @@ -124,6 +124,12 @@ Foam::functionObjects::fieldAverageItem::windowFieldNames() const } +bool Foam::functionObjects::fieldAverageItem::allowRestart() const +{ + return allowRestart_; +} + + Foam::scalar Foam::functionObjects::fieldAverageItem::dt ( const scalar deltaT @@ -209,4 +215,16 @@ bool Foam::functionObjects::fieldAverageItem::inWindow(const scalar t) const } +bool Foam::functionObjects::fieldAverageItem::storeWindowFields() const +{ + return windowType_ == windowType::EXACT; +} + + +bool Foam::functionObjects::fieldAverageItem::writeWindowFields() const +{ + return (allowRestart_ && window_ > 0); +} + + // ************************************************************************* // diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C index faef22d688f..c1c3e1d19a4 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C @@ -33,9 +33,9 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is) : active_(false), fieldName_("unknown"), - mean_(0), + mean_(false), meanFieldName_("unknown"), - prime2Mean_(0), + prime2Mean_(false), prime2MeanFieldName_("unknown"), base_(baseType::ITER), totalIter_(0), @@ -45,36 +45,10 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is) windowType_(windowType::NONE), windowTimes_(), - windowFieldNames_() + windowFieldNames_(), + allowRestart_(true) { - is.check(FUNCTION_NAME); - - const dictionaryEntry entry(dictionary::null, is); - - fieldName_ = entry.keyword(); - mean_ = readBool(entry.lookup("mean")); - prime2Mean_ = readBool(entry.lookup("prime2Mean")); - base_ = baseTypeNames_.lookup("base", entry); - window_ = entry.lookupOrDefault<scalar>("window", -1.0); - - if (window_ > 0) - { - windowName_ = entry.lookupOrDefault<word>("windowName", ""); - windowType_ = windowTypeNames_.lookup("windowType", entry); - - if (windowType_ == windowType::NONE) - { - window_ = -1; - } - } - - meanFieldName_ = fieldName_ + EXT_MEAN; - prime2MeanFieldName_ = fieldName_ + EXT_PRIME2MEAN; - if ((window_ > 0) && (!windowName_.empty())) - { - meanFieldName_ = meanFieldName_ + "_" + windowName_; - prime2MeanFieldName_ = prime2MeanFieldName_ + "_" + windowName_; - } + is >> *this; } @@ -99,15 +73,52 @@ Foam::Istream& Foam::functionObjects::operator>> if (faItem.window_ > 0) { - faItem.windowName_ = entry.lookupOrDefault<word>("windowName", ""); faItem.windowType_ = faItem.windowTypeNames_.lookup("windowType", entry); - if (faItem.windowType_ == fieldAverageItem::windowType::NONE) + if (faItem.windowType_ != fieldAverageItem::windowType::NONE) + { + if + ( + faItem.base_ == fieldAverageItem::baseType::ITER + && label(faItem.window_) < 1 + ) + { + FatalIOErrorInFunction(entry) + << "Window must be 1 or more for base type " + << faItem.baseTypeNames_[fieldAverageItem::baseType::ITER] + << exit(FatalIOError); + } + + faItem.windowName_ = entry.lookupOrDefault<word>("windowName", ""); + + if (faItem.windowType_ == fieldAverageItem::windowType::EXACT) + { + faItem.allowRestart_ = readBool(entry.lookup("allowRestart")); + + if (!faItem.allowRestart_) + { + WarningInFunction + << faItem.windowTypeNames_[faItem.windowType_] + << " windowing for field " << faItem.fieldName_ + << " will not write intermediate files and restart will" + << " not be possible. To enable, please set" + << " 'allowRestart' to 'yes'" + << endl; + } + } + } + else { + // Deactivate windowing faItem.window_ = -1; } } + else + { + // Deactivate windowing + faItem.window_ = -1; + } faItem.meanFieldName_ = faItem.fieldName_ + fieldAverageItem::EXT_MEAN; faItem.prime2MeanFieldName_ = @@ -121,6 +132,7 @@ Foam::Istream& Foam::functionObjects::operator>> faItem.prime2MeanFieldName_ = faItem.prime2MeanFieldName_ + "_" + faItem.windowName_; } + return is; } @@ -135,11 +147,9 @@ Foam::Ostream& Foam::functionObjects::operator<< os.beginBlock(faItem.fieldName_); - os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl; - os.writeKeyword("prime2Mean") << faItem.prime2Mean_ - << token::END_STATEMENT << nl; - os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_] - << token::END_STATEMENT << nl; + os.writeEntry("mean", faItem.mean_); + os.writeEntry("prime2Mean", faItem.prime2Mean_); + os.writeEntry("base", faItem.baseTypeNames_[faItem.base_]); if (faItem.window_ > 0) { @@ -155,6 +165,8 @@ Foam::Ostream& Foam::functionObjects::operator<< "windowType", faItem.windowTypeNames_[faItem.windowType_] ); + + os.writeEntry("allowRestart", faItem.allowRestart_); } os.endBlock() << flush; diff --git a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C index 9946d67a211..5f34c9de2a0 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C @@ -141,11 +141,18 @@ void Foam::functionObjects::fieldAverage::restoreWindowFieldsType IOobject::NO_WRITE ); - if (io.typeHeaderOk<dictionary>(false)) + if (io.typeHeaderOk<Type>(true)) { DebugInfo << "Read and store: " << name << endl; obr().store(new Type(io, fieldPtr->mesh())); } + else + { + WarningInFunction + << "Unable to read window " << Type::typeName << " " << name + << ". Averaging restart behaviour may be compromised" + << endl; + } } } @@ -262,7 +269,6 @@ void Foam::functionObjects::fieldAverage::storeWindowFieldType ) { const word& fieldName = item.fieldName(); - if (!foundObject<Type>(fieldName)) { return; @@ -306,7 +312,7 @@ void Foam::functionObjects::fieldAverage::storeWindowFields() for (fieldAverageItem& item : faItems_) { - if (item.window() > 0) + if (item.storeWindowFields()) { storeWindowFieldType<VolFieldType>(item); storeWindowFieldType<SurfaceFieldType>(item); @@ -432,6 +438,7 @@ void Foam::functionObjects::fieldAverage::writeFields() const writeFieldType<SurfaceFieldType>(fieldName); writeFieldType<SurfFieldType>(fieldName); } + if (item.prime2Mean()) { const word& fieldName = item.prime2MeanFieldName(); @@ -439,7 +446,8 @@ void Foam::functionObjects::fieldAverage::writeFields() const writeFieldType<SurfaceFieldType>(fieldName); writeFieldType<SurfFieldType>(fieldName); } - if (item.window() > 0) + + if (item.writeWindowFields()) { FIFOStack<word> fieldNames = item.windowFieldNames(); forAllConstIters(fieldNames, fieldNameIter) -- GitLab From ebd922a32eedcec9095f7dc891f4cfb219f9f979 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 4 Nov 2017 14:26:38 +0100 Subject: [PATCH 088/126] ENH: support longer doxygen brief descriptions. --- bin/tools/doxyFilter.awk | 51 ++++++++++---- .../HashTables/HashPtrTable/HashPtrTable.H | 6 +- .../containers/HashTables/HashSet/HashSet.H | 16 +++-- .../HashTables/HashTable/HashTable.H | 67 ++++++++++++------- src/OpenFOAM/containers/HashTables/Map/Map.H | 8 +-- .../containers/HashTables/PtrMap/PtrMap.H | 4 +- .../containers/Lists/FixedList/FixedList.H | 29 ++++---- .../containers/Lists/PackedList/PackedList.H | 13 ++-- .../Lists/UIndirectList/UIndirectList.H | 14 ++-- src/OpenFOAM/containers/Lists/UList/UList.H | 23 ++++--- src/OpenFOAM/global/argList/argList.H | 9 ++- src/OpenFOAM/primitives/enums/Enum.H | 8 +-- 12 files changed, 148 insertions(+), 100 deletions(-) diff --git a/bin/tools/doxyFilter.awk b/bin/tools/doxyFilter.awk index 0a581a61a14..a096684722b 100644 --- a/bin/tools/doxyFilter.awk +++ b/bin/tools/doxyFilter.awk @@ -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) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -29,40 +29,67 @@ # # Assumes comment strings are formatted as follows # //- General description -# // more information +# // Detailed information # // and even more information +# or +# //- General description +# //- that spans several +# //- lines +# // Detailed information +# // and even more information +# # This should be re-formatted as the following -# //! general description -# /*! -# more information +# /*! \brief General description +# that spans several +# lines +# */ +# /*! Detailed information # and even more information # */ +# # The intermediate "/*! ... */" block is left-justified to handle # possible verbatim text +# #------------------------------------------------------------------------------ +# States: 0=normal, 1=brief, 2=details BEGIN { state = 0 } /^ *\/\/-/ { - state = 1 - sub(/\/\/-/, "//!") + if (state == 0) + { + # Changed from normal to brief (start of comment block) + printf "/*! \\brief" + state = 1 + } + + if (state == 1) + { + # Within brief: strip leading + if (!sub(/^ *\/\/- /, "")) + { + sub(/^ *\/\/-/, "") + } + } + print next } /^ *\/\// { - # Start comment block if (state == 1) { + # Change from brief to details + printf "*/\n" printf "/*! " state = 2 } - # Inside comment block if (state == 2) { + # Within details: strip leading if (!sub(/^ *\/\/ /, "")) { sub(/^ *\/\//, "") @@ -74,10 +101,10 @@ BEGIN { } { - # End comment block - if (state == 2) + # End comment filtering + if (state) { - printf "*/ " + printf "*/\n" } state = 0 print diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H index daf19328d06..548066d19f6 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H @@ -91,10 +91,10 @@ public: // Constructors - //- Construct null with default table size + //- Construct null with default table capacity HashPtrTable(); - //- Construct given initial table size + //- Construct given initial table capacity explicit HashPtrTable(const label size); //- Construct from Istream using given Istream constructor class @@ -123,7 +123,7 @@ public: // Includes a safeguard against the end-iterator. T* remove(iterator& iter); - //- Erase an entry specified by given iterator + //- Erase an entry specified by given iterator. // Includes a safeguard against the end-iterator. bool erase(iterator& iter); diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H index f20e9059203..5c467a25628 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H @@ -27,6 +27,7 @@ Class Description A HashTable with keys but without contents that is similar to \c std::unordered_set. + The entries are considered \a unordered since their placement depends on the method used to generate the hash key index, the table capacity, insertion order etc. When the key order is @@ -121,19 +122,19 @@ public: // Constructors - //- Construct null with default (128) table size + //- Construct null with default (128) table capacity HashSet() : parent_type() {} - //- Construct given initial size + //- Construct given initial table capacity explicit HashSet(const label size) : parent_type(size) {} - //- Construct from Istream with default table size + //- Construct from Istream with default table capacity HashSet(Istream& is) : parent_type(is) @@ -183,7 +184,7 @@ public: // Edit - //- Insert a new entry + //- Insert a new entry, not overwriting existing entries. // \return True if the entry inserted, which means that it did // not previously exist in the set. bool insert(const Key& key) @@ -297,7 +298,8 @@ public: // Writing //- Write the unordered keys as a list, with line-breaks if list length - // exceeds shortListLen. Using '0' suppresses line-breaks entirely. + //- exceeds shortListLen. + // Using '0' suppresses line-breaks entirely. Ostream& writeList(Ostream& os, const label shortListLen=0) const { return this->writeKeys(os, shortListLen); @@ -329,8 +331,8 @@ public: // Comparison - //- Equality. Two hashset are equal when they have the same keys. - // Independent of table size or order. + //- Sets are equal if all keys are equal, + //- independent of order or underlying storage size. bool operator==(const this_type& rhs) const; //- The opposite of the equality operation. diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index a496b6b630f..926a3f90161 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -26,6 +26,7 @@ Class Description A HashTable similar to \c std::unordered_map. + The entries are considered \a unordered since their placement depends on the method used to generate the hash key index, the table capacity, insertion order etc. When the key order is @@ -305,8 +306,10 @@ protected: //- Internally used base for iterator and const_iterator template<bool Const> class Iterator; - //- Friendship with the base iterator is required. + //- An iterator with const access to HashTable internals. friend class Iterator<true>; + + //- An iterator with non-const access to HashTable internals. friend class Iterator<false>; @@ -325,13 +328,13 @@ public: // Constructors - //- Construct null with default (128) table size + //- Construct null with default (128) table capacity HashTable(); - //- Construct given initial table size + //- Construct given initial table capacity explicit HashTable(const label size); - //- Construct from Istream with default table size + //- Construct from Istream with default table capacity HashTable(Istream& is, const label size = 128); //- Construct as copy @@ -385,18 +388,22 @@ public: // Table of contents - //- Return the table of contents + //- The table of contents (the keys) in unsorted order. List<Key> toc() const; - //- Return the table of contents as a sorted list + //- The table of contents (the keys) in sorted order List<Key> sortedToc() const; - //- Return table of contents sorted using the specified comparator + //- The table of contents (the keys) sorted according to the + //- specified comparator template<class Compare> List<Key> sortedToc(const Compare& comp) const; - //- Return the sorted table of contents with keys that satisfy - // the unary predicate, optionally with inverted logic. + //- The table of contents (the keys) selected according to the + //- unary predicate applied to the \b keys. + // \param invert changes the logic to select when the predicate + // is false + // \return sorted list of selected keys template<class UnaryPredicate> List<Key> tocKeys ( @@ -404,8 +411,11 @@ public: const bool invert = false ) const; - //- Return the sorted table of contents with values that satisfy - // the unary predicate, optionally with inverted logic. + //- The table of contents (the keys) selected according to the + //- unary predicate applied to the \b values. + // \param invert changes the logic to select when the predicate + // is false + // \return sorted list of selected keys template<class UnaryPredicate> List<Key> tocValues ( @@ -413,8 +423,11 @@ public: const bool invert = false ) const; - //- Return the sorted table of contents with keys/values that satisfy - // the binary predicate, optionally with inverted logic. + //- The table of contents (the keys) selected according to the + //- binary predicate applied to the \b keys and \b values. + // \param invert changes the logic to select when the predicate + // is false + // \return sorted list of selected keys template<class BinaryPredicate> List<Key> tocEntries ( @@ -425,8 +438,9 @@ public: // Counting - //- Count the number of keys that satisfy the unary predicate, - // optionally with inverted logic. + //- Count the number of keys that satisfy the unary predicate + // \param invert changes the logic to select when the predicate + // is false template<class UnaryPredicate> label countKeys ( @@ -434,8 +448,9 @@ public: const bool invert = false ) const; - //- Count the number of values that satisfy the unary predicate, - // optionally with inverted logic. + //- Count the number of values that satisfy the unary predicate + // \param invert changes the logic to select when the predicate + // is false template<class UnaryPredicate> label countValues ( @@ -443,8 +458,9 @@ public: const bool invert = false ) const; - //- Count the number of entries that satisfy the binary predicate, - // optionally with inverted logic. + //- Count the number of entries that satisfy the binary predicate. + // \param invert changes the logic to select when the predicate + // is false template<class BinaryPredicate> label countEntries ( @@ -455,7 +471,7 @@ public: // Edit - //- Insert a new entry + //- Insert a new entry, not overwriting existing entries. // \return True if the entry inserted, which means that it did // not previously exist in the table. inline bool insert(const Key& key, const T& obj); @@ -618,11 +634,11 @@ public: //- Move assign void operator=(HashTable<T, Key, Hash>&& rhs); - //- Equality. Hash tables are equal if the keys and values are equal. - // Independent of table storage size and table order. + //- Equality. Tables are equal if all keys and values are equal, + //- independent of order or underlying storage size. bool operator==(const HashTable<T, Key, Hash>& rhs) const; - //- The opposite of the equality operation. Takes linear time. + //- The opposite of the equality operation. bool operator!=(const HashTable<T, Key, Hash>& rhs) const; @@ -918,7 +934,7 @@ public: // Iterator access - //- Iterator set to the beginning of the HashTable + //- iterator set to the beginning of the HashTable inline iterator begin(); //- const_iterator set to the beginning of the HashTable @@ -943,7 +959,8 @@ public: Ostream& printInfo(Ostream& os) const; //- Write the unordered keys as a list, with line-breaks if list length - // exceeds shortListLen. Using '0' suppresses line-breaks entirely. + //- exceeds shortListLen. + // Using '0' suppresses line-breaks entirely. Ostream& writeKeys(Ostream& os, const label shortListLen=0) const; diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H index 784a123a74f..f6910a73cdf 100644 --- a/src/OpenFOAM/containers/HashTables/Map/Map.H +++ b/src/OpenFOAM/containers/HashTables/Map/Map.H @@ -48,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Map Declaration + Class Map Declaration \*---------------------------------------------------------------------------*/ template<class T> @@ -70,19 +70,19 @@ public: // Constructors - //- Construct null with default table size + //- Construct null with default table capacity Map() : parent_type() {} - //- Construct with given table size + //- Construct with given initial table capacity explicit Map(const label size) : parent_type(size) {} - //- Construct from Istream with default table size + //- Construct from Istream with default table capacity Map(Istream& is) : parent_type(is) diff --git a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H index 4e86e1aae92..915edf49ad0 100644 --- a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H +++ b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H @@ -62,13 +62,13 @@ public: // Constructors - //- Construct null with default table size + //- Construct null with default table capacity PtrMap() : parent_type() {} - //- Construct given initial map size + //- Construct with given initial table capacity explicit PtrMap(const label size) : parent_type(size) diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index af54d5c782e..ecac3b57797 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -129,7 +129,7 @@ public: //- Construct from value explicit inline FixedList(const T& val); - //- Construct from C-array + //- Copy construct from C-array explicit inline FixedList(const T lst[Size]); //- Copy constructor @@ -164,7 +164,7 @@ public: // Access //- Return the forward circular index, i.e. next index - // which returns to the first at the end of the list + //- which returns to the first at the end of the list inline label fcIndex(const label i) const; //- Return forward circular value (ie, next value in the list) @@ -174,7 +174,7 @@ public: inline T& fcValue(const label i); //- Return the reverse circular index, i.e. previous index - // which returns to the last at the beginning of the list + //- which returns to the last at the beginning of the list inline label rcIndex(const label i) const; //- Return reverse circular value (ie, previous value in the list) @@ -184,13 +184,13 @@ public: inline T& rcValue(const label i); - //- Return a const pointer to the first data element, - // similar to the STL front() method and the string::data() method + //- Return a const pointer to the first data element. + // Similar to the STL front() method and the string::data() method // This can be used (with caution) when interfacing with C code inline const T* cdata() const; - //- Return a pointer to the first data element, - // similar to the STL front() method and the string::data() method + //- Return a pointer to the first data element. + // Similar to the STL front() method and the string::data() method // This can be used (with caution) when interfacing with C code inline T* data(); @@ -246,10 +246,10 @@ public: //- Move element to the last position. void moveLast(const label i); - //- Swap element with the first element. Fatal on an empty list. + //- Swap element with the first element. void swapFirst(const label i); - //- Swap element with the last element. Fatal on an empty list. + //- Swap element with the last element. void swapLast(const label i); //- Copy (not transfer) the argument contents @@ -292,16 +292,14 @@ public: //- Type of values the FixedList contains typedef T value_type; - //- Type that can be used for storing into - // FixedList::value_type objects + //- The type used for storing into value_type objects typedef T& reference; - //- Type that can be used for storing into - // constant FixedList::value_type objects + //- The type used for reading from constant value_type objects. typedef const T& const_reference; //- The type that can represent the difference between any two - // FixedList iterator objects + //- FixedList iterator objects typedef label difference_type; //- The type that can represent the size of a FixedList @@ -486,7 +484,8 @@ public: void writeEntry(const word& keyword, Ostream& os) const; //- Write the List, with line-breaks in ASCII if the list length - // exceeds shortListLen. Using '0' suppresses line-breaks entirely. + //- exceeds shortListLen. + // Using '0' suppresses line-breaks entirely. Ostream& writeList(Ostream& os, const label shortListLen=0) const; diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index ee03e4ad27a..842a1a100a7 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -268,13 +268,14 @@ public: // Never auto-vivify entries. inline unsigned int get(const label i) const; - //- Set value at index I. Return true if value changed. + //- Set value at index I, default value set is the max_value. // Does auto-vivify for non-existent, non-zero entries. - // Default value set is the max_value. + // \return true if value changed. inline bool set(const label i, const unsigned int val = ~0u); - //- Unset the entry at index I. Return true if value changed. + //- Unset the entry at index I. // Never auto-vivify entries. + // \return true if value changed. inline bool unset(const label i); //- Return the underlying packed storage @@ -287,8 +288,7 @@ public: //- The list length when packed inline label packedLength() const; - //- Return the binary size in number of characters - // used in the underlying storage + //- The number of bytes used in the underlying storage inline std::streamsize byteSize() const; //- Count number of bits set, O(log(n)) @@ -366,7 +366,8 @@ public: Istream& read(Istream& is); //- Write the List, with line-breaks in ASCII if the list length - // exceeds shortListLen. Using '0' suppresses line-breaks entirely. + //- exceeds shortListLen. + // Using '0' suppresses line-breaks entirely. // A special indexed output (ASCII only) is triggered by specifying // a negative value for shortListLen. // diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H index 61ddf3bed97..eac9eaf4151 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H @@ -147,19 +147,17 @@ public: // STL type definitions - //- Type of values the UList contains. + //- Type of values the list contains. typedef T value_type; - //- Type that can be used for storing into - // UList::value_type objects. + //- The type used for storing into UList::value_type objects. typedef T& reference; - //- Type that can be used for storing into - // constant UList::value_type objects + //- The type used for reading from constant UList::value_type objects typedef const T& const_reference; //- The type that can represent the difference between any two - // UList iterator objects. + //- UList iterator objects. typedef label difference_type; //- The type that can represent the size of a UList. @@ -169,8 +167,8 @@ public: // Writing //- Write the List, with line-breaks in ASCII if the list length - // exceeds shortListLen. Using '0' suppresses line-breaks entirely. - // Binary output is currently still a bit of an annoyance. + //- exceeds shortListLen. + // Using '0' suppresses line-breaks entirely. Ostream& writeList(Ostream& os, const label shortListLen=0) const; diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index b33f1706896..83ee18a8556 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -110,11 +110,11 @@ protected: void writeEntry(Ostream& os) const; //- Return a validated (start,size) subset range, which means that it - // always addresses a valid section of the list. + //- always addresses a valid section of the list. labelRange validateRange(const labelRange& range) const; //- Return a validated (start,size) subset range, which means that it - // always addresses a valid section of the list. + //- always addresses a valid section of the list. labelRange validateRange ( std::initializer_list<label> start_size_pair @@ -186,7 +186,7 @@ public: // Access //- Return the forward circular index, i.e. next index - // which returns to the first at the end of the list + //- which returns to the first at the end of the list inline label fcIndex(const label i) const; //- Return forward circular value (ie, next value in the list) @@ -196,7 +196,7 @@ public: inline T& fcValue(const label i); //- Return the reverse circular index, i.e. previous index - // which returns to the last at the beginning of the list + //- which returns to the last at the beginning of the list inline label rcIndex(const label i) const; //- Return reverse circular value (ie, previous value in the list) @@ -206,19 +206,19 @@ public: inline T& rcValue(const label i); //- Return the binary size in number of characters of the UList - // if the element is a primitive type + //- if the element is a primitive type // i.e. contiguous<T>() == true. // Note that is of type streamsize since used in stream ops std::streamsize byteSize() const; - //- Return a const pointer to the first data element, - // similar to the STL front() method and the string::data() method + //- Return a const pointer to the first data element. + // Similar to the STL front() method and the string::data() method // This can be used (with caution) when interfacing with C code inline const T* cdata() const; - //- Return a pointer to the first data element, - // similar to the STL front() method and the string::data() method + //- Return a pointer to the first data element. + // Similar to the STL front() method and the string::data() method // This can be used (with caution) when interfacing with C code inline T* data(); @@ -347,7 +347,7 @@ public: typedef const T& const_reference; //- The type that can represent the difference between any two - // UList iterator objects + //- UList iterator objects typedef label difference_type; //- The type that can represent the size of a UList @@ -539,7 +539,8 @@ public: void writeEntry(const word& keyword, Ostream& os) const; //- Write the List, with line-breaks in ASCII if the list length - // exceeds shortListLen. Using '0' suppresses line-breaks entirely. + //- exceeds shortListLen. + // Using '0' suppresses line-breaks entirely. Ostream& writeList(Ostream& os, const label shortListLen=0) const; diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index cba9bb009fa..973ad7b3ef2 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -126,7 +126,10 @@ class argList // so destructor is done last. ParRunControl parRunControl_; + //- The arguments after removing known options stringList args_; + + //- The extracted options HashTable<string> options_; word executable_; @@ -202,7 +205,7 @@ public: // Constructors //- Construct from argc and argv - // checking the arguments and options as requested + //- checking the arguments and options as requested. argList ( int& argc, @@ -344,14 +347,14 @@ public: // Edit - //- Add to a bool option to validOptions with usage information + //- Add a bool option to validOptions with usage information static void addBoolOption ( const word& opt, const string& usage = "" ); - //- Add to an option to validOptions with usage information + //- Add an option to validOptions with usage information // An option with an empty param is a bool option static void addOption ( diff --git a/src/OpenFOAM/primitives/enums/Enum.H b/src/OpenFOAM/primitives/enums/Enum.H index b57fc9891ac..85b96f314f5 100644 --- a/src/OpenFOAM/primitives/enums/Enum.H +++ b/src/OpenFOAM/primitives/enums/Enum.H @@ -105,7 +105,7 @@ public: explicit Enum(std::initializer_list<std::pair<EnumType, word>> lst); //- Construct from a list of names with values incremented from the - // specified start value. + //- specified start value. Enum(const EnumType start, std::initializer_list<word> lst); @@ -141,7 +141,7 @@ public: // Lookup //- Lookup the key in the dictionary and return the corresponding - // enumeration element based on its name. + //- enumeration element based on its name. // Fatal if anything is incorrect. EnumType lookup ( @@ -150,7 +150,7 @@ public: ) const; //- Find the key in the dictionary and return the corresponding - // enumeration element based on its name. + //- enumeration element based on its name. // Return the default value if the key was not found in the dictionary. // Fatal if the enumerated name was incorrect. EnumType lookupOrDefault @@ -162,7 +162,7 @@ public: //- Find the key in the dictionary and return the corresponding - // enumeration element based on its name. + //- enumeration element based on its name. // Return the default value if the key was not found in the dictionary // or if the enumerated name was incorrect (emit warning) EnumType lookupOrFailsafe -- GitLab From dd838766be3e07a90381865e30ef7d7dbb8ab843 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 4 Nov 2017 14:30:14 +0100 Subject: [PATCH 089/126] STYLE: make memorybuf naming more consistent with std iostreams --- src/OpenFOAM/db/IOstreams/memory/OListStream.H | 2 +- src/OpenFOAM/db/IOstreams/memory/UIListStream.H | 2 +- src/OpenFOAM/db/IOstreams/memory/UOListStream.H | 2 +- .../db/IOstreams/memory/memoryStreamBuffer.H | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/memory/OListStream.H b/src/OpenFOAM/db/IOstreams/memory/OListStream.H index 756394e6fa2..78796b338ce 100644 --- a/src/OpenFOAM/db/IOstreams/memory/OListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/OListStream.H @@ -65,7 +65,7 @@ class OListStreamAllocator //- A streambuf adapter to output to a List class listbuf : - public memorybuf::output + public memorybuf::out { friend OListStreamAllocator; diff --git a/src/OpenFOAM/db/IOstreams/memory/UIListStream.H b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H index e7db211c1d5..8235b2edd5c 100644 --- a/src/OpenFOAM/db/IOstreams/memory/UIListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H @@ -82,7 +82,7 @@ class UIListStreamAllocator //- A streambuf class for input from UList or equivalent class ulistbuf : - public memorybuf::input + public memorybuf::in { friend UIListStreamAllocator; diff --git a/src/OpenFOAM/db/IOstreams/memory/UOListStream.H b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H index 5500fb53831..df255cd92e3 100644 --- a/src/OpenFOAM/db/IOstreams/memory/UOListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H @@ -100,7 +100,7 @@ class UOListAllocator //- A streambuf adapter for output to UList or equivalent class ulistbuf : - public memorybuf::output + public memorybuf::out { friend UOListAllocator; diff --git a/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H index d0f412f1a43..48bfd45ddb8 100644 --- a/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H +++ b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H @@ -129,17 +129,17 @@ protected: public: // Forward declarations - class input; - class output; + class in; + class out; }; /*---------------------------------------------------------------------------*\ - Class memorybuf::input Declaration + Class memorybuf::in Declaration \*---------------------------------------------------------------------------*/ -//- An output streambuf for memory access -class memorybuf::input +//- An input streambuf for memory access +class memorybuf::in : public memorybuf { @@ -175,11 +175,11 @@ protected: /*---------------------------------------------------------------------------*\ - Class memorybuf::output Declaration + Class memorybuf::out Declaration \*---------------------------------------------------------------------------*/ //- An output streambuf for memory access -class memorybuf::output +class memorybuf::out : public memorybuf { -- GitLab From 590b319a7842420ae9be5b9095c5f81677357d24 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 4 Nov 2017 14:59:59 +0100 Subject: [PATCH 090/126] TUT: 'restore0Dir -processors' with filtering of #include files --- bin/tools/RunFunctions | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index 06272605bcd..55ab42d175b 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -340,8 +340,8 @@ cloneParallelCase() # restore0Dir() { - if [ "$1" = "-processor" ] - then + case "$1" in + -processor | -processors) echo "Restore 0/ from 0.orig/ for processor directories" [ -d 0.orig ] || echo " Warning: no 0.orig/ found" @@ -349,7 +349,24 @@ restore0Dir() \ls -d processor* | xargs -I {} \rm -rf ./{}/0 \ls -d processor* | xargs -I {} \cp -r 0.orig ./{}/0 > /dev/null 2>&1 - else + # Remove '#include' directives from field dictionaries + # for collated format + if [ "$1" = "-processors" ] + then + ( + echo "Filter #include directives in processors/0:" + cd processors/0 2>/dev/null || exit 0 + for file in $(grep -l "#include" * 2> /dev/null) + do + foamDictionary "$file" > "$file.$$." && mv "$file.$$." "$file" + echo " $file" + done | tr -d '\n' + echo + ) + fi + ;; + + *) echo "Restore 0/ from 0.orig/" if [ -d 0.orig ] then @@ -358,7 +375,8 @@ restore0Dir() else echo " Warning: no 0.orig/ found" fi - fi + ;; + esac } -- GitLab From 507486194e7a8973f76b8126a1fd97fb8762355f Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 4 Nov 2017 15:51:52 +0100 Subject: [PATCH 091/126] ENH: improved parallel transfer of strings - support send/receive with embedded '\0' characters --- applications/test/parallel/Test-parallel.C | 34 +++++++++++++++++-- .../db/IOstreams/Pstreams/UIPstream.C | 31 ++++++++++------- .../db/IOstreams/Pstreams/UIPstream.H | 2 +- .../db/IOstreams/Pstreams/UOPstream.C | 2 +- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/applications/test/parallel/Test-parallel.C b/applications/test/parallel/Test-parallel.C index 14ba97f7a56..ec5546c6759 100644 --- a/applications/test/parallel/Test-parallel.C +++ b/applications/test/parallel/Test-parallel.C @@ -120,6 +120,24 @@ void testMapDistribute() } +// Print to Perr +template<class T> +Ostream& perrInfo(const T& data) +{ + Perr<< data; + return Perr; +} + + +// Print to Perr +template<> +Ostream& perrInfo(const string& data) +{ + Perr<< data << " (size: " << data.size() << ")"; + return Perr; +} + + template<class T> void testTransfer(const T& input) { @@ -127,7 +145,8 @@ void testTransfer(const T& input) if (Pstream::master()) { - Perr<<"test transfer (" << (typeid(T).name()) << "): " << data << nl << endl; + Perr<<"test transfer (" << (typeid(T).name()) << "): "; + perrInfo(data) << nl << endl; } if (Pstream::myProcNo() != Pstream::masterNo()) @@ -141,7 +160,7 @@ void testTransfer(const T& input) Perr<< "slave receiving from master " << Pstream::masterNo() << endl; IPstream fromMaster(Pstream::commsTypes::blocking, Pstream::masterNo()); fromMaster >> data; - Perr<< data << endl; + perrInfo(data) << endl; } else { @@ -155,7 +174,7 @@ void testTransfer(const T& input) Perr<< "master receiving from slave " << slave << endl; IPstream fromSlave(Pstream::commsTypes::blocking, slave); fromSlave >> data; - Perr<< data << endl; + perrInfo(data) << endl; } for @@ -258,6 +277,15 @@ int main(int argc, char *argv[]) testTransfer(scalar(3.14159)); testTransfer(string("test string")); testTransfer(string(" x ")); + + { + // Slightly roundabout way to construct with a nul in string + string str1("embedded. nul character in string"); + str1[8] = '\0'; + + Info<< "len: " << str1.size() << endl; + testTransfer(str1); + } testTransfer(word("3.141 59")); // bad word, but transfer doesn't care testTokenized(label(1234)); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index 21b412fce39..0e40098fa55 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -42,12 +42,12 @@ inline void Foam::UIPstream::checkEof() template<class T> -inline void Foam::UIPstream::readFromBuffer(T& t) +inline void Foam::UIPstream::readFromBuffer(T& val) { const size_t align = sizeof(T); externalBufPosition_ = align + ((externalBufPosition_ - 1) & ~(align - 1)); - t = reinterpret_cast<T&>(externalBuf_[externalBufPosition_]); + val = reinterpret_cast<T&>(externalBuf_[externalBufPosition_]); externalBufPosition_ += sizeof(T); checkEof(); } @@ -67,10 +67,14 @@ inline void Foam::UIPstream::readFromBuffer + ((externalBufPosition_ - 1) & ~(align - 1)); } - const char* bufPtr = &externalBuf_[externalBufPosition_]; - char* dataPtr = reinterpret_cast<char*>(data); - size_t i = count; - while (i--) *dataPtr++ = *bufPtr++; + const char* const __restrict__ buf = &externalBuf_[externalBufPosition_]; + char* const __restrict__ output = reinterpret_cast<char*>(data); + + for (size_t i = 0; i < count; ++i) + { + output[i] = buf[i]; + } + externalBufPosition_ += count; checkEof(); } @@ -78,14 +82,15 @@ inline void Foam::UIPstream::readFromBuffer inline Foam::Istream& Foam::UIPstream::readStringFromBuffer(std::string& str) { + // Use std::string::assign() to copy content, including '\0'. + // Stripping (when desired) is the responsibility of the sending side. + size_t len; readFromBuffer(len); - // Uses the underlying std::string::operator=() - // - no stripInvalid invoked (the sending side should have done that) - // - relies on trailing '\0' char (so cannot send anything with an embedded - // nul char) - str = &externalBuf_[externalBufPosition_]; - externalBufPosition_ += len + 1; + + str.assign(&externalBuf_[externalBufPosition_], len); + + externalBufPosition_ += len; checkEof(); return *this; @@ -276,7 +281,7 @@ Foam::Istream& Foam::UIPstream::read(token& t) Foam::Istream& Foam::UIPstream::read(char& c) { c = externalBuf_[externalBufPosition_]; - externalBufPosition_++; + ++externalBufPosition_; checkEof(); return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H index d0c0f865529..04115646f12 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H @@ -80,7 +80,7 @@ class UIPstream //- Read a T from the transfer buffer template<class T> - inline void readFromBuffer(T& t); + inline void readFromBuffer(T& val); //- Read count bytes of data from the transfer buffer // using align byte alignment diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index eb54b5ea61a..b94ede40563 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -109,7 +109,7 @@ inline void Foam::UOPstream::writeStringToBuffer(const std::string& str) { const size_t len = str.size(); writeToBuffer(len); - writeToBuffer(str.c_str(), len + 1, 1); + writeToBuffer(str.data(), len, 1); } -- GitLab From 3d13220df43728a4360303ab92df8322fa222dfa Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 4 Nov 2017 16:05:32 +0100 Subject: [PATCH 092/126] STYLE: relocate charList typedef to containers --- src/OpenFOAM/containers/Lists/List/List.H | 2 ++ src/OpenFOAM/containers/Lists/UList/UList.H | 1 + src/OpenFOAM/graph/curve/curveTools.H | 4 ---- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index aaacbda88b2..e2224c8c3cd 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -75,6 +75,8 @@ template<class T> class IndirectList; template<class T> class UIndirectList; template<class T> class BiIndirectList; +typedef List<char> charList; + /*---------------------------------------------------------------------------*\ Class List Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 83ee18a8556..e0893960df8 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -67,6 +67,7 @@ template<class T> class UList; template<class T> Ostream& operator<<(Ostream&, const UList<T>&); template<class T> Istream& operator>>(Istream&, UList<T>&); +typedef UList<char> charUList; typedef UList<label> labelUList; /*---------------------------------------------------------------------------*\ diff --git a/src/OpenFOAM/graph/curve/curveTools.H b/src/OpenFOAM/graph/curve/curveTools.H index 04787e4e800..4963c23bb38 100644 --- a/src/OpenFOAM/graph/curve/curveTools.H +++ b/src/OpenFOAM/graph/curve/curveTools.H @@ -15,10 +15,6 @@ namespace Foam #define curveSmall 1.0e-8 #define curveGreat 1.0e8 -typedef List<char> charList; -typedef List<charList> charListList; - - scalar distance(const vector&, const vector&); -- GitLab From 061a85858f4243ad0c119399493de43f219398ca Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sat, 4 Nov 2017 17:25:26 +0100 Subject: [PATCH 093/126] ENH: support method/spawn as mpirunDebug command-line options --- bin/mpirunDebug | 218 ++++++++++++++++++++++++++++++------------------ 1 file changed, 139 insertions(+), 79 deletions(-) diff --git a/bin/mpirunDebug b/bin/mpirunDebug index 3be74baa251..943ffee111e 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -4,7 +4,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) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -26,50 +26,90 @@ # mpirunDebug # # Description -# Driver script to run mpi jobs with the processes in separate -# windows or to separate log files. +# Driver script to run mpi jobs with the processes in a separate XTerm +# or to separate log files. # Requires bash on all processors. #------------------------------------------------------------------------------ +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE -if [ `uname -s` = Linux ] -then +Usage: ${0##*/} [OPTION] -np <N> <executable> <args> + +options: + -method=MODE Run mode + (0) normal + (1) gdb+xterm + (2) gdb + (3) log + (4) log+xterm + (5) xterm+valgrind + (6) gperftools(callgrind) + -spawn=TYPE Spawn type: (1) local (2) remote + -log Alias for -method=3 + -local Alias for -spawn=1 + -yes Start without additional prompt + -help Print the usage + +Invoke mpirun but with each process in a separate XTerm, or to separate logfile + +USAGE + exit 1 +} + +case "$(uname -s)" in +Linux) ECHO='echo -e' -else + ;; +*) ECHO='echo' -fi + ;; +esac +unset nProcs appName appArgs +unset method spawn optNoAsk -usage() -{ - cat<<USAGE +# parse options +while [ "$#" -gt 0 ] +do + # echo "$1" 1>&2 + case "$1" in + -help) + usage + ;; -Usage: ${0##*/} -np <dd> <executable> <args> + -method=[0-6]) + method="${1#*=}" + ;; -* This will run like mpirun but with each process in an XTerm + -spawn=[1-2]) + spawn="${1#*=}" + ;; -USAGE - exit 1 -} + -log) + method=3 + ;; -unset nProcs exec args + -local) + spawn=1 + ;; + + -yes) + optNoAsk=true + ;; -while [ "$1" != "" ] -do - echo "$1" - case $1 in -np) nProcs=$2 shift ;; + *) - if [ ! "$exec" ] - then - exec=$1 - elif [ ! "$args" ] + if [ -z "$appName" ] then - args="\"$1\"" + appName="$1" else - args="$args \"$1\"" + appArgs="${appArgs}${appArgs:+ }\"$1\"" fi ;; esac @@ -77,54 +117,61 @@ do done echo "nProcs=$nProcs" -echo "exec=$exec" -echo "args=$args" +echo "exec=$appName" +echo "args=$appArgs" -[ "$nProcs" ] || usage -[ "$args" ] || usage -[ "$exec" ] || usage +[ -n "$nProcs" ] || usage +[ -n "$appArgs" ] || usage +[ -n "$appName" ] || usage -exec=`which $exec` -if [ ! -x "$exec" ] -then - echo "Cannot find executable $exec or is not executable" - usage -fi +exec=$(command -v $appName) +[ -x "$exec" ] || { + echo "Cannot find executable $appName or is not executable" + usage +} -if [ ! "$PWD" ] -then - PWD=`pwd` -fi +[ -n "$PWD" ] || PWD=$(pwd) -echo "run $args" > $PWD/gdbCommands +echo "run $appArgs" > $PWD/gdbCommands echo "where" >> $PWD/gdbCommands echo "Constructed gdb initialization file $PWD/gdbCommands" -$ECHO "Choose running method: 0)normal 1)gdb+xterm 2)gdb 3)log 4)log+xterm 5)xterm+valgrind 6)gperftools(callgrind): \c" -read method -case "$method" in -0 | 1 | 2 | 3 | 4 | 5 | 6) - # okay - ;; -*) - usage - ;; -esac +# Choose method +if [ -z "$method" ] +then + $ECHO "Choose running method: 0)normal 1)gdb+xterm 2)gdb 3)log 4)log+xterm 5)xterm+valgrind 6)gperftools(callgrind): \c" + read method + case "$method" in + 0 | 1 | 2 | 3 | 4 | 5 | 6) + # okay + ;; + *) + usage + ;; + esac +fi -$ECHO "Run all processes local or distributed? 1)local 2)remote: \c" -read spawn -if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ] +# Choose spawn +if [ -z "$spawn" ] then - usage + $ECHO "Run all processes local or distributed? 1)local 2)remote: \c" + read spawn + case "$spawn" in + 1 | 2) + # okay + ;; + *) + usage + ;; + esac fi # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/ # check <installedProject>/etc/ -if [ "$WM_PROJECT" ] +if [ -n "$WM_PROJECT" ] then - for i in \ $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT \ @@ -143,7 +190,7 @@ fi # Source OpenFOAM settings if OpenFOAM environment not set. # attempt to preserve the installation directory 'FOAM_INST_DIR' # use FOAM_SETTINGS to pass command-line settings -if [ "$FOAM_INST_DIR" ] +if [ -n "$FOAM_INST_DIR" ] then sourceFoam="FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS" else @@ -162,49 +209,53 @@ for ((proc=0; proc<$nProcs; proc++)) do procCmdFile="$PWD/processor${proc}.sh" procLog="processor${proc}.log" - geom="-geometry 120x15+$xpos+$ypos" + xterm="xterm -font fixed -title processor${proc} -geometry 120x15+$xpos+$ypos" + unset node case "$WM_MPLIB" in *OPENMPI) node="-np 1 " ;; - *) - node="" esac echo "#!/bin/bash" > $procCmdFile + echo "$sourceFoam" >> $procCmdFile + echo "cd $PWD" >> $procCmdFile + case "$method" in 0) - echo "$sourceFoam; cd $PWD; $exec $args | tee $procLog" >> $procCmdFile echo "${node}$procCmdFile" >> $PWD/mpirun.schema + echo "$exec $appArgs | tee $procLog" >> $procCmdFile ;; 1) - echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile - #echo "$sourceFoam; cd $PWD; $exec $args; read dummy" >> $procCmdFile - echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema + echo "${node}$xterm -e $procCmdFile" >> $PWD/mpirun.schema + echo "gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog" + echo "read dummy" ;; 2) - echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec > $procLog 2>&1" >> $procCmdFile echo "${node}$procCmdFile" >> $PWD/mpirun.schema + echo "gdb -command $PWD/gdbCommands $exec > $procLog 2>&1" ;; 3) - echo "$sourceFoam; cd $PWD; $exec $args > $procLog 2>&1" >> $procCmdFile echo "${node}$procCmdFile" >> $PWD/mpirun.schema + echo "$exec $appArgs > $procLog 2>&1" ;; 4) - echo "$sourceFoam; cd $PWD; $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile - echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema + echo "${node}$xterm -e $procCmdFile" >> $PWD/mpirun.schema + echo "$exec $appArgs 2>&1 | tee $procLog" + echo "read dummy" ;; 5) - echo "$sourceFoam; cd $PWD; valgrind --leak-check=full --show-reachable=yes $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile - echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema + echo "${node}$xterm -e $procCmdFile" >> $PWD/mpirun.schema + echo "valgrind --leak-check=full --show-reachable=yes $exec $appArgs 2>&1 | tee $procLog" + echo "read dummy" ;; 6) - echo "$sourceFoam; cd $PWD; CPUPROFILE=log.profiler_$proc $exec $args; \ - pprof --callgrind $exec log.profiler_$proc > log.profiler_$proc.callgrind;" >> $procCmdFile echo "${node}$procCmdFile" >> $PWD/mpirun.schema + echo "CPUPROFILE=log.profiler_$proc $exec $appArgs" + echo "pprof --callgrind $exec log.profiler_$proc > log.profiler_$proc.callgrind" ;; - esac + esac >> $procCmdFile chmod +x $procCmdFile @@ -255,11 +306,20 @@ MPICH) esac echo "Constructed $PWD/mpirun.schema file." -echo "" +echo echo " $cmd" -echo "" -$ECHO "Press return to execute.\c" -read dummy +echo + +if [ -n "$optNoAsk" ] +then + echo "starting: " $(date '+%Y-%m-%d %H:%M:%S %z' 2>/dev/null) + echo +else + # Pause before running + $ECHO "Press return to execute.\c" + read dummy +fi + exec $cmd #------------------------------------------------------------------------------ -- GitLab From cae8a894cd9ea21967d5671513e9330f5b68366e Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 6 Nov 2017 09:25:58 +0100 Subject: [PATCH 094/126] ENH: allow creation of ITstream by parsing string --- applications/test/ITstream/Make/files | 3 + applications/test/ITstream/Make/options | 2 + applications/test/ITstream/Test-ITstream.C | 137 ++++++++++++++++++ src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C | 85 ++++++++++- src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H | 45 +++++- 5 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 applications/test/ITstream/Make/files create mode 100644 applications/test/ITstream/Make/options create mode 100644 applications/test/ITstream/Test-ITstream.C diff --git a/applications/test/ITstream/Make/files b/applications/test/ITstream/Make/files new file mode 100644 index 00000000000..6b70c4ea837 --- /dev/null +++ b/applications/test/ITstream/Make/files @@ -0,0 +1,3 @@ +Test-ITstream.C + +EXE = $(FOAM_USER_APPBIN)/Test-ITstream diff --git a/applications/test/ITstream/Make/options b/applications/test/ITstream/Make/options new file mode 100644 index 00000000000..18e6fe47afa --- /dev/null +++ b/applications/test/ITstream/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/ITstream/Test-ITstream.C b/applications/test/ITstream/Test-ITstream.C new file mode 100644 index 00000000000..a81e8585eed --- /dev/null +++ b/applications/test/ITstream/Test-ITstream.C @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + +\*---------------------------------------------------------------------------*/ + +#include "ListStream.H" +#include "UListStream.H" +#include "wordList.H" +#include "IOstreams.H" +#include "argList.H" +#include "ITstream.H" + +using namespace Foam; + +template<class T> +Ostream& toString(Ostream& os, const T& str) +{ + os << str; + return os; +} + + +template<> +Ostream& toString(Ostream& os, const UList<char>& list) +{ + for (const char c : list) + { + os << c; + } + + return os; +} + + +template<> +Ostream& toString(Ostream& os, const List<char>& list) +{ + for (const char c : list) + { + os << c; + } + + return os; +} + + +void printTokens(Istream& is) +{ + label count = 0; + token t; + while (is.good()) + { + is >> t; + if (t.good()) + { + ++count; + Info<<"token: " << t << endl; + } + } + + Info<< count << " tokens" << endl; +} + + +template<class BUF> +void doTest(const string& name, const BUF& input, bool verbose=false) +{ + Info<<"test " << name.c_str() << ":" << nl + <<"====" << nl; + toString(Info, input) + << nl + <<"====" << nl << endl; + + ITstream its(name, input); + Info<< "got " << its.size() << " tokens - index at " + << its.tokenIndex() << endl; + + if (verbose) + { + for (const token& tok : its) + { + Info<< " " << tok.info() << nl; + } + Info<< nl; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + const char* charInput = + "( const char input \"string\" to tokenize )" + "List<label> 5(0 1 2 3 4);"; + + string stringInput("( string ; input \"string\" to tokenize )"); + + List<char> listInput(stringInput.cbegin(), stringInput.cend()); + + doTest("char*", charInput, true); + doTest("string", stringInput, true); + doTest("List<char>", listInput, true); + + reverse(listInput); + doTest("List<char>", listInput, true); + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C index c0890dad9d5..ca31271fa32 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,8 +25,89 @@ License #include "error.H" #include "ITstream.H" +#include "UIListStream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::ITstream::toTokenList(ISstream& is) +{ + tokenIndex_ = 0; + + token tok; + + while (!is.read(tok).bad() && tok.good()) + { + newElmt(tokenIndex()++) = std::move(tok); + } + + tokenList::setSize(tokenIndex()); + + setOpened(); + ITstream::rewind(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::ITstream::ITstream +( + const string& name, + const UList<char>& input, + streamFormat format, + versionNumber version +) +: + Istream(format, version), + tokenList(16, token::undefinedToken), + name_(name), + tokenIndex_(0) +{ + UIListStream is(input, format, version); + + toTokenList(is); +} + + +Foam::ITstream::ITstream +( + const string& name, + const std::string& input, + streamFormat format, + versionNumber version +) +: + Istream(format, version), + tokenList(16, token::undefinedToken), + name_(name), + tokenIndex_(0) +{ + UIListStream is(input.data(), input.size(), format, version); + + toTokenList(is); +} + + +Foam::ITstream::ITstream +( + const string& name, + const char* input, + streamFormat format, + versionNumber version +) +: + Istream(format, version), + tokenList(16, token::undefinedToken), + name_(name), + tokenIndex_(0) +{ + const size_t len = strlen(input); + UIListStream is(input, len, format, version); + + toTokenList(is); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::ITstream::print(Ostream& os) const { diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H index b8414cc4f23..af9fff4bef9 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,6 +43,10 @@ SourceFiles namespace Foam { +// Forward declaration +class ISstream; + + /*---------------------------------------------------------------------------*\ Class ITstream Declaration \*---------------------------------------------------------------------------*/ @@ -61,6 +65,12 @@ class ITstream label tokenIndex_; + // Private Member Functions + + //- Convert input sequence into tokens and append to the token list + void toTokenList(ISstream& input); + + public: // Constructors @@ -103,6 +113,39 @@ public: } + //- Construct token list by parsing the input character sequence + // Uses UIListStream internally. + ITstream + ( + const string& name, + const UList<char>& input, + streamFormat format=ASCII, + versionNumber version=currentVersion + ); + + + //- Construct token list by parsing the input string + // Uses UIListStream internally. + ITstream + ( + const string& name, + const std::string& input, + streamFormat format=ASCII, + versionNumber version=currentVersion + ); + + + //- Construct token list by parsing the input character sequence + // Uses UIListStream internally. + ITstream + ( + const string& name, + const char* input, + streamFormat format=ASCII, + versionNumber version=currentVersion + ); + + //- Construct as copy ITstream(const ITstream& its) : -- GitLab From e1b71c028cdeed15ead181db316504d8fba47719 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 5 Nov 2017 13:26:10 +0100 Subject: [PATCH 095/126] ENH: add move/swap semantics to string types and regExp - move append() single element to List and DynamicList ENH: add stringOps::count to avoid unnecessary string conversions --- applications/test/regex/Test-regex.C | 20 +++++- applications/test/string/Test-string.C | 59 +++++++++++++++++ applications/test/wordRe/Test-wordRe.C | 52 ++++++++++++++- src/OSspecific/POSIX/regExp.H | 12 +++- src/OSspecific/POSIX/regExpI.H | 23 +++++++ .../Lists/DynamicList/DynamicList.H | 3 + .../Lists/DynamicList/DynamicListI.H | 62 ++++++++++++------ src/OpenFOAM/containers/Lists/List/List.H | 5 +- src/OpenFOAM/containers/Lists/List/ListI.H | 32 +++++++--- src/OpenFOAM/containers/Lists/List/ListIO.C | 11 ++-- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C | 9 +-- .../primitives/strings/fileName/fileName.C | 6 +- .../primitives/strings/keyType/keyType.H | 39 ++++++++---- .../primitives/strings/keyType/keyTypeI.H | 63 ++++++++++++++++--- .../primitives/strings/string/string.C | 12 +--- .../primitives/strings/string/string.H | 11 +++- .../primitives/strings/string/stringI.H | 6 ++ .../primitives/strings/stringOps/stringOps.C | 41 ++++++++++++ .../primitives/strings/stringOps/stringOps.H | 8 +++ src/OpenFOAM/primitives/strings/word/word.C | 31 +++++++-- src/OpenFOAM/primitives/strings/word/word.H | 38 ++++++++--- src/OpenFOAM/primitives/strings/word/wordI.H | 62 +++++++++++++----- .../primitives/strings/wordRe/wordRe.H | 17 ++--- .../primitives/strings/wordRe/wordReI.H | 21 +++++++ 24 files changed, 523 insertions(+), 120 deletions(-) diff --git a/applications/test/regex/Test-regex.C b/applications/test/regex/Test-regex.C index 6f506f76594..6996d4445ce 100644 --- a/applications/test/regex/Test-regex.C +++ b/applications/test/regex/Test-regex.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) Info<< "Test expressions:" << rawList << endl; IOobject::writeDivider(Info) << endl; - List<string> groups; + List<std::string> groups; // Report matches: forAll(rawList, elemI) @@ -74,7 +74,23 @@ int main(int argc, char *argv[]) Info<< "false"; } } + Info<< endl; + + if (false) + { + regExp re2(std::move(re)); + Info<<"move construct: " << re.exists() << "/" << re2.exists() + << endl; + + re = std::move(re2); + Info<<"move assign: " << re.exists() << "/" << re2.exists() + << endl; + + re.swap(re2); + Info<<"swap: " << re.exists() << "/" << re2.exists() + << endl; + } } Info<< nl << "test regExp(const char*) ..." << endl; diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C index 7975620442b..73c703d170b 100644 --- a/applications/test/string/Test-string.C +++ b/applications/test/string/Test-string.C @@ -69,6 +69,65 @@ int main(int argc, char *argv[]) Info<<"trimRight: " << stringOps::trimRight(test) << endl; Info<<"trim: " << stringOps::trim(test) << endl; + if (false) + { + Info<<"test move construct - string size:" << test.size() << nl; + string test2(std::move(test)); + + Info<<"input size:" << test.size() << nl; + Info<<"moved size:" << test2.size() << nl; + + Info<<"test move assign - string sizes:" + << test.size() << "/" << test2.size() << nl; + + test = std::move(test2); + + Info<<"input size:" << test.size() << nl; + Info<<"moved size:" << test2.size() << nl; + } + + if (false) + { + std::string str("some text"); + + Info<<"test move construct to string:" << str.size() << nl; + + Foam::string test2(std::move(str)); + + Info<<"input/moved sizes:" << str.size() << "/" << test2.size() << nl; + + str = std::move(test2); + + Info<<"test move assign - sizes:" + << str.size() << "/" << test2.size() << nl; + } + + if (false) + { + Foam::string str("thisIsAWord"); + + Info<<"test move construct to word:" << str.size() << nl; + + word test2(std::move(str)); + + Info<<"input/moved sizes:" << str.size() << "/" << test2.size() << nl; + + str = std::move(test2); + + Info<<"test move assign - sizes:" + << str.size() << "/" << test2.size() << nl; + + // move back + test2.swap(str); + + Info<<"test move assign - sizes:" + << str.size() << "/" << test2.size() << nl; + + string str2(std::move(test2)); + Info<<"input/moved sizes:" << test2.size() << "/" << str2.size() << nl; + + } + { fileName test1("libFooBar.so"); diff --git a/applications/test/wordRe/Test-wordRe.C b/applications/test/wordRe/Test-wordRe.C index be1af08a549..5504e66a1ea 100644 --- a/applications/test/wordRe/Test-wordRe.C +++ b/applications/test/wordRe/Test-wordRe.C @@ -56,6 +56,56 @@ int main(int argc, char *argv[]) {"file[a-b]", wordRe::REGEX}, }; + if (true) + { + Info<<"keyType: " << keyre << endl; + + keyType key2(std::move(keyre)); + + Info<<"move construct: <" << keyre << "> <" << key2 << ">" << endl; + + keyre = std::move(key2); + + Info<<"move assign: <" << keyre << "> <" << key2 << ">" << endl; + + keyType key3; + + keyre.swap(key3); + + Info<<"swap: <" << keyre << "> <" << key3 << ">" << endl; + + keyre = std::move(key3); + Info<<"move assign: <" << keyre << "> <" << key3 << ">" << endl; + + return 0; + } + + if (false) + { + wordRe keyre("y.*", wordRe::REGEX); + + Info<<"wordRe: " << keyre << endl; + + wordRe key2(std::move(keyre)); + + Info<<"keyTypes: " << keyre << " " << key2 << endl; + + keyre = std::move(key2); + + Info<<"keyTypes: " << keyre << " " << key2 << endl; + + wordRe key3; + + keyre.swap(key3); + + Info<<"keyTypes: <" << keyre << "> <" << key3 << ">" << endl; + + keyre = std::move(key3); + Info<<"keyTypes: <" << keyre << "> <" << key3 << ">" << endl; + + return 0; + } + wordRes wrelist(wordrelist); Info<< "re-list:" << wrelist() << endl; @@ -76,7 +126,7 @@ int main(int argc, char *argv[]) wre = "this .* file"; - Info<<"substring: " << wre(4) << endl; + Info<<"substring: " << wre.substr(4) << endl; wre.info(Info) << endl; wre = s1; diff --git a/src/OSspecific/POSIX/regExp.H b/src/OSspecific/POSIX/regExp.H index 6a03192cf27..c5c78929092 100644 --- a/src/OSspecific/POSIX/regExp.H +++ b/src/OSspecific/POSIX/regExp.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -113,6 +113,9 @@ public: //- Construct from string, optionally ignore case inline regExp(const std::string& pattern, bool ignoreCase); + //- Move construct + inline regExp(regExp&& rgx); + //- Destructor inline ~regExp(); @@ -146,6 +149,9 @@ public: // \return True if expression had existed prior to the clear. bool clear(); + //- Swap contents + inline void swap(regExp& rgx); + // Matching/Searching @@ -177,6 +183,10 @@ public: //- Assign and compile pattern from string // Always case sensitive inline void operator=(const std::string& pattern); + + //- Move assignment + inline void operator=(regExp&& rgx); + }; diff --git a/src/OSspecific/POSIX/regExpI.H b/src/OSspecific/POSIX/regExpI.H index 7302e02410b..60c7da3053b 100644 --- a/src/OSspecific/POSIX/regExpI.H +++ b/src/OSspecific/POSIX/regExpI.H @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include <algorithm> + // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -78,6 +80,14 @@ inline Foam::regExp::regExp(const std::string& pattern, bool ignoreCase) } +inline Foam::regExp::regExp(regExp&& rgx) +: + preg_(rgx.preg_) +{ + rgx.preg_ = nullptr; +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // inline Foam::regExp::~regExp() @@ -112,6 +122,12 @@ inline bool Foam::regExp::search(const std::string& text) const } +inline void Foam::regExp::swap(regExp& rgx) +{ + std::swap(preg_, rgx.preg_); +} + + // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // inline bool Foam::regExp::operator()(const std::string& text) const @@ -132,4 +148,11 @@ inline void Foam::regExp::operator=(const std::string& pattern) } +inline void Foam::regExp::operator=(regExp&& rgx) +{ + clear(); + swap(rgx); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 20f9258bda0..002a3e92274 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -249,6 +249,9 @@ public: //- Append an element to the end of this list. inline DynamicList<T, SizeMin>& append(const T& val); + //- Move append an element + inline DynamicList<T, SizeMin>& append(T&& val); + //- Append another list to the end of this list. inline DynamicList<T, SizeMin>& append(const UList<T>& lst); diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index c6adaec88fe..81ec482e212 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -492,7 +492,22 @@ Foam::DynamicList<T, SizeMin>::append const label idx = List<T>::size(); setSize(idx + 1); - this->operator[](idx) = val; + this->operator[](idx) = val; // copy element + return *this; +} + + +template<class T, int SizeMin> +inline Foam::DynamicList<T, SizeMin>& +Foam::DynamicList<T, SizeMin>::append +( + T&& val +) +{ + const label idx = List<T>::size(); + setSize(idx + 1); + + this->operator[](idx) = std::move(val); // move assign element return *this; } @@ -510,12 +525,13 @@ Foam::DynamicList<T, SizeMin>::append << "Attempted appending to self" << abort(FatalError); } - label nextFree = List<T>::size(); - setSize(nextFree + lst.size()); + label idx = List<T>::size(); + + setSize(idx + lst.size()); for (const T& val : lst) { - this->operator[](nextFree++) = val; + this->operator[](idx++) = val; // copy element } return *this; } @@ -529,12 +545,12 @@ Foam::DynamicList<T, SizeMin>::append const FixedList<T, FixedSize>& lst ) { - label nextFree = List<T>::size(); - setSize(nextFree + lst.size()); + label idx = List<T>::size(); + setSize(idx + lst.size()); for (const T& val : lst) { - this->operator[](nextFree++) = val; + this->operator[](idx++) = val; // copy element } return *this; } @@ -547,12 +563,13 @@ Foam::DynamicList<T, SizeMin>::append std::initializer_list<T> lst ) { - label nextFree = List<T>::size(); - setSize(nextFree + lst.size()); + label idx = List<T>::size(); + + setSize(idx + lst.size()); for (const T& val : lst) { - this->operator[](nextFree++) = val; + this->operator[](idx++) = val; // copy element } return *this; } @@ -565,12 +582,14 @@ Foam::DynamicList<T, SizeMin>::append const UIndirectList<T>& lst ) { - label nextFree = List<T>::size(); - setSize(nextFree + lst.size()); + label idx = List<T>::size(); + const label n = lst.size(); + + setSize(idx + n); - forAll(lst, elemI) + for (label i=0; i<n; ++i) { - this->operator[](nextFree++) = lst[elemI]; + this->operator[](idx++) = lst[i]; // copy element } return *this; } @@ -589,12 +608,13 @@ Foam::DynamicList<T, SizeMin>::append << "Attempted appending to self" << abort(FatalError); } - label nextFree = List<T>::size(); - setSize(nextFree + lst.size()); + label idx = List<T>::size(); + + setSize(idx + lst.size()); for (T& val : lst) { - Foam::Swap(this->operator[](nextFree++), val); + Foam::Swap(this->operator[](idx++), val); // moved content } lst.clear(); @@ -779,11 +799,13 @@ inline void Foam::DynamicList<T, SizeMin>::operator= const FixedList<T, FixedSize>& lst ) { - setSize(lst.size()); + const label n = lst.size(); + + setSize(n); - forAll(lst, i) + for (label i=0; i<n; ++i) { - this->operator[](i) = lst[i]; + this->operator[](i) = lst[i]; // copy element } } diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index e2224c8c3cd..843272099f8 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -226,7 +226,10 @@ public: //- Append an element at the end of the list inline void append(const T& val); - //- Append a List at the end of this list + //- Move append an element at the end of the list + inline void append(T&& val); + + //- Append a List to the end of this list inline void append(const UList<T>& lst); //- Append a UIndirectList at the end of this list diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H index f93a099bb49..b815a32d871 100644 --- a/src/OpenFOAM/containers/Lists/List/ListI.H +++ b/src/OpenFOAM/containers/Lists/List/ListI.H @@ -172,7 +172,17 @@ inline Foam::Xfer<Foam::List<T>> Foam::List<T>::xfer() template<class T> inline void Foam::List<T>::append(const T& val) { - setSize(this->size()+1, val); + setSize(this->size() + 1, val); // copy element +} + + +template<class T> +inline void Foam::List<T>::append(T&& val) +{ + const label idx = this->size(); + setSize(idx + 1); + + this->operator[](idx) = std::move(val); // move assign element } @@ -185,12 +195,14 @@ inline void Foam::List<T>::append(const UList<T>& lst) << "attempted appending to self" << abort(FatalError); } - label nextFree = this->size(); - setSize(nextFree + lst.size()); + label idx = this->size(); + const label n = lst.size(); - forAll(lst, i) + setSize(idx + n); + + for (label i=0; i<n; ++i) { - this->operator[](nextFree++) = lst[i]; + this->operator[](idx++) = lst[i]; // copy element } } @@ -198,12 +210,14 @@ inline void Foam::List<T>::append(const UList<T>& lst) template<class T> inline void Foam::List<T>::append(const UIndirectList<T>& lst) { - label nextFree = this->size(); - setSize(nextFree + lst.size()); + label idx = this->size(); + const label n = lst.size(); + + setSize(idx + n); - forAll(lst, i) + for (label i=0; i<n; ++i) { - this->operator[](nextFree++) = lst[i]; + this->operator[](idx++) = lst[i]; // copy element } } diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C index b29418c24a1..aa8cd447f15 100644 --- a/src/OpenFOAM/containers/Lists/List/ListIO.C +++ b/src/OpenFOAM/containers/Lists/List/ListIO.C @@ -92,7 +92,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L) } else { - // uniform content (delimiter == token::BEGIN_BLOCK) + // Uniform content (delimiter == token::BEGIN_BLOCK) T element; is >> element; @@ -141,7 +141,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L) // Putback the opening bracket is.putBack(firstToken); - // Now read as a singly-linked list + // Read as a singly-linked list SLList<T> sll(is); // Convert the singly-linked list to this list @@ -176,8 +176,11 @@ Foam::List<T> Foam::readList(Istream& is) << exit(FatalIOError); } - // Read via a singly-linked list - L = SLList<T>(is); + // Read as singly-linked list + SLList<T> sll(is); + + // Convert the singly-linked list to this list + L = sll; } else { diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C index 5c6f14103e7..3cdcf3e6d0d 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C @@ -24,8 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "error.H" -#include "OSstream.H" #include "token.H" +#include "OSstream.H" +#include "stringOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,7 +53,7 @@ Foam::Ostream& Foam::OSstream::write(const char c) os_ << c; if (c == token::NL) { - lineNumber_++; + ++lineNumber_; } setState(os_.rdstate()); return *this; @@ -61,7 +62,7 @@ Foam::Ostream& Foam::OSstream::write(const char c) Foam::Ostream& Foam::OSstream::write(const char* str) { - lineNumber_ += string(str).count(token::NL); + lineNumber_ += stringOps::count(str, token::NL); os_ << str; setState(os_.rdstate()); return *this; @@ -169,7 +170,7 @@ Foam::Ostream& Foam::OSstream::writeQuoted else { // output unquoted string, only advance line number on newline - lineNumber_ += string(str).count(token::NL); + lineNumber_ += stringOps::count(str, token::NL); os_ << str; } diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index 8ca6388330c..ceba5881162 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -359,10 +359,8 @@ std::string Foam::fileName::path(const std::string& str) { return str.substr(0, i); } - else - { - return "/"; - } + + return "/"; } diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H index 0f9d6139433..14770a9ce9c 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyType.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,7 +72,7 @@ class keyType // Private Member Functions - //- Disallow assignments where we cannot determine string/word type + //- No assignment where we cannot determine string/word type void operator=(const std::string&) = delete; public: @@ -88,22 +88,34 @@ public: //- Construct null inline keyType(); - //- Construct as copy, retaining type (literal or regex) + //- Copy construct, retaining type (literal or regex) inline keyType(const keyType& s); - //- Construct as copy of word. Not treated as a regular expression + //- Copy construct from word. Not treated as a regular expression inline keyType(const word& s); - //- Construct as copy of string. Treat as regular expression. + //- Copy construct from string. Treat as regular expression. inline keyType(const string& s); //- Construct as copy of character array. // Not treated as a regular expression inline keyType(const char* s); - //- Construct as copy of std::string with specified treatment + //- Copy construct from std::string with specified treatment inline keyType(const std::string& s, const bool isPattern); + //- Move construct, retaining type (literal or regex) + inline keyType(keyType&& s); + + //- Move construct from word. Not treated as a regular expression + inline keyType(word&& s); + + //- Move construct from string. Treat as regular expression. + inline keyType(string&& s); + + //- Move construct from std::string with specified treatment + inline keyType(std::string&& s, const bool isPattern); + //- Construct from Istream // Treat as regular expression if surrounded by quotation marks. keyType(Istream& is); @@ -119,6 +131,9 @@ public: //- Treat as a pattern rather than a literal string? inline bool isPattern() const; + //- Swap contents + inline void swap(keyType& s); + //- Smart match as regular expression or as a string. // Optionally force a literal match only bool match(const std::string& text, bool literal = false) const; @@ -126,27 +141,25 @@ public: // Member operators - //- Avoid masking the normal operator() - using word::operator(); - //- Perform smart match on text inline bool operator()(const std::string& text) const; - // Assignment - - //- Assignment operator, retaining type (literal or regex) + //- Copy assignment, retaining type (literal or regex) inline void operator=(const keyType& s); //- Assign as word, not treated as a regular expression. inline void operator=(const word& s); - //- Assign as regular expression + //- Assign from Foam::string as regular expression inline void operator=(const string& s); //- Assign as word, not treated as a regular expression. inline void operator=(const char* s); + //- Move assignment, retaining type (literal or regex) + inline void operator=(keyType&& s); + // IOstream operators diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H index 575bb834b16..95fa78496ad 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include <algorithm> + // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // inline bool Foam::keyType::valid(char c) @@ -75,17 +77,44 @@ inline Foam::keyType::keyType(const char* s) {} -inline Foam::keyType::keyType -( - const std::string& s, - const bool isPattern -) +inline Foam::keyType::keyType(const std::string& s, const bool isPattern) : word(s, false), isPattern_(isPattern) {} + +inline Foam::keyType::keyType(keyType&& s) +: + word(std::move(static_cast<word&>(s)), false), + isPattern_(s.isPattern()) +{ + s.isPattern_ = false; +} + + +inline Foam::keyType::keyType(word&& s) +: + word(std::move(s), false), + isPattern_(false) +{} + + +inline Foam::keyType::keyType(string&& s) +: + word(std::move(s), false), + isPattern_(true) +{} + + +inline Foam::keyType::keyType(std::string&& s, const bool isPattern) +: + word(std::move(s), false), + isPattern_(isPattern) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline bool Foam::keyType::isPattern() const @@ -94,6 +123,13 @@ inline bool Foam::keyType::isPattern() const } +inline void Foam::keyType::swap(keyType& s) +{ + word::swap(static_cast<word&>(s)); + std::swap(isPattern_, s.isPattern_); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline bool Foam::keyType::operator()(const std::string& text) const @@ -104,30 +140,37 @@ inline bool Foam::keyType::operator()(const std::string& text) const inline void Foam::keyType::operator=(const keyType& s) { - string::operator=(s); // Bypass checking + string::operator=(s); // Bypass char checking isPattern_ = s.isPattern_; } inline void Foam::keyType::operator=(const word& s) { - string::operator=(s); // Bypass checking + string::operator=(s); // Bypass char checking isPattern_ = false; } inline void Foam::keyType::operator=(const string& s) { - string::operator=(s); // Bypass checking + string::operator=(s); // Bypass char checking isPattern_ = true; } inline void Foam::keyType::operator=(const char* s) { - string::operator=(s); // Bypass checking + string::operator=(s); // Bypass char checking isPattern_ = false; } +inline void Foam::keyType::operator=(keyType&& s) +{ + clear(); + swap(s); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/strings/string/string.C b/src/OpenFOAM/primitives/strings/string/string.C index b16b30f66de..ac8beb6f187 100644 --- a/src/OpenFOAM/primitives/strings/string/string.C +++ b/src/OpenFOAM/primitives/strings/string/string.C @@ -101,17 +101,7 @@ bool Foam::string::hasExt(const wordRe& ending) const Foam::string::size_type Foam::string::count(const char c) const { - size_type nChar = 0; - - for (auto iter = cbegin(); iter != cend(); ++iter) - { - if (*iter == c) - { - ++nChar; - } - } - - return nChar; + return stringOps::count(*this, c); } diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H index 3af6835f144..ee5aee9b9c6 100644 --- a/src/OpenFOAM/primitives/strings/string/string.H +++ b/src/OpenFOAM/primitives/strings/string/string.H @@ -153,13 +153,18 @@ public: //- Construct from copies of a single character inline string(const size_type len, const char c); + //- Move construct from std::string + inline string(std::string&& str); + //- Construct from Istream string(Istream& is); // Member Functions - //- Count and return the number of a given character in the string + //- Count the number of occurences of the specified character + //- in the string + // Partially deprecated (NOV-2017) in favour of stringOps::count size_type count(const char c) const; //- Does the string contain valid characters only? @@ -194,7 +199,7 @@ public: using std::string::replace; //- Replace first occurence of sub-string oldStr with newStr, - // beginning at start + //- beginning at start string& replace ( const string& oldStr, @@ -203,7 +208,7 @@ public: ); //- Replace all occurences of sub-string oldStr with newStr, - // beginning at start. This is a no-op if oldStr is empty. + //- beginning at start. This is a no-op if oldStr is empty. string& replaceAll ( const string& oldStr, diff --git a/src/OpenFOAM/primitives/strings/string/stringI.H b/src/OpenFOAM/primitives/strings/string/stringI.H index 89a36cc3ee8..7d584d2244a 100644 --- a/src/OpenFOAM/primitives/strings/string/stringI.H +++ b/src/OpenFOAM/primitives/strings/string/stringI.H @@ -99,6 +99,12 @@ inline Foam::string::string(const size_type len, const char c) {} +inline Foam::string::string(std::string&& str) +: + std::string(std::move(str)) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class String> diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index 0bb89dd6938..8646523b683 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -132,6 +132,47 @@ static inline int findParameterAlternative // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +std::string::size_type Foam::stringOps::count +( + const std::string& str, + const char c +) +{ + std::string::size_type n = 0; + + for (auto iter = str.cbegin(); iter != str.cend(); ++iter) + { + if (*iter == c) + { + ++n; + } + } + + return n; +} + + +std::string::size_type Foam::stringOps::count(const char* str, const char c) +{ + if (!str) + { + return 0; + } + + std::string::size_type n = 0; + + for (const char *iter = str; *iter; ++iter) + { + if (*iter == c) + { + ++n; + } + } + + return n; +} + + Foam::string Foam::stringOps::expand ( const string& original, diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H index 0d84856f52d..3ae8bf4f4f3 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H @@ -54,6 +54,14 @@ namespace Foam namespace stringOps { + //- Count the number of occurences of the specified character + std::string::size_type count(const std::string& str, const char c); + + //- Count the number of occurences of the specified character + // Correctly handles nullptr. + std::string::size_type count(const char* str, const char c); + + //- Expand occurences of variables according to the mapping // Expansion includes: // -# variables diff --git a/src/OpenFOAM/primitives/strings/word/word.C b/src/OpenFOAM/primitives/strings/word/word.C index 932f10af4cb..c51d489c914 100644 --- a/src/OpenFOAM/primitives/strings/word/word.C +++ b/src/OpenFOAM/primitives/strings/word/word.C @@ -25,6 +25,7 @@ License #include "word.H" #include "debug.H" +#include <cctype> // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -77,10 +78,8 @@ Foam::word Foam::word::lessExt() const { return *this; } - else - { - return substr(0, i); - } + + return substr(0, i); } @@ -109,4 +108,28 @@ bool Foam::word::hasExt(const wordRe& ending) const } +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +Foam::word Foam::operator&(const word& a, const word& b) +{ + if (a.size()) + { + if (b.size()) + { + // Two non-empty words: can concatenate and perform camel case + word camelCase(a + b); + camelCase[a.size()] = char(toupper(b[0])); + + return camelCase; + } + + return a; + } + + // Or, if the first string is empty (or both are empty) + + return b; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H index b92d7209342..b840928cef1 100644 --- a/src/OpenFOAM/primitives/strings/word/word.H +++ b/src/OpenFOAM/primitives/strings/word/word.H @@ -31,6 +31,7 @@ Description semicolons or brace brackets. Words are delimited by whitespace. SourceFiles + wordI.H word.C wordIO.C @@ -48,7 +49,6 @@ namespace Foam // Forward declaration of friend functions and operators class word; -inline word operator&(const word& a, const word& b); Istream& operator>>(Istream& is, word& w); Ostream& operator<<(Ostream& os, const word& w); @@ -84,7 +84,7 @@ public: //- Construct null inline word(); - //- Construct as copy + //- Copy construct inline word(const word& w); //- Construct as copy of character array @@ -98,12 +98,21 @@ public: const bool doStripInvalid ); - //- Construct as copy of string + //- Construct as copy of Foam::string inline word(const string& s, const bool doStripInvalid=true); //- Construct as copy of std::string inline word(const std::string& s, const bool doStripInvalid=true); + //- Move construct + inline word(word&& w); + + //- Move construct from Foam::string + inline word(string&& s, const bool doStripInvalid=true); + + //- Move construct from std::string + inline word(std::string&& s, const bool doStripInvalid=true); + //- Construct from Istream word(Istream& is); @@ -149,24 +158,26 @@ public: // Assignment - //- Copy, no character validation required + //- Copy assignment, no character validation required inline void operator=(const word& w); - //- Copy, stripping invalid characters + //- Copy assignment from Foam::string, stripping invalid characters inline void operator=(const string& s); - //- Copy, stripping invalid characters + //- Copy assignment from std::string, stripping invalid characters inline void operator=(const std::string& s); //- Copy, stripping invalid characters inline void operator=(const char* s); + //- Move assignment + inline void operator=(word&& w); - // Friend Operators + //- Move assignment from Foam::string, stripping invalid characters + inline void operator=(string&& s); - //- Join word a and b, capitalising the first letter of b - // (so-called camelCase) - friend word operator&(const word& a, const word& b); + //- Move assignment from std::string, stripping invalid characters + inline void operator=(std::string&& s); // IOstream operators @@ -176,6 +187,13 @@ public: }; +// Global Operators + +//- Join words as camelCase, capitalizing the first letter of b. +// No effect if either argument is empty. +word operator&(const word& a, const word& b); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/primitives/strings/word/wordI.H b/src/OpenFOAM/primitives/strings/word/wordI.H index 2fa48801a73..7ee9e0a08da 100644 --- a/src/OpenFOAM/primitives/strings/word/wordI.H +++ b/src/OpenFOAM/primitives/strings/word/wordI.H @@ -111,6 +111,34 @@ inline Foam::word::word } +inline Foam::word::word(word&& w) +: + string(std::move(w)) +{} + + +inline Foam::word::word(string&& s, const bool doStripInvalid) +: + string(std::move(s)) +{ + if (doStripInvalid) + { + stripInvalid(); + } +} + + +inline Foam::word::word(std::string&& s, const bool doStripInvalid) +: + string(std::move(s)) +{ + if (doStripInvalid) + { + stripInvalid(); + } +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline bool Foam::word::valid(char c) @@ -148,6 +176,12 @@ inline void Foam::word::operator=(const word& w) } +inline void Foam::word::operator=(word&& w) +{ + string::operator=(std::move(w)); +} + + inline void Foam::word::operator=(const string& s) { string::operator=(s); @@ -155,35 +189,31 @@ inline void Foam::word::operator=(const string& s) } -inline void Foam::word::operator=(const std::string& s) +inline void Foam::word::operator=(string&& s) { - string::operator=(s); + string::operator=(std::move(s)); stripInvalid(); } -inline void Foam::word::operator=(const char* s) +inline void Foam::word::operator=(const std::string& s) { string::operator=(s); stripInvalid(); } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -inline Foam::word Foam::operator&(const word& a, const word& b) +inline void Foam::word::operator=(std::string&& s) { - if (b.size()) - { - string ub = b; - ub.string::operator[](0) = char(toupper(ub.string::operator[](0))); + string::operator=(std::move(s)); + stripInvalid(); +} - return a + ub; - } - else - { - return a; - } + +inline void Foam::word::operator=(const char* s) +{ + string::operator=(s); + stripInvalid(); } diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H index 8195abb90ec..a7573068bec 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H @@ -154,6 +154,9 @@ public: //- Construct as copy of word, use specified compile option inline wordRe(const word& str, const compOption); + //- Move construct + inline wordRe(wordRe&& str); + //- Construct from Istream // Words are treated as literals, strings with an auto-test wordRe(Istream& is); @@ -191,6 +194,9 @@ public: //- Clear string and regular expression inline void clear(); + //- Swap contents + inline void swap(wordRe& str); + // Matching/Searching @@ -210,17 +216,11 @@ public: // Member operators - //- Avoid masking the normal operator() - using word::operator(); - //- Perform smart match on text, as per match() inline bool operator()(const std::string& text) const; - // Assignment - - //- Copy wordRe and its type (literal or regex) - // Always case sensitive + //- Copy assignment, retaining type (literal or regex) inline void operator=(const wordRe& str); //- Copy word, never a regular expression @@ -242,6 +242,9 @@ public: // Always case sensitive inline void operator=(const char* str); + //- Move assignment. + inline void operator=(wordRe&& str); + // IOstream operators diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H index 658df00695f..c269e321a47 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H @@ -148,6 +148,13 @@ inline Foam::wordRe::wordRe(const word& str, const compOption opt) } +inline Foam::wordRe::wordRe(wordRe&& str) +: + word(std::move(static_cast<word&>(str))), + re_(std::move(str.re_)) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline bool Foam::wordRe::isPattern() const @@ -249,6 +256,13 @@ inline void Foam::wordRe::set(const char* str, const compOption opt) } +inline void Foam::wordRe::swap(wordRe& str) +{ + word::swap(static_cast<word&>(str)); + re_.swap(str.re_); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline bool Foam::wordRe::operator()(const std::string& text) const @@ -313,4 +327,11 @@ inline void Foam::wordRe::operator=(const char* str) } +inline void Foam::wordRe::operator=(wordRe&& str) +{ + clear(); + swap(str); +} + + // ************************************************************************* // -- GitLab From c4de3e0a4d35cf006e6f10f656abbb988c2c7dd9 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 5 Nov 2017 20:05:28 +0100 Subject: [PATCH 096/126] ENH: enhancements to behaviour of token - improved memory alignment reduces overhead for Int32 compilation - added move/swap semantics - made the type() readonly in favour of setVariant() to allow change of variant within a particular storage representation. Eg, STRING -> VERBATIMSTRING. --- applications/test/token/Make/files | 3 + applications/test/token/Make/options | 1 + applications/test/token/Test-token.C | 75 ++ applications/test/tokenize/Test-tokenize.C | 14 + src/OpenFOAM/db/IOstreams/IOstreams/Istream.C | 14 +- src/OpenFOAM/db/IOstreams/IOstreams/Istream.H | 8 +- .../db/IOstreams/Pstreams/UIPstream.C | 25 +- src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C | 39 +- src/OpenFOAM/db/IOstreams/token/token.C | 22 +- src/OpenFOAM/db/IOstreams/token/token.H | 415 +++++++---- src/OpenFOAM/db/IOstreams/token/tokenI.H | 648 +++++++++++------- src/OpenFOAM/db/IOstreams/token/tokenIO.C | 275 ++++---- src/OpenFOAM/memory/refCount/refCount.H | 28 +- src/OpenFOAM/memory/tmp/tmp.H | 2 +- 14 files changed, 946 insertions(+), 623 deletions(-) create mode 100644 applications/test/token/Make/files create mode 100644 applications/test/token/Make/options create mode 100644 applications/test/token/Test-token.C diff --git a/applications/test/token/Make/files b/applications/test/token/Make/files new file mode 100644 index 00000000000..27b95da13e1 --- /dev/null +++ b/applications/test/token/Make/files @@ -0,0 +1,3 @@ +Test-token.C + +EXE = $(FOAM_USER_APPBIN)/Test-token diff --git a/applications/test/token/Make/options b/applications/test/token/Make/options new file mode 100644 index 00000000000..1f502ad153c --- /dev/null +++ b/applications/test/token/Make/options @@ -0,0 +1 @@ +/* EXE_INC = */ diff --git a/applications/test/token/Test-token.C b/applications/test/token/Test-token.C new file mode 100644 index 00000000000..b8918c54b77 --- /dev/null +++ b/applications/test/token/Test-token.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Description + Test token construct assign etc. +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "IOobject.H" +#include "IOstreams.H" +#include "IFstream.H" +#include "StringStream.H" +#include "cpuTime.H" +#include "DynamicList.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noBanner(); + argList::noParallel(); + + argList args(argc, argv, false, true); + + token tok1; + Info<< "construct null: " << tok1.info() << endl; + + tok1 = double(3.14159); + Info<< "assign double: " << tok1.info() << endl; + + token tok2(tok1); + Info<< "copy construct: " << tok2.info() << endl; + + tok1 = word("this-word"); + Info<< "assign word: " << tok1.info() << endl; + + token tok3(tok1); + Info<< "copy construct: " << tok3.info() << endl; + Info<< "orig: " << tok1.info() << endl; + + token tok4(std::move(tok1)); + Info<< "move construct: " << tok4.info() << endl; + Info<< "orig: " << tok1.info() << endl; + + tok3 = tok4; + Info<< "assign token: " << tok3.info() << endl; + Info<< "orig: " << tok4.info() << endl; + + return 0; +} + +// ************************************************************************* // diff --git a/applications/test/tokenize/Test-tokenize.C b/applications/test/tokenize/Test-tokenize.C index bd2f84a4820..f944036d667 100644 --- a/applications/test/tokenize/Test-tokenize.C +++ b/applications/test/tokenize/Test-tokenize.C @@ -33,6 +33,7 @@ Description #include "IFstream.H" #include "StringStream.H" #include "cpuTime.H" +#include "DynamicList.H" using namespace Foam; @@ -69,6 +70,8 @@ int main(int argc, char *argv[]) IStringStream is(rawArg); + DynamicList<token> tokens; + while (is.good()) { token tok(is); @@ -83,12 +86,23 @@ int main(int argc, char *argv[]) << " lookahead: '" << char(lookahead) << "'" << endl; } + + if (tok.good()) + { + tokens.append(std::move(tok)); + if (verbose) + { + Info<< "after append: " << tok.info() << endl; + } + } } if (verbose) { Info<< nl; IOobject::writeDivider(Info); + + Info<< "tokenList:" << tokens << endl; } } } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C index 25ee28e0055..941b78cfd6e 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C @@ -27,7 +27,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::Istream::putBack(const token& t) +void Foam::Istream::putBack(const token& tok) { if (bad()) { @@ -43,13 +43,13 @@ void Foam::Istream::putBack(const token& t) } else { - putBackToken_ = t; + putBackToken_ = tok; putBack_ = true; } } -bool Foam::Istream::getBack(token& t) +bool Foam::Istream::getBack(token& tok) { if (bad()) { @@ -59,7 +59,7 @@ bool Foam::Istream::getBack(token& t) } else if (putBack_) { - t = putBackToken_; + tok = putBackToken_; putBack_ = false; return true; } @@ -68,15 +68,15 @@ bool Foam::Istream::getBack(token& t) } -bool Foam::Istream::peekBack(token& t) +bool Foam::Istream::peekBack(token& tok) { if (putBack_) { - t = putBackToken_; + tok = putBackToken_; } else { - t = token::undefinedToken; + tok = token::undefinedToken; } return putBack_; diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H index 24df823bdda..e55211309d8 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H @@ -96,16 +96,16 @@ public: //- Put back token // Only a single put back is permitted - void putBack(const token&); + void putBack(const token& tok); //- Get the put back token if there is one and return true. // Return false if no put back token is available. - bool getBack(token&); + bool getBack(token& tok); //- Peek at the put back token without removing it. // Returns false if no put back token is available and set the // token to undefined. - bool peekBack(token&); + bool peekBack(token& tok); //- Return next token from stream virtual Istream& read(token&) = 0; @@ -116,7 +116,7 @@ public: //- Read a word virtual Istream& read(word&) = 0; - // Read a string (including enclosing double-quotes) + //- Read a string (including enclosing double-quotes) virtual Istream& read(string&) = 0; //- Read a label diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index 0e40098fa55..1ed965b7580 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -164,22 +164,20 @@ Foam::Istream& Foam::UIPstream::read(token& t) // Word case token::tokenType::WORD : { - word* pval = new word; - if (read(*pval)) + word val; + if (read(val)) { - if (token::compound::isCompound(*pval)) + if (token::compound::isCompound(val)) { - t = token::compound::New(*pval, *this).ptr(); - delete pval; + t = token::compound::New(val, *this).ptr(); } else { - t = pval; + t = std::move(val); } } else { - delete pval; t.setBad(); } return *this; @@ -190,26 +188,25 @@ Foam::Istream& Foam::UIPstream::read(token& t) { // Recurse to read actual string read(t); - t.type() = token::tokenType::VERBATIMSTRING; + t.setType(token::tokenType::VERBATIMSTRING); return *this; } case token::tokenType::VARIABLE : { // Recurse to read actual string read(t); - t.type() = token::tokenType::VARIABLE; + t.setType(token::tokenType::VARIABLE); return *this; } case token::tokenType::STRING : { - string* pval = new string; - if (read(*pval)) + string val; + if (read(val)) { - t = pval; + t = std::move(val); } else { - delete pval; t.setBad(); } return *this; diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C index 010eef975bc..cc9a0e5a656 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C @@ -116,21 +116,18 @@ char Foam::ISstream::nextValid() void Foam::ISstream::readWordToken(token& t) { - word* wPtr = new word; - - if (read(*wPtr).bad()) + word val; + if (read(val).bad()) { - delete wPtr; t.setBad(); } - else if (token::compound::isCompound(*wPtr)) + else if (token::compound::isCompound(val)) { - t = token::compound::New(*wPtr, *this).ptr(); - delete wPtr; + t = token::compound::New(val, *this).ptr(); } else { - t = wPtr; // Token takes ownership + t = std::move(val); // Move contents to token } } @@ -192,16 +189,15 @@ Foam::Istream& Foam::ISstream::read(token& t) case token::BEGIN_STRING : { putback(c); - string* sPtr = new string; - if (read(*sPtr).bad()) + string val; + if (read(val).bad()) { - delete sPtr; t.setBad(); } else { - t = sPtr; // Token takes ownership + t = std::move(val); // Move contents to token } return *this; @@ -219,17 +215,16 @@ Foam::Istream& Foam::ISstream::read(token& t) else if (nextC == token::BEGIN_BLOCK) { // Verbatim string: #{ ... #} - string* sPtr = new string; - if (readVerbatim(*sPtr).bad()) + string val; + if (readVerbatim(val).bad()) { - delete sPtr; t.setBad(); } else { - t = sPtr; // Token takes ownership - t.type() = token::tokenType::VERBATIMSTRING; + t = std::move(val); // Move contents to token + t.setType(token::tokenType::VERBATIMSTRING); } } else @@ -259,17 +254,15 @@ Foam::Istream& Foam::ISstream::read(token& t) putback(nextC); putback(c); - string* sPtr = new string; - - if (readVariable(*sPtr).bad()) + string val; + if (readVariable(val).bad()) { - delete sPtr; t.setBad(); } else { - t = sPtr; // Token takes ownership - t.type() = token::tokenType::VARIABLE; + t = std::move(val); // Move contents to token + t.setType(token::tokenType::VARIABLE); } } else diff --git a/src/OpenFOAM/db/IOstreams/token/token.C b/src/OpenFOAM/db/IOstreams/token/token.C index 17019bda99d..fe1f76df5ce 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.C +++ b/src/OpenFOAM/db/IOstreams/token/token.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,14 +29,14 @@ License namespace Foam { - const char* const token::typeName = "token"; - token token::undefinedToken; - typedef token::compound tokenCompound; defineTypeNameAndDebug(tokenCompound, 0); defineRunTimeSelectionTable(tokenCompound, Istream); } +const char* const Foam::token::typeName = "token"; +const Foam::token Foam::token::undefinedToken; + // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -94,7 +94,7 @@ Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is) { if (type_ == tokenType::COMPOUND) { - if (compoundTokenPtr_->empty()) + if (data_.compoundPtr->empty()) { FatalIOErrorInFunction(is) << "compound has already been transfered from token\n " @@ -102,16 +102,14 @@ Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is) } else { - compoundTokenPtr_->empty() = true; + data_.compoundPtr->empty() = true; } - return *compoundTokenPtr_; - } - else - { - parseError("compound"); - return *compoundTokenPtr_; + return *data_.compoundPtr; } + + parseError("compound"); + return *data_.compoundPtr; } diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H index 1de16e5e13a..90897917c3f 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.H +++ b/src/OpenFOAM/db/IOstreams/token/token.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,7 @@ Class Foam::token Description - A token holds items read from Istream. + A token holds an item read from Istream. SourceFiles tokenI.H @@ -64,34 +64,40 @@ Ostream& operator<<(Ostream& os, const token& t); /*---------------------------------------------------------------------------*\ - Class token Declaration + Class token Declaration \*---------------------------------------------------------------------------*/ class token { - public: - //- Enumeration defining the types of token + //- Enumeration defining the types of token. + // Since these values are also used to tag content in Pstream, + // the maximum number of types is limited to 30. enum tokenType { - UNDEFINED, - - PUNCTUATION, - WORD, - VARIABLE, - STRING, - VERBATIMSTRING, - LABEL, - FLOAT_SCALAR, - DOUBLE_SCALAR, - COMPOUND, - - ERROR + UNDEFINED, //!< An undefined token-type + + // Fundamental types + PUNCTUATION, //!< single character punctuation + LABEL, //!< label (integer) type + FLOAT_SCALAR, //!< float (single-precision) type + DOUBLE_SCALAR, //!< double (double-precision) type + + // Pointer types + WORD, //!< Contents represent a Foam::word + STRING, //!< Contents represent a Foam::string + VARIABLE, //!< Contents are a Foam::string representing a + //!< dictionary \c $variable expansion + VERBATIMSTRING, //!< Contents are a Foam::string representing verbatim + //!< content + COMPOUND, //!< Compound type such as List\<label\> etc. + + ERROR //!< A token error encountered }; - //- Standard punctuation tokens + //- Standard punctuation tokens (a character) enum punctuationToken { NULL_TOKEN = '\0', @@ -99,25 +105,26 @@ public: TAB = '\t', NL = '\n', - END_STATEMENT = ';', - BEGIN_LIST = '(', - END_LIST = ')', - BEGIN_SQR = '[', - END_SQR = ']', - BEGIN_BLOCK = '{', - END_BLOCK = '}', - COLON = ':', - COMMA = ',', + END_STATEMENT = ';', //!< End entry [#isseparator] + BEGIN_LIST = '(', //!< Begin list [#isseparator] + END_LIST = ')', //!< End list [#isseparator] + BEGIN_SQR = '[', //!< Begin dimensions [#isseparator] + END_SQR = ']', //!< End dimensions [#isseparator] + BEGIN_BLOCK = '{', //!< Begin block [#isseparator] + END_BLOCK = '}', //!< End block [#isseparator] + COLON = ':', //!< Colon [#isseparator] + COMMA = ',', //!< Comma [#isseparator] HASH = '#', + ATSYM = '@', BEGIN_STRING = '"', END_STRING = BEGIN_STRING, - ASSIGN = '=', - ADD = '+', - SUBTRACT = '-', - MULTIPLY = '*', - DIVIDE = '/' + ASSIGN = '=', //!< Assigment/equals [#isseparator] + ADD = '+', //!< Addition [#isseparator] + SUBTRACT = '-', //!< Substract or start of negative number + MULTIPLY = '*', //!< Multiply [#isseparator] + DIVIDE = '/' //!< Divide [#isseparator] }; @@ -145,7 +152,6 @@ public: //- Runtime type information TypeName("compound"); - //- Declare run-time constructor selection table declareRunTimeSelectionTable ( @@ -169,7 +175,7 @@ public: // Selectors //- Select null constructed - static autoPtr<compound> New(const word& type, Istream&); + static autoPtr<compound> New(const word& type, Istream& is); //- Destructor @@ -178,26 +184,22 @@ public: // Member Functions - // Access - - //- Return true if name is a compound type - static bool isCompound(const word& name); + //- Return true if name is a known compound type + static bool isCompound(const word& name); - bool empty() const - { - return empty_; - } - - bool& empty() - { - return empty_; - } + bool empty() const + { + return empty_; + } - virtual label size() const = 0; + bool& empty() + { + return empty_; + } - // Write + virtual label size() const = 0; - virtual void write(Ostream& os) const = 0; + virtual void write(Ostream& os) const = 0; // IOstream Operators @@ -236,35 +238,49 @@ public: //- Static undefined token - static token undefinedToken; + static const token undefinedToken; private: + //- A %union of token types + union content + { + // Fundamental values. Largest first for any {} initialization. + int64_t int64Val; + int32_t int32Val; + + punctuationToken punctuationVal; + label labelVal; + floatScalar floatVal; + doubleScalar doubleVal; + + // Pointers + word* wordPtr; + string* stringPtr; + mutable compound* compoundPtr; + }; + + // Private data + //- The data content (as a union). + // For memory alignment this should appear as the first member. + content data_; + //- The token type tokenType type_; - //- Anonymous Union of token types - union - { - punctuationToken punctuationToken_; - word* wordTokenPtr_; - string* stringTokenPtr_; - label labelToken_; - floatScalar floatScalarToken_; - doubleScalar doubleScalarToken_; - mutable compound* compoundTokenPtr_; - }; - - //- Line number in the file this token was read from + //- Line number in the file the token was read from label lineNumber_; // Private Member Functions - //- Clear any allocated storage (word or string) + //- Set as UNDEFINED and zero the union content without any checking + inline void setUndefined(); + + //- Clear any allocated storage (word or string) and set to UNDEFINED inline void clear(); // Parse error, expected 'expected', found ... @@ -283,18 +299,15 @@ public: //- Construct null inline token(); - //- Construct as copy + //- Copy construct inline token(const token& t); + //- Move construct. The original token is left as UNDEFINED. + inline token(token&& t); + //- Construct punctuation character token inline explicit token(punctuationToken p); - //- Construct word token - inline explicit token(const word& w); - - //- Construct string token - inline explicit token(const string& str); - //- Construct label token inline explicit token(const label val); @@ -304,15 +317,15 @@ public: //- Construct doubleScalar token inline explicit token(const doubleScalar val); + //- Construct word token by copying word contents + inline explicit token(const word& w); - //- Construct punctuation character token - inline token(punctuationToken p, const label lineNumber); + //- Construct string token by copying string contents + inline explicit token(const string& str); - //- Construct word token - inline token(const word& w, const label lineNumber); - //- Construct string token - inline token(const string& str, const label lineNumber); + //- Construct punctuation character token + inline token(punctuationToken p, const label lineNumber); //- Construct label token inline token(const label val, const label lineNumber); @@ -323,6 +336,12 @@ public: //- Construct doubleScalar token inline token(const doubleScalar val, const label lineNumber); + //- Construct word token by copying word contents + inline token(const word& w, const label lineNumber); + + //- Construct string token by copying string contents + inline token(const string& str, const label lineNumber); + //- Construct from Istream token(Istream& is); @@ -331,108 +350,216 @@ public: inline ~token(); + // Static member functions + + //- True if the character is a punctuation separator (eg, in ISstream). + // Since it could also start a number, SUBTRACT is not included as + // a separator. + // + // \param c the character to test, passed as int for consistency with + // isdigit, isspace etc. + inline static bool isseparator(int c); + + // Member functions - // Access + // Status - inline tokenType type() const; - inline tokenType& type(); + //- Return the name of the token type + word name() const; - inline bool good() const; - inline bool undefined() const; - inline bool error() const; + //- Return the token type + inline tokenType type() const; - inline bool isPunctuation() const; - inline punctuationToken pToken() const; + //- Change the token type, for similar types. + // This can be used to change between string-like variants + // (eg, STRING, VARIABLE, VERBATIMSTRING) + // To change types entirely (eg, STRING to DOUBLE_SCALAR), + // use the corresponding assignment operator. + // + // \return true if the change was successful or no change was required + inline bool setType(const tokenType variant); - inline bool isWord() const; - inline const word& wordToken() const; + //- The line number for the token + inline label lineNumber() const; - inline bool isVariable() const; + //- The line number for the token + inline label& lineNumber(); - inline bool isString() const; - inline const string& stringToken() const; + //- True if token is not UNDEFINED or ERROR + inline bool good() const; - inline bool isLabel() const; - inline label labelToken() const; + //- True if token is UNDEFINED + inline bool undefined() const; - inline bool isFloatScalar() const; - inline floatScalar floatScalarToken() const; + //- True if token is ERROR + inline bool error() const; - inline bool isDoubleScalar() const; - inline doubleScalar doubleScalarToken() const; + //- True if token is PUNCTUATION + inline bool isPunctuation() const; - inline bool isScalar() const; - inline scalar scalarToken() const; + //- True if token is PUNCTUATION and isseparator + inline bool isSeparator() const; - inline bool isNumber() const; - inline scalar number() const; + //- True if token is LABEL + inline bool isLabel() const; - inline bool isCompound() const; - inline const compound& compoundToken() const; - compound& transferCompoundToken(const Istream& is); + //- True if token is FLOAT_SCALAR + inline bool isFloatScalar() const; - inline label lineNumber() const; - inline label& lineNumber(); + //- True if token is DOUBLE_SCALAR + inline bool isDoubleScalar() const; + //- True if token is FLOAT_SCALAR or DOUBLE_SCALAR + inline bool isScalar() const; - // Edit + //- True if token is LABEL, FLOAT_SCALAR or DOUBLE_SCALAR + inline bool isNumber() const; - //- Set bad - inline void setBad(); + //- True if token is WORD + inline bool isWord() const; + //- True if token is STRING, VARIABLE or VERBATIMSTRING + inline bool isString() const; - // Info + //- True if token is VARIABLE + inline bool isVariable() const; + + //- True if token is COMPOUND + inline bool isCompound() const; + + + // Access + + //- Return punctuation character. + // Report FatalIOError and return \b \\0 if token is not PUNCTUATION + inline punctuationToken pToken() const; + + //- Return label value. + // Report FatalIOError and return \b 0 if token is not LABEL + inline label labelToken() const; + + //- Return float value. + // Report FatalIOError and return \b 0.0 if token is not FLOAT_SCALAR + inline floatScalar floatScalarToken() const; + + //- Return double value. + // Report FatalIOError and return \b 0.0 if token is not DOUBLE_SCALAR + inline doubleScalar doubleScalarToken() const; + + //- Return float or double value. + // Report FatalIOError and return \b 0.0 if token is not a + // FLOAT_SCALAR or DOUBLE_SCALAR + inline scalar scalarToken() const; + + //- Return label, float or double value. + // Report FatalIOError and return \b 0.0 if token is not a + // LABEL, FLOAT_SCALAR or DOUBLE_SCALAR + inline scalar number() const; + + //- Return const reference to the word contents. + // Report FatalIOError and return \b "" if token is not a WORD + inline const word& wordToken() const; + + //- Return const reference to the string contents. + // Report FatalIOError and return \b "" if token is not a + // STRING, VARIABLE or VERBATIMSTRING + inline const string& stringToken() const; + + //- Read access for compound token + inline const compound& compoundToken() const; + + //- Return reference to compound token and decrease its internal + //- refCound accordingly. + // The Istream is used for reference error messages only. + compound& transferCompoundToken(const Istream& is); - //- Return info proxy. - // Used to print token information to a stream - InfoProxy<token> info() const - { - return *this; - } + + // Edit + + //- Clear token and set to be in an error state. + inline void setBad(); + + //- Swap token contents: type, data, line-number + inline void swap(token& tok); + + + // Info + + //- Return info proxy for printing token information to a stream + InfoProxy<token> info() const + { + return *this; + } // Member operators - // Assignment + // Assignment + + //- Copy assign + inline void operator=(const token& tok); + + //- Move assign + inline void operator=(token&& tok); + + //- Copy assign from punctuation + inline void operator=(const punctuationToken p); + + //- Copy assign from label + inline void operator=(const label val); + + //- Copy assign from float + inline void operator=(const floatScalar val); + + //- Copy assign from double + inline void operator=(const doubleScalar val); + + //- Copy assign from word + inline void operator=(const word& w); + + //- Copy assign from string + inline void operator=(const string& str); - inline void operator=(const token& t); + //- Move assign from word + inline void operator=(word&& w); - inline void operator=(const punctuationToken p); + //- Move assign from string + inline void operator=(string&& str); - inline void operator=(word* wPtr); - inline void operator=(const word& w); + //- Transfer word pointer to the token + // \deprecated in favour of using move assign from word + inline void operator=(word* wordPtr); - inline void operator=(string* strPtr); - inline void operator=(const string& str); + //- Transfer string pointer to the token + // \deprecated in favour of using move assign from string + inline void operator=(string* stringPtr); - inline void operator=(const label val); - inline void operator=(const floatScalar val); - inline void operator=(const doubleScalar val); + //- Assign compound with reference counting to token + inline void operator=(compound* compoundPtr); - inline void operator=(compound* compPtr); + // Equality - // Equality + inline bool operator==(const token& t) const; - inline bool operator==(const token& t) const; - inline bool operator==(const punctuationToken p) const; - inline bool operator==(const word& w) const; - inline bool operator==(const string& str) const; - inline bool operator==(const label val) const; - inline bool operator==(const floatScalar val) const; - inline bool operator==(const doubleScalar val) const; + inline bool operator==(const punctuationToken p) const; + inline bool operator==(const label val) const; + inline bool operator==(const floatScalar val) const; + inline bool operator==(const doubleScalar val) const; + inline bool operator==(const word& w) const; + inline bool operator==(const string& str) const; - // Inequality + // Inequality - inline bool operator!=(const token& t) const; - inline bool operator!=(const punctuationToken p) const; - inline bool operator!=(const word& w) const; - inline bool operator!=(const string& str) const; - inline bool operator!=(const label val) const; - inline bool operator!=(const floatScalar val) const; - inline bool operator!=(const doubleScalar val) const; + inline bool operator!=(const token& t) const; + inline bool operator!=(const punctuationToken p) const; + inline bool operator!=(const label val) const; + inline bool operator!=(const floatScalar val) const; + inline bool operator!=(const doubleScalar val) const; + inline bool operator!=(const word& w) const; + inline bool operator!=(const string& str) const; // IOstream operators diff --git a/src/OpenFOAM/db/IOstreams/token/tokenI.H b/src/OpenFOAM/db/IOstreams/token/tokenI.H index 32417b4e750..c391298652a 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenI.H +++ b/src/OpenFOAM/db/IOstreams/token/tokenI.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,36 +23,54 @@ License \*---------------------------------------------------------------------------*/ +#include <algorithm> + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +inline void Foam::token::setUndefined() +{ + type_ = tokenType::UNDEFINED; + data_.int64Val = 0; // bit-wise zero for union content + // leave lineNumber untouched - may still be needed +} + + inline void Foam::token::clear() { - if (type_ == tokenType::WORD) - { - delete wordTokenPtr_; - } - else if - ( - type_ == tokenType::STRING - || type_ == tokenType::VARIABLE - || type_ == tokenType::VERBATIMSTRING - ) - { - delete stringTokenPtr_; - } - else if (type_ == tokenType::COMPOUND) + switch (type_) { - if (compoundTokenPtr_->unique()) + case tokenType::WORD: + { + delete data_.wordPtr; + break; + } + + case tokenType::STRING: + case tokenType::VARIABLE: + case tokenType::VERBATIMSTRING: { - delete compoundTokenPtr_; + delete data_.stringPtr; + break; } - else + + case tokenType::COMPOUND: { - compoundTokenPtr_->refCount::operator--(); + if (data_.compoundPtr->unique()) + { + delete data_.compoundPtr; + } + else + { + data_.compoundPtr->refCount::operator--(); + } + break; } + + default: + break; } - type_ = tokenType::UNDEFINED; + setUndefined(); } @@ -60,58 +78,62 @@ inline void Foam::token::clear() inline Foam::token::token() : + data_(), // bit-wise zero for union content type_(tokenType::UNDEFINED), lineNumber_(0) {} -inline Foam::token::token(const token& t) +inline Foam::token::token(const token& tok) : - type_(t.type_), - lineNumber_(t.lineNumber_) + data_(tok.data_), // bit-wise copy of union content + type_(tok.type_), + lineNumber_(tok.lineNumber_) { + // Fundamental: values already handled by bit-wise copy + // Pointer: duplicate content or increase refCount + switch (type_) { - case tokenType::UNDEFINED: - break; - - case tokenType::PUNCTUATION: - punctuationToken_ = t.punctuationToken_; - break; - case tokenType::WORD: - wordTokenPtr_ = new word(*t.wordTokenPtr_); - break; + { + data_.wordPtr = new word(*tok.data_.wordPtr); + break; + } case tokenType::STRING: case tokenType::VARIABLE: case tokenType::VERBATIMSTRING: - stringTokenPtr_ = new string(*t.stringTokenPtr_); - break; - - case tokenType::LABEL: - labelToken_ = t.labelToken_; - break; - - case tokenType::FLOAT_SCALAR: - floatScalarToken_ = t.floatScalarToken_; - break; - - case tokenType::DOUBLE_SCALAR: - doubleScalarToken_ = t.doubleScalarToken_; - break; + { + data_.stringPtr = new string(*tok.data_.stringPtr); + break; + } case tokenType::COMPOUND: - compoundTokenPtr_ = t.compoundTokenPtr_; - compoundTokenPtr_->refCount::operator++(); - break; + { + // Identical pointers, but increase the refCount + data_.compoundPtr = tok.data_.compoundPtr; + data_.compoundPtr->refCount::operator++(); + break; + } - case tokenType::ERROR: - break; + default: + break; } } +inline Foam::token::token(token&& tok) +: + data_(tok.data_), // bit-wise copy of union content + type_(tok.type_), + lineNumber_(tok.lineNumber_) +{ + tok.setUndefined(); // zero the union content without any checking + tok.lineNumber_ = 0; +} + + inline Foam::token::token(punctuationToken p) : token(p, 0) @@ -150,50 +172,62 @@ inline Foam::token::token(const doubleScalar val) inline Foam::token::token(punctuationToken p, label lineNumber) : + data_(), type_(tokenType::PUNCTUATION), - punctuationToken_(p), lineNumber_(lineNumber) -{} +{ + data_.punctuationVal = p; +} -inline Foam::token::token(const word& w, label lineNumber) +inline Foam::token::token(const label val, label lineNumber) : - type_(tokenType::WORD), - wordTokenPtr_(new word(w)), + data_(), + type_(tokenType::LABEL), lineNumber_(lineNumber) -{} +{ + data_.labelVal = val; +} -inline Foam::token::token(const string& str, label lineNumber) +inline Foam::token::token(const floatScalar val, label lineNumber) : - type_(tokenType::STRING), - stringTokenPtr_(new string(str)), + data_(), + type_(tokenType::FLOAT_SCALAR), lineNumber_(lineNumber) -{} +{ + data_.floatVal = val; +} -inline Foam::token::token(const label val, label lineNumber) +inline Foam::token::token(const doubleScalar val, label lineNumber) : - type_(tokenType::LABEL), - labelToken_(val), + data_(), + type_(tokenType::DOUBLE_SCALAR), lineNumber_(lineNumber) -{} +{ + data_.doubleVal = val; +} -inline Foam::token::token(const floatScalar val, label lineNumber) +inline Foam::token::token(const word& w, label lineNumber) : - type_(tokenType::FLOAT_SCALAR), - floatScalarToken_(val), + data_(), + type_(tokenType::WORD), lineNumber_(lineNumber) -{} +{ + data_.wordPtr = new word(w); +} -inline Foam::token::token(const doubleScalar val, label lineNumber) +inline Foam::token::token(const string& str, label lineNumber) : - type_(tokenType::DOUBLE_SCALAR), - doubleScalarToken_(val), + data_(), + type_(tokenType::STRING), lineNumber_(lineNumber) -{} +{ + data_.stringPtr = new string(str); +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -206,134 +240,179 @@ inline Foam::token::~token() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::token::tokenType Foam::token::type() const +inline void Foam::token::swap(token& tok) { - return type_; + std::swap(data_, tok.data_); + std::swap(type_, tok.type_); + std::swap(lineNumber_, tok.lineNumber_); } -inline Foam::token::tokenType& Foam::token::type() + +inline Foam::token::tokenType Foam::token::type() const { return type_; } + +inline bool Foam::token::setType(token::tokenType variant) +{ + if (type_ == variant) + { + // No change required + return true; + } + + switch (variant) + { + case tokenType::STRING: + case tokenType::VARIABLE: + case tokenType::VERBATIMSTRING: + { + switch (type_) + { + // could also go from WORD to STRING etc - to be decided + case tokenType::STRING: + case tokenType::VARIABLE: + case tokenType::VERBATIMSTRING: + type_ = variant; + return true; + break; + + default: + return false; + break; + } + } + + default: + break; + } + + return false; +} + + +inline Foam::label Foam::token::lineNumber() const +{ + return lineNumber_; +} + + +inline Foam::label& Foam::token::lineNumber() +{ + return lineNumber_; +} + + inline bool Foam::token::good() const { - return (type_ != tokenType::ERROR && type_ != tokenType::UNDEFINED); + return (type_ != tokenType::UNDEFINED && type_ != tokenType::ERROR); } + inline bool Foam::token::undefined() const { return (type_ == tokenType::UNDEFINED); } + inline bool Foam::token::error() const { return (type_ == tokenType::ERROR); } + inline bool Foam::token::isPunctuation() const { return (type_ == tokenType::PUNCTUATION); } -inline Foam::token::punctuationToken Foam::token::pToken() const + +inline Foam::token::punctuationToken Foam::token::pToken() const { if (type_ == tokenType::PUNCTUATION) { - return punctuationToken_; - } - else - { - parseError("punctuation character"); - return NULL_TOKEN; + return data_.punctuationVal; } -} -inline bool Foam::token::isWord() const -{ - return (type_ == tokenType::WORD); + parseError("punctuation character"); + return NULL_TOKEN; } -inline const Foam::word& Foam::token::wordToken() const + +inline bool Foam::token::isseparator(int c) { - if (type_ == tokenType::WORD) - { - return *wordTokenPtr_; - } - else + switch (c) { - parseError(word::typeName); - return word::null; + case token::END_STATEMENT : + case token::BEGIN_LIST : + case token::END_LIST : + case token::BEGIN_SQR : + case token::END_SQR : + case token::BEGIN_BLOCK : + case token::END_BLOCK : + case token::COLON : + case token::COMMA : + case token::ASSIGN : + case token::ADD : + // Excluded token::SUBTRACT since it could start a number + case token::MULTIPLY : + case token::DIVIDE : + { + return true; + } + + default: + break; } -} -inline bool Foam::token::isVariable() const -{ - return (type_ == tokenType::VARIABLE); + return false; } -inline bool Foam::token::isString() const + +inline bool Foam::token::isSeparator() const { return ( - type_ == tokenType::STRING - || type_ == tokenType::VARIABLE - || type_ == tokenType::VERBATIMSTRING + type_ == tokenType::PUNCTUATION + && isseparator(data_.punctuationVal) ); } -inline const Foam::string& Foam::token::stringToken() const -{ - if - ( - type_ == tokenType::STRING - || type_ == tokenType::VARIABLE - || type_ == tokenType::VERBATIMSTRING - ) - { - return *stringTokenPtr_; - } - else - { - parseError(string::typeName); - return string::null; - } -} inline bool Foam::token::isLabel() const { return (type_ == tokenType::LABEL); } + inline Foam::label Foam::token::labelToken() const { if (type_ == tokenType::LABEL) { - return labelToken_; - } - else - { - parseError(pTraits<label>::typeName); - return 0; + return data_.labelVal; } + + parseError(pTraits<label>::typeName); + return 0; } + inline bool Foam::token::isFloatScalar() const { return (type_ == tokenType::FLOAT_SCALAR); } + inline Foam::floatScalar Foam::token::floatScalarToken() const { if (type_ == tokenType::FLOAT_SCALAR) { - return floatScalarToken_; - } - else - { - parseError("floatScalar"); - return 0.0; + return data_.floatVal; } + + parseError("floatScalar"); + return 0.0; } @@ -342,17 +421,16 @@ inline bool Foam::token::isDoubleScalar() const return (type_ == tokenType::DOUBLE_SCALAR); } + inline Foam::doubleScalar Foam::token::doubleScalarToken() const { if (type_ == tokenType::DOUBLE_SCALAR) { - return doubleScalarToken_; - } - else - { - parseError("doubleScalar"); - return 0.0; + return data_.doubleVal; } + + parseError("doubleScalar"); + return 0.0; } @@ -365,72 +443,112 @@ inline bool Foam::token::isScalar() const ); } + inline Foam::scalar Foam::token::scalarToken() const { if (type_ == tokenType::FLOAT_SCALAR) { - return floatScalarToken_; + return data_.floatVal; } else if (type_ == tokenType::DOUBLE_SCALAR) { - return doubleScalarToken_; - } - else - { - parseError(pTraits<scalar>::typeName); - return 0.0; + return data_.doubleVal; } + + parseError(pTraits<scalar>::typeName); + return 0.0; } + inline bool Foam::token::isNumber() const { return (type_ == tokenType::LABEL || isScalar()); } + inline Foam::scalar Foam::token::number() const { - if (type_ == tokenType::LABEL) + if (isLabel()) { - return labelToken_; + return labelToken(); } - else if (isScalar()) + if (isScalar()) { return scalarToken(); } - else - { - parseError("number (label or scalar)"); - return 0.0; - } + + parseError("number (label or scalar)"); + return 0.0; } -inline bool Foam::token::isCompound() const + +inline bool Foam::token::isWord() const { - return (type_ == tokenType::COMPOUND); + return (type_ == tokenType::WORD); } -inline const Foam::token::compound& Foam::token::compoundToken() const + +inline const Foam::word& Foam::token::wordToken() const { - if (type_ == tokenType::COMPOUND) + if (type_ == tokenType::WORD) { - return *compoundTokenPtr_; + return *data_.wordPtr; } - else + + parseError(word::typeName); + return word::null; +} + + +inline bool Foam::token::isVariable() const +{ + return (type_ == tokenType::VARIABLE); +} + + +inline bool Foam::token::isString() const +{ + return + ( + type_ == tokenType::STRING + || type_ == tokenType::VARIABLE + || type_ == tokenType::VERBATIMSTRING + ); +} + + +inline const Foam::string& Foam::token::stringToken() const +{ + if + ( + type_ == tokenType::STRING + || type_ == tokenType::VARIABLE + || type_ == tokenType::VERBATIMSTRING + ) { - parseError("compound"); - return *compoundTokenPtr_; + return *data_.stringPtr; } + + parseError(string::typeName); + return string::null; } -inline Foam::label Foam::token::lineNumber() const +inline bool Foam::token::isCompound() const { - return lineNumber_; + return (type_ == tokenType::COMPOUND); } -inline Foam::label& Foam::token::lineNumber() + +inline const Foam::token::compound& Foam::token::compoundToken() const { - return lineNumber_; + if (type_ == tokenType::COMPOUND) + { + return *data_.compoundPtr; + } + + parseError("compound"); + return *data_.compoundPtr; // This is questionable. } @@ -443,117 +561,148 @@ inline void Foam::token::setBad() // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline void Foam::token::operator=(const token& t) +inline void Foam::token::operator=(const token& tok) { clear(); - type_ = t.type_; - switch (type_) - { - case tokenType::UNDEFINED: - break; + type_ = tok.type_; + data_ = tok.data_; // bit-wise copy of union content + lineNumber_ = tok.lineNumber_; - case tokenType::PUNCTUATION: - punctuationToken_ = t.punctuationToken_; - break; + // Fundamental: values already handled by bit-wise copy + // Pointer: duplicate content or increase refCount + switch (type_) + { case tokenType::WORD: - wordTokenPtr_ = new word(*t.wordTokenPtr_); + { + data_.wordPtr = new word(*tok.data_.wordPtr); + } break; case tokenType::STRING: case tokenType::VARIABLE: case tokenType::VERBATIMSTRING: - stringTokenPtr_ = new string(*t.stringTokenPtr_); - break; - - case tokenType::LABEL: - labelToken_ = t.labelToken_; - break; - - case tokenType::FLOAT_SCALAR: - floatScalarToken_ = t.floatScalarToken_; - break; - - case tokenType::DOUBLE_SCALAR: - doubleScalarToken_ = t.doubleScalarToken_; + { + data_.stringPtr = new string(*tok.data_.stringPtr); + } break; case tokenType::COMPOUND: - compoundTokenPtr_ = t.compoundTokenPtr_; - compoundTokenPtr_->refCount::operator++(); + { + // Identical pointers, but increase the refCount + data_.compoundPtr = tok.data_.compoundPtr; + data_.compoundPtr->refCount::operator++(); + } break; - case tokenType::ERROR: - break; + default: + break; } +} + - lineNumber_ = t.lineNumber_; +inline void Foam::token::operator=(token&& tok) +{ + clear(); + lineNumber_ = 0; + swap(tok); } + inline void Foam::token::operator=(const punctuationToken p) { clear(); type_ = tokenType::PUNCTUATION; - punctuationToken_ = p; + data_.punctuationVal = p; } -inline void Foam::token::operator=(word* wPtr) + +inline void Foam::token::operator=(const label val) { clear(); - type_ = tokenType::WORD; - wordTokenPtr_ = wPtr; + type_ = tokenType::LABEL; + data_.labelVal = val; } -inline void Foam::token::operator=(const word& w) + +inline void Foam::token::operator=(const floatScalar val) { - operator=(new word(w)); + clear(); + type_ = tokenType::FLOAT_SCALAR; + data_.floatVal = val; } -inline void Foam::token::operator=(string* strPtr) + +inline void Foam::token::operator=(const doubleScalar val) +{ + clear(); + type_ = tokenType::DOUBLE_SCALAR; + data_.doubleVal = val; +} + + +inline void Foam::token::operator=(word* wordPtr) +{ + clear(); + type_ = tokenType::WORD; + data_.wordPtr = wordPtr; +} + + +inline void Foam::token::operator=(string* stringPtr) { clear(); type_ = tokenType::STRING; - stringTokenPtr_ = strPtr; + data_.stringPtr = stringPtr; } -inline void Foam::token::operator=(const string& str) + +inline void Foam::token::operator=(const word& w) { - operator=(new string(str)); + clear(); + type_ = tokenType::WORD; + data_.wordPtr = new word(w); } -inline void Foam::token::operator=(const label val) + +inline void Foam::token::operator=(const string& str) { clear(); - type_ = tokenType::LABEL; - labelToken_ = val; + type_ = tokenType::STRING; + data_.stringPtr = new string(str); } -inline void Foam::token::operator=(const floatScalar val) + +inline void Foam::token::operator=(word&& w) { clear(); - type_ = tokenType::FLOAT_SCALAR; - floatScalarToken_ = val; + type_ = tokenType::WORD; + data_.wordPtr = new word; + data_.wordPtr->swap(w); } -inline void Foam::token::operator=(const doubleScalar val) + +inline void Foam::token::operator=(string&& s) { clear(); - type_ = tokenType::DOUBLE_SCALAR; - doubleScalarToken_ = val; + type_ = tokenType::STRING; + data_.stringPtr = new string; + data_.stringPtr->swap(s); } -inline void Foam::token::operator=(Foam::token::compound* compPtr) + +inline void Foam::token::operator=(Foam::token::compound* compoundPtr) { clear(); type_ = tokenType::COMPOUND; - compoundTokenPtr_ = compPtr; + data_.compoundPtr = compoundPtr; } -inline bool Foam::token::operator==(const token& t) const +inline bool Foam::token::operator==(const token& tok) const { - if (type_ != t.type_) + if (type_ != tok.type_) { return false; } @@ -564,27 +713,27 @@ inline bool Foam::token::operator==(const token& t) const return true; case tokenType::PUNCTUATION: - return punctuationToken_ == t.punctuationToken_; - - case tokenType::WORD: - return *wordTokenPtr_ == *t.wordTokenPtr_; - - case tokenType::STRING: - case tokenType::VARIABLE: - case tokenType::VERBATIMSTRING: - return *stringTokenPtr_ == *t.stringTokenPtr_; + return data_.punctuationVal == tok.data_.punctuationVal; case tokenType::LABEL: - return labelToken_ == t.labelToken_; + return data_.labelVal == tok.data_.labelVal; case tokenType::FLOAT_SCALAR: - return equal(floatScalarToken_, t.floatScalarToken_); + return equal(data_.floatVal, tok.data_.floatVal); case tokenType::DOUBLE_SCALAR: - return equal(doubleScalarToken_, t.doubleScalarToken_); + return equal(data_.doubleVal, tok.data_.doubleVal); + + case tokenType::WORD: + return *data_.wordPtr == *tok.data_.wordPtr; + + case tokenType::STRING: + case tokenType::VARIABLE: + case tokenType::VERBATIMSTRING: + return *data_.stringPtr == *tok.data_.stringPtr; case tokenType::COMPOUND: - return compoundTokenPtr_ == t.compoundTokenPtr_; + return data_.compoundPtr == tok.data_.compoundPtr; case tokenType::ERROR: return true; @@ -593,16 +742,19 @@ inline bool Foam::token::operator==(const token& t) const return false; } + inline bool Foam::token::operator==(const punctuationToken p) const { - return (type_ == tokenType::PUNCTUATION && punctuationToken_ == p); + return (type_ == tokenType::PUNCTUATION && data_.punctuationVal == p); } + inline bool Foam::token::operator==(const word& w) const { return (type_ == tokenType::WORD && wordToken() == w); } + inline bool Foam::token::operator==(const string& str) const { return @@ -616,67 +768,77 @@ inline bool Foam::token::operator==(const string& str) const ); } + inline bool Foam::token::operator==(const label val) const { return ( type_ == tokenType::LABEL - && labelToken_ == val + && data_.labelVal == val ); } + inline bool Foam::token::operator==(const floatScalar val) const { return ( type_ == tokenType::FLOAT_SCALAR - && equal(floatScalarToken_, val) + && equal(data_.floatVal, val) ); } + inline bool Foam::token::operator==(const doubleScalar val) const { return ( type_ == tokenType::DOUBLE_SCALAR - && equal(doubleScalarToken_, val) + && equal(data_.doubleVal, val) ); } + inline bool Foam::token::operator!=(const token& t) const { return !operator==(t); } + inline bool Foam::token::operator!=(const punctuationToken p) const { return !operator==(p); } -inline bool Foam::token::operator!=(const word& w) const -{ - return !operator==(w); -} - -inline bool Foam::token::operator!=(const string& str) const -{ - return !operator==(str); -} inline bool Foam::token::operator!=(const label val) const { return !operator==(val); } + inline bool Foam::token::operator!=(const floatScalar val) const { return !operator==(val); } + inline bool Foam::token::operator!=(const doubleScalar val) const { return !operator==(val); } +inline bool Foam::token::operator!=(const word& w) const +{ + return !operator==(w); +} + + +inline bool Foam::token::operator!=(const string& str) const +{ + return !operator==(str); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/token/tokenIO.C b/src/OpenFOAM/db/IOstreams/token/tokenIO.C index f451de1796a..c32935d9074 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenIO.C +++ b/src/OpenFOAM/db/IOstreams/token/tokenIO.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,254 +25,221 @@ License #include "error.H" #include "token.H" - -#include "IOstreams.H" #include "scalar.H" +#include "IOstreams.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // -Foam::token::token(Istream& is) -: - type_(tokenType::UNDEFINED) +namespace Foam { - is.read(*this); -} - - -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -Foam::Istream& Foam::operator>>(Istream& is, token& t) +template<class OS> +static OS& printTokenInfo(OS& os, const token& tok) { - t.clear(); - return is.read(t); -} - + os << "on line " << tok.lineNumber() << ": "; -Foam::Ostream& Foam::operator<<(Ostream& os, const token& t) -{ - switch (t.type_) + switch (tok.type()) { case token::tokenType::UNDEFINED: - os << "UNDEFINED"; - WarningInFunction - << "Undefined token" << endl; + os << "undefined token"; break; case token::tokenType::PUNCTUATION: - os << t.punctuationToken_; + os << "punctuation '" << tok.pToken() << '\''; break; - case token::tokenType::WORD: - os << *t.wordTokenPtr_; + case token::tokenType::LABEL: + os << "label " << tok.labelToken(); break; - case token::tokenType::STRING: - case token::tokenType::VERBATIMSTRING: - os << *t.stringTokenPtr_; + case token::tokenType::FLOAT_SCALAR: + os << "float " << tok.floatScalarToken(); break; - case token::tokenType::VARIABLE: - // Behaviour differs according to stream type - os.write(t); + case token::tokenType::DOUBLE_SCALAR: + os << "double " << tok.doubleScalarToken(); break; - case token::tokenType::LABEL: - os << t.labelToken_; + case token::tokenType::WORD: + os << "word '" << tok.wordToken() << '\''; break; - case token::tokenType::FLOAT_SCALAR: - os << t.floatScalarToken_; + case token::tokenType::STRING: + os << "string " << tok.stringToken(); break; - case token::tokenType::DOUBLE_SCALAR: - os << t.doubleScalarToken_; + case token::tokenType::VARIABLE: + os << "variable " << tok.stringToken(); + break; + + case token::tokenType::VERBATIMSTRING: + os << "verbatim string " << tok.stringToken(); break; case token::tokenType::COMPOUND: - os << *t.compoundTokenPtr_; + { + if (tok.compoundToken().empty()) + { + os << "empty "; + } + os << "compound of type " + << tok.compoundToken().type(); + } break; case token::tokenType::ERROR: - os << "ERROR"; - WarningInFunction - << "Error token" << endl; + os << "error"; break; default: - os << "UNKNOWN"; - SeriousErrorInFunction - << "Unknown token" - << endl; + os << "unknown token type '" << int(tok.type()) << '\''; + break; } - os.check(FUNCTION_NAME); return os; } +} // End namespace Foam -ostream& Foam::operator<<(ostream& os, const token::punctuationToken& pt) -{ - return os << char(pt); -} - +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Ostream& Foam::operator<<(Ostream& os, const token::punctuationToken& pt) +Foam::token::token(Istream& is) +: + token() { - return os << char(pt); + is.read(*this); } -Foam::Ostream& Foam::operator<<(Ostream& os, const token::compound& ct) +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::word Foam::token::name() const { - os << ct.type() << token::SPACE; - ct.write(os); + switch (type_) + { + case token::tokenType::UNDEFINED: return "undefined"; + case token::tokenType::PUNCTUATION: return "punctuation"; + case token::tokenType::LABEL: return "label"; + case token::tokenType::FLOAT_SCALAR: return "float"; + case token::tokenType::DOUBLE_SCALAR: return "double"; + case token::tokenType::WORD: return "word"; + case token::tokenType::STRING: return "string"; + case token::tokenType::VERBATIMSTRING: return "verbatim"; + case token::tokenType::VARIABLE: return "variable"; + case token::tokenType::COMPOUND: return "compound"; + case token::tokenType::ERROR: return "error"; - return os; + default: + break; + } + + return "unknown(" + std::to_string(int(type_)) + ")"; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip) +Foam::Istream& Foam::operator>>(Istream& is, token& tok) { - const token& t = ip.t_; + tok.clear(); + return is.read(tok); +} - os << "on line " << t.lineNumber(); - switch (t.type()) +Foam::Ostream& Foam::operator<<(Ostream& os, const token& tok) +{ + switch (tok.type_) { case token::tokenType::UNDEFINED: - os << " an undefined token"; + os << "UNDEFINED"; + WarningInFunction + << "Undefined token" << endl; break; case token::tokenType::PUNCTUATION: - os << " the punctuation token " << '\'' << t.pToken() << '\''; - break; - - case token::tokenType::WORD: - os << " the word " << '\'' << t.wordToken() << '\''; + os << tok.data_.punctuationVal; break; - case token::tokenType::STRING: - os << " the string " << t.stringToken(); + case token::tokenType::LABEL: + os << tok.data_.labelVal; break; - case token::tokenType::VARIABLE: - os << " the variable " << t.stringToken(); + case token::tokenType::FLOAT_SCALAR: + os << tok.data_.floatVal; break; - case token::tokenType::VERBATIMSTRING: - os << " the verbatim string " << t.stringToken(); + case token::tokenType::DOUBLE_SCALAR: + os << tok.data_.doubleVal; break; - case token::tokenType::LABEL: - os << " the label " << t.labelToken(); + case token::tokenType::WORD: + os << *tok.data_.wordPtr; break; - case token::tokenType::FLOAT_SCALAR: - os << " the floatScalar " << t.floatScalarToken(); + case token::tokenType::STRING: + case token::tokenType::VERBATIMSTRING: + os << *tok.data_.stringPtr; break; - case token::tokenType::DOUBLE_SCALAR: - os << " the doubleScalar " << t.doubleScalarToken(); + case token::tokenType::VARIABLE: + // Behaviour differs according to stream type + os.write(tok); break; case token::tokenType::COMPOUND: - { - if (t.compoundToken().empty()) - { - os << " the empty compound of type " - << t.compoundToken().type(); - } - else - { - os << " the compound of type " - << t.compoundToken().type(); - } - } + os << *tok.data_.compoundPtr; break; case token::tokenType::ERROR: - os << " an error"; + os << "ERROR"; + WarningInFunction + << "Error token" << endl; break; default: - os << " an unknown token type " << '\'' << int(t.type()) << '\''; + os << "UNKNOWN"; + SeriousErrorInFunction + << "Unknown token" + << endl; } + os.check(FUNCTION_NAME); return os; } -template<> -Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<token>& ip) +ostream& Foam::operator<<(ostream& os, const token::punctuationToken& pt) { - const token& t = ip.t_; - - os << "on line " << t.lineNumber(); - - switch (t.type()) - { - case token::tokenType::UNDEFINED: - os << " an undefined token"; - break; - - case token::tokenType::PUNCTUATION: - os << " the punctuation token " << '\'' << t.pToken() << '\''; - break; - - case token::tokenType::WORD: - os << " the word " << '\'' << t.wordToken() << '\''; - break; + return os << char(pt); +} - case token::tokenType::STRING: - os << " the string " << t.stringToken(); - break; - case token::tokenType::VARIABLE: - os << " the variable " << t.stringToken(); - break; +Foam::Ostream& Foam::operator<<(Ostream& os, const token::punctuationToken& pt) +{ + return os << char(pt); +} - case token::tokenType::VERBATIMSTRING: - os << " the verbatim string " << t.stringToken(); - break; - case token::tokenType::LABEL: - os << " the label " << t.labelToken(); - break; +Foam::Ostream& Foam::operator<<(Ostream& os, const token::compound& ct) +{ + os << ct.type() << token::SPACE; + ct.write(os); - case token::tokenType::FLOAT_SCALAR: - os << " the floatScalar " << t.floatScalarToken(); - break; + return os; +} - case token::tokenType::DOUBLE_SCALAR: - os << " the doubleScalar " << t.doubleScalarToken(); - break; - case token::tokenType::COMPOUND: - { - if (t.compoundToken().empty()) - { - os << " the empty compound of type " - << t.compoundToken().type(); - } - else - { - os << " the compound of type " - << t.compoundToken().type(); - } - } - break; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - case token::tokenType::ERROR: - os << " an error"; - break; +ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip) +{ + return printTokenInfo(os, ip.t_); +} - default: - os << " an unknown token type " << '\'' << int(t.type()) << '\''; - } - return os; +template<> +Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<token>& ip) +{ + return printTokenInfo(os, ip.t_); } diff --git a/src/OpenFOAM/memory/refCount/refCount.H b/src/OpenFOAM/memory/refCount/refCount.H index a4a208b3c05..1f90ba73a49 100644 --- a/src/OpenFOAM/memory/refCount/refCount.H +++ b/src/OpenFOAM/memory/refCount/refCount.H @@ -36,8 +36,6 @@ See also #ifndef refCount_H #define refCount_H -#include "bool.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -50,20 +48,10 @@ namespace Foam class refCount { // Private data + int count_; - int count_; - - - // Private Member Functions - - //- Dissallow copy - refCount(const refCount&); - - //- Dissallow bitwise assignment - void operator=(const refCount&); - -protected: +public: // Constructors @@ -74,8 +62,6 @@ protected: {} -public: - // Member Functions //- Return the current reference count @@ -87,7 +73,7 @@ public: //- Return true if the reference count is zero bool unique() const { - return count_ == 0; + return !count_; } @@ -96,25 +82,25 @@ public: //- Increment the reference count void operator++() { - count_++; + ++count_; } //- Increment the reference count void operator++(int) { - count_++; + ++count_; } //- Decrement the reference count void operator--() { - count_--; + --count_; } //- Decrement the reference count void operator--(int) { - count_--; + --count_; } }; diff --git a/src/OpenFOAM/memory/tmp/tmp.H b/src/OpenFOAM/memory/tmp/tmp.H index 0da141b95a0..de9d05befda 100644 --- a/src/OpenFOAM/memory/tmp/tmp.H +++ b/src/OpenFOAM/memory/tmp/tmp.H @@ -161,7 +161,7 @@ public: //- Assignment to pointer changing this tmp to a temporary T inline void operator=(T* tPtr); - //- Assignment transfering the temporary T to this tmp + //- Assignment transferring the temporary T to this tmp inline void operator=(const tmp<T>& t); }; -- GitLab From 61534989dfb432aa8dceccbd635f3c6b8cf60db5 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 5 Nov 2017 22:07:17 +0100 Subject: [PATCH 097/126] ENH: simplify primitiveEntry parsing code, move append new tokens - simplify string output code --- applications/test/dictionary/testDict | 8 ++ src/OpenFOAM/Make/files | 1 - src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H | 2 +- .../db/IOstreams/Pstreams/UOPstream.C | 10 +- .../db/IOstreams/Pstreams/UOPstream.H | 2 +- src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C | 19 ++- .../db/IOstreams/Sstreams/ISstreamI.H | 6 +- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C | 105 +++++---------- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H | 4 +- .../db/IOstreams/Sstreams/prefixOSstream.C | 10 +- .../db/IOstreams/Sstreams/prefixOSstream.H | 2 +- .../db/IOstreams/StringStreams/StringStream.H | 4 +- src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C | 17 +-- src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H | 2 +- src/OpenFOAM/db/dictionary/dictionary.C | 10 +- .../dictionaryEntry/dictionaryEntry.C | 12 +- .../dictionaryListEntry/dictionaryListEntry.C | 40 ------ .../dictionaryListEntryIO.C | 10 ++ src/OpenFOAM/db/dictionary/entry/entryIO.C | 29 ++-- .../db/dictionary/functionEntries/README | 30 +++++ .../functionEntries/calcEntry/calcEntry.C | 4 +- .../functionEntry/functionEntry.C | 9 +- .../primitiveEntry/primitiveEntry.C | 45 ++++--- .../primitiveEntry/primitiveEntry.H | 24 ++-- .../primitiveEntry/primitiveEntryIO.C | 127 +++++++----------- .../primitiveEntry/primitiveEntryTemplates.C | 4 +- src/surfMesh/surfaceFormats/obj/OBJstream.C | 78 +++++------ 27 files changed, 289 insertions(+), 325 deletions(-) delete mode 100644 src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntry.C create mode 100644 src/OpenFOAM/db/dictionary/functionEntries/README diff --git a/applications/test/dictionary/testDict b/applications/test/dictionary/testDict index a933c543e3f..5fd1c07e862 100644 --- a/applications/test/dictionary/testDict +++ b/applications/test/dictionary/testDict @@ -95,6 +95,14 @@ boundaryField #include "testDict2" +verbatim #{ + + This is a somewhat larger chunk of verbatim text that we would much + prefer to move as a token rather than copying its entire content each + time we do parsing or need to resize the token list. + +#}; + foo { $active diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 782d12b42fa..cfe98bfe647 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -217,7 +217,6 @@ $(dictionaryEntry)/dictionaryEntry.C $(dictionaryEntry)/dictionaryEntryIO.C dictionaryListEntry = $(dictionary)/dictionaryListEntry -$(dictionaryListEntry)/dictionaryListEntry.C $(dictionaryListEntry)/dictionaryListEntryIO.C functionEntries = $(dictionary)/functionEntries diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index c8eb66976f3..990e0924e8c 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -97,7 +97,7 @@ public: // Write functions //- Write next token to stream - virtual Ostream& write(const token& t) = 0; + virtual Ostream& write(const token& tok) = 0; //- Write character virtual Ostream& write(const char c) = 0; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index b94ede40563..d9ffbd0ed90 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -185,18 +185,18 @@ Foam::UOPstream::~UOPstream() // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -Foam::Ostream& Foam::UOPstream::write(const token& t) +Foam::Ostream& Foam::UOPstream::write(const token& tok) { // Raw token output only supported for verbatim strings for now - if (t.type() == token::tokenType::VERBATIMSTRING) + if (tok.type() == token::tokenType::VERBATIMSTRING) { writeToBuffer(char(token::tokenType::VERBATIMSTRING)); - write(t.stringToken()); + write(tok.stringToken()); } - else if (t.type() == token::tokenType::VARIABLE) + else if (tok.type() == token::tokenType::VARIABLE) { writeToBuffer(char(token::tokenType::VARIABLE)); - write(t.stringToken()); + write(tok.stringToken()); } else { diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H index 364b10ccdda..c96b33ac8cf 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H @@ -147,7 +147,7 @@ public: ); //- Write next token to stream - Ostream& write(const token& t); + Ostream& write(const token& tok); //- Write single character. Whitespace is suppressed. Ostream& write(const char c); diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C index cc9a0e5a656..804eb97858c 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C @@ -164,7 +164,7 @@ Foam::Istream& Foam::ISstream::read(token& t) // Analyse input starting with this character. switch (c) { - // Check for punctuation first + // Check for punctuation first - same as token::isSeparator case token::END_STATEMENT : case token::BEGIN_LIST : @@ -288,7 +288,7 @@ Foam::Istream& Foam::ISstream::read(token& t) case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : { - bool asLabel = (c != '.'); + label labelVal = (c != '.'); // used as bool here unsigned nChar = 0; buf[nChar++] = c; @@ -308,9 +308,9 @@ Foam::Istream& Foam::ISstream::read(token& t) ) ) { - if (asLabel) + if (labelVal) { - asLabel = isdigit(c); + labelVal = isdigit(c); } buf[nChar++] = c; @@ -344,16 +344,15 @@ Foam::Istream& Foam::ISstream::read(token& t) // A single '-' is punctuation t = token::punctuationToken(token::SUBTRACT); } + else if (labelVal && Foam::read(buf, labelVal)) + { + t = labelVal; + } else { - label labelVal; scalar scalarVal; - if (asLabel && Foam::read(buf, labelVal)) - { - t = labelVal; - } - else if (readScalar(buf, scalarVal)) + if (readScalar(buf, scalarVal)) { // A scalar or too big to fit as a label t = scalarVal; diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H index ecad21b4173..6ceeb982c0b 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H @@ -59,7 +59,7 @@ inline Foam::ISstream& Foam::ISstream::get(char& c) if (good() && c == '\n') { - lineNumber_++; + ++lineNumber_; } return *this; @@ -76,7 +76,7 @@ inline Foam::ISstream& Foam::ISstream::getLine(string& str) { std::getline(is_, str); setState(is_.rdstate()); - lineNumber_++; + ++lineNumber_; return *this; } @@ -86,7 +86,7 @@ inline Foam::ISstream& Foam::ISstream::putback(const char c) { if (c == '\n') { - lineNumber_--; + --lineNumber_; } if (!is_.putback(c)) diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C index 3cdcf3e6d0d..1ace27022c1 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,21 +28,21 @@ License #include "OSstream.H" #include "stringOps.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::Ostream& Foam::OSstream::write(const token& t) +Foam::Ostream& Foam::OSstream::write(const token& tok) { - if (t.type() == token::tokenType::VERBATIMSTRING) + if (tok.type() == token::tokenType::VERBATIMSTRING) { write(char(token::HASH)); write(char(token::BEGIN_BLOCK)); - writeQuoted(t.stringToken(), false); + writeQuoted(tok.stringToken(), false); write(char(token::HASH)); write(char(token::END_BLOCK)); } - else if (t.type() == token::tokenType::VARIABLE) + else if (tok.type() == token::tokenType::VARIABLE) { - writeQuoted(t.stringToken(), false); + writeQuoted(tok.stringToken(), false); } return *this; } @@ -77,36 +77,51 @@ Foam::Ostream& Foam::OSstream::write(const word& str) } -Foam::Ostream& Foam::OSstream::write(const string& str) +Foam::Ostream& Foam::OSstream::writeQuoted +( + const std::string& str, + const bool quoted +) { + if (!quoted) + { + // Output unquoted, only advance line number on newline + lineNumber_ += stringOps::count(str, token::NL); + os_ << str; + + setState(os_.rdstate()); + return *this; + } + + + // Output with surrounding quotes and backslash escaping os_ << token::BEGIN_STRING; - int backslash = 0; + unsigned backslash = 0; for (auto iter = str.cbegin(); iter != str.cend(); ++iter) { const char c = *iter; if (c == '\\') { - backslash++; - // suppress output until we know if other characters follow - continue; + ++backslash; + continue; // only output after escaped character is known } else if (c == token::NL) { - lineNumber_++; - backslash++; // backslash escape for newline + ++lineNumber_; + ++backslash; // backslash escape for newline } else if (c == token::END_STRING) { - backslash++; // backslash escape for quote + ++backslash; // backslash escape for quote } - // output pending backslashes + // output all pending backslashes while (backslash) { os_ << '\\'; - backslash--; + --backslash; } os_ << c; @@ -114,7 +129,6 @@ Foam::Ostream& Foam::OSstream::write(const string& str) // silently drop any trailing backslashes // they would otherwise appear like an escaped end-quote - os_ << token::END_STRING; setState(os_.rdstate()); @@ -122,60 +136,9 @@ Foam::Ostream& Foam::OSstream::write(const string& str) } -Foam::Ostream& Foam::OSstream::writeQuoted -( - const std::string& str, - const bool quoted -) +Foam::Ostream& Foam::OSstream::write(const string& str) { - if (quoted) - { - os_ << token::BEGIN_STRING; - - int backslash = 0; - for (auto iter = str.cbegin(); iter != str.cend(); ++iter) - { - const char c = *iter; - - if (c == '\\') - { - backslash++; - // suppress output until we know if other characters follow - continue; - } - else if (c == token::NL) - { - lineNumber_++; - backslash++; // backslash escape for newline - } - else if (c == token::END_STRING) - { - backslash++; // backslash escape for quote - } - - // output pending backslashes - while (backslash) - { - os_ << '\\'; - backslash--; - } - - os_ << c; - } - - // silently drop any trailing backslashes - // they would otherwise appear like an escaped end-quote - os_ << token::END_STRING; - } - else - { - // output unquoted string, only advance line number on newline - lineNumber_ += stringOps::count(str, token::NL); - os_ << str; - } - - setState(os_.rdstate()); - return *this; + return writeQuoted(str, true); } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H index 2dd13c50fb2..753bad7ca55 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H @@ -105,7 +105,7 @@ public: // Write functions //- Write next token to stream - virtual Ostream& write(const token& t); + virtual Ostream& write(const token& tok); //- Write character virtual Ostream& write(const char c); @@ -116,7 +116,7 @@ public: //- Write word virtual Ostream& write(const word& str); - //- Write string + //- Write string (quoted) // In the rare case that the string contains a final trailing // backslash, it will be dropped to the appearance of an escaped // double-quote. diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C index 42a2df76c97..fcafc89f7fa 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C @@ -65,19 +65,19 @@ void Foam::prefixOSstream::print(Ostream& os) const } -Foam::Ostream& Foam::prefixOSstream::write(const token& t) +Foam::Ostream& Foam::prefixOSstream::write(const token& tok) { - if (t.type() == token::tokenType::VERBATIMSTRING) + if (tok.type() == token::tokenType::VERBATIMSTRING) { write(char(token::HASH)); write(char(token::BEGIN_BLOCK)); - writeQuoted(t.stringToken(), false); + writeQuoted(tok.stringToken(), false); write(char(token::HASH)); write(char(token::END_BLOCK)); } - else if (t.type() == token::tokenType::VARIABLE) + else if (tok.type() == token::tokenType::VARIABLE) { - writeQuoted(t.stringToken(), false); + writeQuoted(tok.stringToken(), false); } return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H index 8912793a552..4c9eca7b448 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H @@ -99,7 +99,7 @@ public: // Write functions //- Write next token to stream - virtual Ostream& write(const token& t); + virtual Ostream& write(const token& tok); //- Write character virtual Ostream& write(const char c); diff --git a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H index ab9f3356124..83f75c642a0 100644 --- a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H +++ b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C index ca31271fa32..24258a1fa32 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C @@ -134,19 +134,19 @@ void Foam::ITstream::print(Ostream& os) const } -Foam::Istream& Foam::ITstream::read(token& t) +Foam::Istream& Foam::ITstream::read(token& tok) { // Return the put back token if it exists - if (Istream::getBack(t)) + if (Istream::getBack(tok)) { - lineNumber_ = t.lineNumber(); + lineNumber_ = tok.lineNumber(); return *this; } if (tokenIndex_ < size()) { - t = operator[](tokenIndex_++); - lineNumber_ = t.lineNumber(); + tok = operator[](tokenIndex_++); + lineNumber_ = tok.lineNumber(); if (tokenIndex_ == size()) { @@ -170,15 +170,15 @@ Foam::Istream& Foam::ITstream::read(token& t) setEof(); } - t = token::undefinedToken; + tok = token::undefinedToken; if (size()) { - t.lineNumber() = tokenList::last().lineNumber(); + tok.lineNumber() = tokenList::last().lineNumber(); } else { - t.lineNumber() = lineNumber(); + tok.lineNumber() = lineNumber(); } } @@ -238,6 +238,7 @@ Foam::Istream& Foam::ITstream::read(char*, std::streamsize) void Foam::ITstream::rewind() { tokenIndex_ = 0; + lineNumber_ = 0; if (size()) { diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H index af9fff4bef9..f6c96f12720 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H @@ -208,7 +208,7 @@ public: // Read functions //- Return next token from stream - virtual Istream& read(token& t); + virtual Istream& read(token& tok); //- Read a character virtual Istream& read(char&); diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index f4fc9d63369..6c4697e7edb 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -217,14 +217,16 @@ Foam::tokenList Foam::dictionary::tokens() const // Serialize dictionary into a string OStringStream os; write(os, false); + IStringStream is(os.str()); - // Parse string as tokens DynamicList<token> tokens; - token t; - while (is.read(t)) + + // Parse string as tokens + token tok; + while (is.read(tok)) { - tokens.append(t); + tokens.append(std::move(tok)); } return tokenList(tokens.xfer()); diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C index 6167956e709..262c6b4fb45 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C +++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C @@ -58,10 +58,8 @@ Foam::label Foam::dictionaryEntry::startLineNumber() const { return first()->startLineNumber(); } - else - { - return -1; - } + + return -1; } @@ -71,10 +69,8 @@ Foam::label Foam::dictionaryEntry::endLineNumber() const { return last()->endLineNumber(); } - else - { - return -1; - } + + return -1; } diff --git a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntry.C b/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntry.C deleted file mode 100644 index 055a55b59de..00000000000 --- a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntry.C +++ /dev/null @@ -1,40 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 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 "dictionaryListEntry.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::dictionaryListEntry::dictionaryListEntry -( - const dictionary& parentDict, - const dictionaryListEntry& dictEnt -) -: - dictionaryEntry(parentDict, dictEnt) -{} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C b/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C index 53399cc5430..041c1072585 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C @@ -44,6 +44,16 @@ static Foam::label realSize(const Foam::dictionary& dict) // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::dictionaryListEntry::dictionaryListEntry +( + const dictionary& parentDict, + const dictionaryListEntry& dictEnt +) +: + dictionaryEntry(parentDict, dictEnt) +{} + + Foam::dictionaryListEntry::dictionaryListEntry ( const dictionary& parentDict, diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index 14bf0beb54e..b1fb4b92baa 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -56,7 +56,8 @@ bool Foam::entry::getKeyword(keyType& keyword, token& keyToken, Istream& is) keyword = keyToken.wordToken(); return true; } - else if (keyToken.isString()) + + if (keyToken.isString()) { // Enable wildcards keyword = keyToken.stringToken(); @@ -136,7 +137,8 @@ bool Foam::entry::New { return false; } - else if + + if ( keyToken.isLabel() || (keyToken.isPunctuation() && keyToken.pToken() == token::BEGIN_LIST) @@ -162,9 +164,10 @@ bool Foam::entry::New return false; } + if (keyword[0] == '#') { - // Function entry + // Function entry - #function if (disableFunctionEntries) { @@ -183,9 +186,11 @@ bool Foam::entry::New const word functionName(keyword.substr(1), false); return functionEntry::execute(functionName, parentDict, is); } - else if (!disableFunctionEntries && keyword[0] == '$') + + + if (!disableFunctionEntries && keyword[0] == '$') { - // Substitution entry + // Substitution entry - $variable token nextToken(is); is.putBack(nextToken); @@ -245,10 +250,10 @@ bool Foam::entry::New return true; } - else - { - // Normal or scoped entry + + // Normal or scoped entry + { token nextToken(is); is.putBack(nextToken); @@ -399,11 +404,9 @@ bool Foam::entry::New ); } } - else - { - // Some error finding/creating intermediate dictionaries - return false; - } + + // Some error finding/creating intermediate dictionaries + return false; } else { diff --git a/src/OpenFOAM/db/dictionary/functionEntries/README b/src/OpenFOAM/db/dictionary/functionEntries/README new file mode 100644 index 00000000000..0dc051a5d7f --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/README @@ -0,0 +1,30 @@ +| directive | context | content | line oriented? +|-------------------|-------------------|-------------------|----------------- + #inputMode | dict | word + #default | dict | entry introducer + #merge | dict | entry introducer + #overwrite | dict | entry introducer + #warn | dict | entry introducer + #error | dict | entry introducer + | | + #remove | dict | readList<keyType> + | | + #include | dict/primitive | string + #includeEtc | dict/primitive | string + #includeIfPresent | dict/primitive | string + #includeFunc | dict | word + | | + #calcEntry | dict/primitive | string + #codeStream | dict/primitive | dictionary + + +Pending future extensions + +| directive | context | content | line oriented? +|-------------------|-------------------|-------------------|----------------- + #define | dict | entry introducer + #local | dict | entry introducer + #undef | dict | readList<word> + + +2017-11-05 diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C index a7e2e2c9492..4fa4a4a2719 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C @@ -66,7 +66,7 @@ bool Foam::functionEntries::calcEntry::execute Istream& is ) { - Info<< "Using #calcEntry at line " << is.lineNumber() + Info<< "Using #calc at line " << is.lineNumber() << " in file " << parentDict.name() << endl; dynamicCode::checkSecurity @@ -110,7 +110,7 @@ bool Foam::functionEntries::calcEntry::execute Istream& is ) { - Info<< "Using #calcEntry at line " << is.lineNumber() + Info<< "Using #calc at line " << is.lineNumber() << " in file " << parentDict.name() << endl; dynamicCode::checkSecurity diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index 2798b924e3a..8eba79a926f 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -160,13 +160,16 @@ bool Foam::functionEntry::execute void Foam::functionEntry::write(Ostream& os) const { // Contents should be single string token - const token& t = operator[](0); - const string& s = t.stringToken(); + const token& tok = operator[](0); + const string& s = tok.stringToken(); - for (size_t i = 0; i < s.size(); i++) + // Write character-wise for literal output + for (size_t i = 0; i < s.size(); ++i) { os.write(s[i]); } + + os << nl; } diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C index 88750273e7c..76a0c482c41 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C @@ -30,11 +30,23 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::primitiveEntry::append(const UList<token>& varTokens) +void Foam::primitiveEntry::appendTokenList(const UList<token>& varTokens) { for (const token& tok : varTokens) { - newElmt(tokenIndex()++) = tok; + newElmt(tokenIndex()++) = tok; // append copy + } +} + + +void Foam::primitiveEntry::appendTokensFromString(const string& input) +{ + IStringStream is(input); + + token tok; + while (!is.read(tok).bad() && tok.good()) + { + newElmt(tokenIndex()++) = std::move(tok); } } @@ -85,17 +97,18 @@ bool Foam::primitiveEntry::expandVariable return false; } - append(tokenList(IStringStream('(' + str + ')')())); + // Split input string into a stream of tokens and append to list + appendTokensFromString(str); } else if (eptr->isDict()) { // Found dictionary entry - append(eptr->dict().tokens()); + appendTokenList(eptr->dict().tokens()); } else { // Found primitive entry - append(eptr->stream()); + appendTokenList(eptr->stream()); } return true; @@ -113,10 +126,10 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& is) } -Foam::primitiveEntry::primitiveEntry(const keyType& key, const token& t) +Foam::primitiveEntry::primitiveEntry(const keyType& key, const token& tok) : entry(key), - ITstream(key, tokenList(1, t)) + ITstream(key, tokenList(1, tok)) {} @@ -148,14 +161,12 @@ Foam::label Foam::primitiveEntry::startLineNumber() const { const tokenList& tokens = *this; - if (tokens.empty()) + if (tokens.size()) { - return -1; - } - else - { - return tokens.first().lineNumber(); + tokens.first().lineNumber(); } + + return -1; } @@ -163,14 +174,12 @@ Foam::label Foam::primitiveEntry::endLineNumber() const { const tokenList& tokens = *this; - if (tokens.empty()) - { - return -1; - } - else + if (tokens.size()) { return tokens.last().lineNumber(); } + + return -1; } diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H index 38e9412a8df..59c2a757346 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H @@ -64,17 +64,25 @@ class primitiveEntry { // Private Member Functions - //- Append the given tokens starting at the current tokenIndex - void append(const UList<token>& varTokens); - - //- Append the given token to this entry - void append + //- Test if token is acceptable after filtering for function entries + //- and variable expansions. + bool acceptToken ( - const token& currToken, + const token& tok, const dictionary& dict, Istream& is ); + //- Append the given tokens at the current tokenIndex + // No filtering on the tokens. + void appendTokenList(const UList<token>& varTokens); + + //- Split input string into a stream of tokens and append at the + //- current tokenIndex. + // No filtering on the tokens. + void appendTokensFromString(const string& input); + + //- Expand the given variable. // The keyword starts with '$', but has been removed by the caller // and thus passed as a varName. @@ -113,7 +121,7 @@ public: primitiveEntry(const keyType& key, const ITstream& is); //- Construct from keyword and a single token - primitiveEntry(const keyType& key, const token& t); + primitiveEntry(const keyType& key, const token& tok); //- Construct from keyword and a list of tokens primitiveEntry(const keyType& key, const UList<token>& tokens); @@ -123,7 +131,7 @@ public: //- Construct from keyword and a T template<class T> - primitiveEntry(const keyType& key, const T& t); + primitiveEntry(const keyType& key, const T& val); autoPtr<entry> clone(const dictionary&) const { diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index 6a040941e74..1d91eccf6ca 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -28,18 +28,20 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::primitiveEntry::append +bool Foam::primitiveEntry::acceptToken ( - const token& currToken, + const token& tok, const dictionary& dict, Istream& is ) { - if (currToken.isWord()) + bool accept = tok.good(); + + if (tok.isWord()) { - const word& key = currToken.wordToken(); + const word& key = tok.wordToken(); - if + accept = ( disableFunctionEntries || key.size() == 1 @@ -47,16 +49,13 @@ void Foam::primitiveEntry::append !(key[0] == '$' && expandVariable(key.substr(1), dict)) && !(key[0] == '#' && expandFunction(key.substr(1), dict, is)) ) - ) - { - newElmt(tokenIndex()++) = currToken; - } + ); } - else if (currToken.isVariable()) + else if (tok.isVariable()) { - const string& key = currToken.stringToken(); + const string& key = tok.stringToken(); - if + accept = ( disableFunctionEntries || key.size() <= 3 @@ -65,15 +64,10 @@ void Foam::primitiveEntry::append && key[1] == token::BEGIN_BLOCK && expandVariable(key.substr(1), dict) ) - ) - { - newElmt(tokenIndex()++) = currToken; - } - } - else - { - newElmt(tokenIndex()++) = currToken; + ); } + + return accept; } @@ -92,65 +86,41 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is) { is.fatalCheck(FUNCTION_NAME); - label blockCount = 0; - token currToken; + label depth = 0; + token tok; - if + while ( - !is.read(currToken).bad() - && currToken.good() - && currToken != token::END_STATEMENT + !is.read(tok).bad() && tok.good() + && !(tok == token::END_STATEMENT && depth == 0) ) { - append(currToken, dict, is); - - if - ( - currToken == token::BEGIN_BLOCK - || currToken == token::BEGIN_LIST - ) + if (tok.isPunctuation()) { - blockCount++; - } - - while - ( - !is.read(currToken).bad() - && currToken.good() - && !(currToken == token::END_STATEMENT && blockCount == 0) - ) - { - if - ( - currToken == token::BEGIN_BLOCK - || currToken == token::BEGIN_LIST - ) + const char c = tok.pToken(); + if (c == token::BEGIN_BLOCK || c == token::BEGIN_LIST) { - blockCount++; + ++depth; } - else if - ( - currToken == token::END_BLOCK - || currToken == token::END_LIST - ) + else if (c == token::END_BLOCK || c == token::END_LIST) { - blockCount--; + --depth; } + } - append(currToken, dict, is); + if (acceptToken(tok, dict, is)) + { + newElmt(tokenIndex()++) = std::move(tok); } - } - is.fatalCheck(FUNCTION_NAME); + // With/without move: clear any old content and force to have a + // known good token so that we can rely on it for the return value. - if (currToken.good()) - { - return true; - } - else - { - return false; + tok = token::punctuationToken::NULL_TOKEN; } + + is.fatalCheck(FUNCTION_NAME); + return tok.good(); } @@ -227,24 +197,27 @@ void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const os.writeKeyword(keyword()); } - bool space = false; // Separate from previous tokens with a space - for (const token& t : *this) + bool addSpace = false; // Separate from previous tokens with a space + for (const token& tok : *this) { - if (space) - { - os << token::SPACE; - } - space = true; // Prefix any following tokens - - if (t.type() == token::tokenType::VERBATIMSTRING) + if (tok.type() == token::tokenType::VERBATIMSTRING) { // Bypass token output operator to avoid losing verbatimness. - // Handle in Ostreams themselves - os.write(t); + // Handled in the Ostreams themselves + + if (addSpace) os << token::SPACE; + + os.write(tok); + + addSpace = true; // Separate from following tokens } else { - os << t; + if (addSpace) os << token::SPACE; + + os << tok; + + addSpace = true; // Separate from following tokens } } diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C index 29f11a5c80f..ce36746fee8 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C @@ -30,13 +30,13 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class T> -Foam::primitiveEntry::primitiveEntry(const keyType& key, const T& t) +Foam::primitiveEntry::primitiveEntry(const keyType& key, const T& val) : entry(key), ITstream(key, tokenList(10)) { OStringStream os; - os << t << token::END_STATEMENT; + os << val << token::END_STATEMENT; readEntry(dictionary::null, IStringStream(os.str())()); } diff --git a/src/surfMesh/surfaceFormats/obj/OBJstream.C b/src/surfMesh/surfaceFormats/obj/OBJstream.C index 2fcf7f43052..2056c51d5a8 100644 --- a/src/surfMesh/surfaceFormats/obj/OBJstream.C +++ b/src/surfMesh/surfaceFormats/obj/OBJstream.C @@ -48,9 +48,10 @@ void Foam::OBJstream::writeAndCheck(const char c) startOfLine_ = false; if (c == 'v') { - nVertices_++; + ++nVertices_; } } + OFstream::write(c); } @@ -88,9 +89,9 @@ Foam::Ostream& Foam::OBJstream::write(const char c) Foam::Ostream& Foam::OBJstream::write(const char* str) { - for (const char* p = str; *p != '\0'; ++p) + for (const char* iter = str; *iter; ++iter) { - writeAndCheck(*p); + writeAndCheck(*iter); } return *this; } @@ -114,54 +115,53 @@ Foam::Ostream& Foam::OBJstream::writeQuoted const bool quoted ) { - if (quoted) + if (!quoted) { - OFstream::write(token::BEGIN_STRING); - - int backslash = 0; + // Output unquoted, only advance line number on newline for (auto iter = str.cbegin(); iter != str.cend(); ++iter) { - const char c = *iter; + writeAndCheck(*iter); + } + return *this; + } - if (c == '\\') - { - backslash++; - // suppress output until we know if other characters follow - continue; - } - else if (c == token::NL) - { - lineNumber_++; - backslash++; // backslash escape for newline - } - else if (c == token::END_STRING) - { - backslash++; // backslash escape for quote - } - // output pending backslashes - while (backslash) - { - OFstream::write('\\'); - backslash--; - } + OFstream::write(token::BEGIN_STRING); - writeAndCheck(c); + unsigned backslash = 0; + for (auto iter = str.cbegin(); iter != str.cend(); ++iter) + { + const char c = *iter; + + if (c == '\\') + { + ++backslash; + continue; // only output after escaped character is known + } + else if (c == token::NL) + { + ++lineNumber_; + ++backslash; // backslash escape for newline + } + else if (c == token::END_STRING) + { + ++backslash; // backslash escape for quote } - // silently drop any trailing backslashes - // they would otherwise appear like an escaped end-quote - OFstream::write(token::END_STRING); - } - else - { - // output unquoted string, only advance line number on newline - for (auto iter = str.cbegin(); iter != str.cend(); ++iter) + // output all pending backslashes + while (backslash) { - writeAndCheck(*iter); + OFstream::write('\\'); + --backslash; } + + writeAndCheck(c); } + // silently drop any trailing backslashes + // they would otherwise appear like an escaped end-quote + OFstream::write(token::END_STRING); + return *this; } -- GitLab From c0ba7bf05ac7503c418b9c424caeb3809c31133f Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 6 Nov 2017 00:49:24 +0100 Subject: [PATCH 098/126] STYLE: use Ostream writeEntry when writing key/value entries - makes for clearer code ENH: make writeIfDifferent part of Ostream --- .../T/smoluchowskiJumpTFvPatchScalarField.C | 14 +++-- .../BCs/U/maxwellSlipUFvPatchVectorField.C | 20 ++++---- .../BCs/rho/fixedRhoFvPatchScalarField.C | 4 +- .../alphaContactAngleFvPatchScalarField.C | 3 +- .../alphaContactAngleFvPatchScalarField.C | 3 +- .../alphaContactAngleFvPatchScalarField.C | 3 +- .../alphaContactAngleFvPatchScalarField.C | 3 +- ...allBoilingWallFunctionFvPatchScalarField.C | 6 +-- ...ayatillekeWallFunctionFvPatchScalarField.C | 8 +-- ...allBoilingWallFunctionFvPatchScalarField.C | 30 +++++------ .../copiedFixedValueFvPatchScalarField.C | 3 +- ...ixedMultiPhaseHeatFluxFvPatchScalarField.C | 2 +- .../KocamustafaogullariIshii.C | 2 +- .../TolubinskiKostanchuk.C | 6 +-- .../departureDiameterModel.C | 2 +- .../departureFrequencyModel.C | 2 +- .../nucleationSiteModel/nucleationSiteModel.C | 2 +- .../Lavieville/Lavieville.C | 2 +- .../partitioningModels/cosine/cosine.C | 6 +-- .../partitioningModels/linear/linear.C | 6 +-- .../partitioningModel/partitioningModel.C | 2 +- ...sonJacksonParticleSlipFvPatchVectorField.C | 3 +- ...onJacksonParticleThetaFvPatchScalarField.C | 6 +-- ...sonJacksonParticleSlipFvPatchVectorField.C | 3 +- ...onJacksonParticleThetaFvPatchScalarField.C | 6 +-- etc/codeTemplates/BC/BC.C | 6 +-- src/OSspecific/POSIX/cpuInfo/cpuInfo.C | 26 +++------- src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H | 22 +++++++- src/OpenFOAM/fields/Fields/Field/Field.C | 5 +- .../UniformDimensionedField.C | 6 +-- .../codedFixedValuePointPatchField.C | 6 +-- .../fixedNormalSlipPointPatchField.C | 3 +- .../pointPatchField/pointPatchField.C | 22 +------- .../pointPatchField/pointPatchField.H | 11 ---- .../global/profiling/profilingInformation.C | 10 +--- .../interpolationLookUpTable.C | 10 ++-- .../tableReaders/csv/csvTableReader.C | 13 ++--- .../tableReaders/tableReader.C | 5 +- .../basic/generic/genericPolyPatch.C | 6 +-- .../constraint/cyclic/cyclicPolyPatch.C | 12 ++--- .../constraint/oldCyclic/oldCyclicPolyPatch.C | 18 +++---- .../constraint/processor/processorPolyPatch.C | 6 +-- .../processorCyclicPolyPatch.C | 9 +--- .../polyPatches/polyPatch/polyPatch.C | 6 +-- .../functions/Function1/Scale/Scale.C | 8 +-- .../functions/Function1/Table/TableBase.C | 25 ++++----- .../functions/Function1/ramp/ramp.C | 12 +++-- ...convectiveHeatTransferFvPatchScalarField.C | 2 +- ...pedMassWallTemperatureFvPatchScalarField.C | 5 +- ...ppedUniformInletHeatAdditionFvPatchField.C | 11 ++-- .../thermalBaffle1DFvPatchScalarField.C | 5 +- ...RateAdvectiveDiffusiveFvPatchScalarField.C | 7 ++- ...tureCoupledBaffleMixedFvPatchScalarField.C | 3 +- ...eratureRadCoupledMixedFvPatchScalarField.C | 9 ++-- ...ayatillekeWallFunctionFvPatchScalarField.C | 8 +-- .../alphatWallFunctionFvPatchScalarField.C | 2 +- ...ayatillekeWallFunctionFvPatchScalarField.C | 8 +-- .../atmBoundaryLayer/atmBoundaryLayer.C | 18 +++---- ...thDissipationRateInletFvPatchScalarField.C | 7 ++- ...ngLengthFrequencyInletFvPatchScalarField.C | 7 ++- .../fixedShearStressFvPatchVectorField.C | 2 +- .../porousBafflePressureFvPatchField.C | 9 ++-- .../epsilonWallFunctionFvPatchScalarField.C | 6 +-- .../fWallFunctionFvPatchScalarField.C | 6 +-- .../kLowReWallFunctionFvPatchScalarField.C | 8 +-- .../nutURoughWallFunctionFvPatchScalarField.C | 9 ++-- ...UTabulatedWallFunctionFvPatchScalarField.C | 3 +- .../nutWallFunctionFvPatchScalarField.C | 6 +-- .../omegaWallFunctionFvPatchScalarField.C | 10 ++-- .../v2WallFunctionFvPatchScalarField.C | 6 +-- src/dynamicMesh/attachDetach/attachDetach.C | 28 +++++----- src/dynamicMesh/boundaryPatch/boundaryPatch.C | 4 +- ...yMotionDisplacementPointPatchVectorField.C | 4 +- .../perfectInterface/perfectInterface.C | 36 ++++--------- src/dynamicMesh/setUpdater/setUpdater.C | 27 +++------- .../slidingInterface/slidingInterface.C | 48 +++++++---------- .../cfdTools/general/MRF/MRFZone.C | 17 +++---- .../SRFFreestreamVelocityFvPatchVectorField.C | 6 +-- .../SRFVelocityFvPatchVectorField.C | 2 +- .../cfdTools/general/fvOptions/fvOptionIO.C | 13 +++-- .../activeBaffleVelocityFvPatchVectorField.C | 18 +++---- ...ureForceBaffleVelocityFvPatchVectorField.C | 23 +++------ .../derived/advective/advectiveFvPatchField.C | 8 +-- .../codedFixedValueFvPatchField.C | 6 +-- .../codedMixed/codedMixedFvPatchField.C | 3 +- ...lindricalInletVelocityFvPatchVectorField.C | 4 +- .../derived/fan/fanFvPatchField.C | 9 ++-- .../derived/fixedJump/fixedJumpFvPatchField.C | 3 +- .../fixedJumpAMI/fixedJumpAMIFvPatchField.C | 3 +- ...malInletOutletVelocityFvPatchVectorField.C | 12 ++--- ...ureCompressibleDensityFvPatchScalarField.C | 2 +- .../fixedProfile/fixedProfileFvPatchField.C | 4 +- .../flowRateInletVelocityFvPatchVectorField.C | 7 ++- ...flowRateOutletVelocityFvPatchVectorField.C | 4 +- .../fluxCorrectedVelocityFvPatchVectorField.C | 4 +- .../freestream/freestreamFvPatchField.C | 6 +-- .../freestreamPressureFvPatchScalarField.C | 6 +-- .../inletOutlet/inletOutletFvPatchField.C | 5 +- ...OutletTotalTemperatureFvPatchScalarField.C | 8 +-- ...erstitialInletVelocityFvPatchVectorField.C | 2 +- .../mappedField/mappedPatchFieldBase.C | 9 ++-- .../mappedFlowRateFvPatchVectorField.C | 6 +-- ...mappedVelocityFluxFixedValueFvPatchField.C | 2 +- ...FlowRateOutletVelocityFvPatchVectorField.C | 8 ++- .../outletInlet/outletInletFvPatchField.C | 5 +- .../outletMappedUniformInletFvPatchField.C | 8 +-- ...utletPhaseMeanVelocityFvPatchVectorField.C | 6 +-- ...aseHydrostaticPressureFvPatchScalarField.C | 12 ++--- .../plenumPressureFvPatchScalarField.C | 36 +++++-------- ...tedInletOutletVelocityFvPatchVectorField.C | 4 +- ...eDirectedInletVelocityFvPatchVectorField.C | 4 +- ...tOutletParSlipVelocityFvPatchVectorField.C | 4 +- ...ureInletOutletVelocityFvPatchVectorField.C | 2 +- .../pressureInletVelocityFvPatchVectorField.C | 4 +- ...malInletOutletVelocityFvPatchVectorField.C | 4 +- ...IDControlInletVelocityFvPatchVectorField.C | 25 ++++----- .../prghPressureFvPatchScalarField.C | 2 +- ...talHydrostaticPressureFvPatchScalarField.C | 8 +-- .../prghTotalPressureFvPatchScalarField.C | 6 +-- ...ureInletOutletVelocityFvPatchVectorField.C | 2 +- .../rotatingWallVelocityFvPatchVectorField.C | 4 +- .../supersonicFreestreamFvPatchVectorField.C | 14 ++--- ...lFlowRateInletVelocityFvPatchVectorField.C | 8 +-- .../swirlInletVelocityFvPatchVectorField.C | 4 +- .../syringePressureFvPatchScalarField.C | 22 ++++---- .../timeVaryingMappedFixedValueFvPatchField.C | 13 ++--- .../totalPressureFvPatchScalarField.C | 10 ++-- .../totalTemperatureFvPatchScalarField.C | 8 +-- .../turbulentDFSEMInletFvPatchVectorField.C | 26 +++++----- .../turbulentInletFvPatchField.C | 5 +- ...sityKineticEnergyInletFvPatchScalarField.C | 6 +-- ...ityHydrostaticPressureFvPatchScalarField.C | 6 +-- .../uniformInletOutletFvPatchField.C | 5 +- .../uniformTotalPressureFvPatchScalarField.C | 10 ++-- .../variableHeightFlowRateFvPatchField.C | 9 ++-- ...tFlowRateInletVelocityFvPatchVectorField.C | 2 +- .../waveSurfacePressureFvPatchScalarField.C | 6 +-- .../waveTransmissiveFvPatchField.C | 17 +++---- .../fvPatchFields/fvPatchField/fvPatchField.C | 22 +------- .../fvPatchFields/fvPatchField/fvPatchField.H | 11 ---- .../fvsPatchField/fvsPatchField.C | 2 +- ...llatingDisplacementPointPatchVectorField.C | 15 ++---- ...OscillatingVelocityPointPatchVectorField.C | 15 ++---- ...llatingDisplacementPointPatchVectorField.C | 6 +-- ...oscillatingVelocityPointPatchVectorField.C | 6 +-- ...surfaceDisplacementPointPatchVectorField.C | 10 ++-- ...aceSlipDisplacementPointPatchVectorField.C | 11 ++-- ...meVaryingMappedFixedValuePointPatchField.C | 13 ++--- ...polatedDisplacementPointPatchVectorField.C | 6 +-- .../waveDisplacementPointPatchVectorField.C | 9 ++-- .../genericFvPatchField/genericFvPatchField.C | 2 +- .../genericPointPatchField.C | 2 +- .../phaseProperties/phasePropertiesIO.C | 17 +++---- .../submodels/CloudSubModelBase.C | 3 +- .../DispersionRASModel/DispersionRASModel.C | 5 +- src/lumpedPointMotion/lumpedPointState.C | 2 +- .../cyclicACMIPolyPatch/cyclicACMIPolyPatch.C | 3 +- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C | 38 ++++++-------- .../cyclicPeriodicAMIPolyPatch.C | 23 ++------- .../coordinateSystems/coordinateSystem.C | 14 +++-- .../mappedPolyPatch/mappedPatchBase.C | 3 +- .../mappedVariableThicknessWallPolyPatch.C | 2 +- .../regionCoupledBase.C | 12 ++--- ...sRadiativeCoupledMixedFvPatchScalarField.C | 19 +++---- ...ysisTemperatureCoupledFvPatchScalarField.C | 10 ++-- ...rolysisVelocityCoupledFvPatchVectorField.C | 10 ++-- ...ilmHeightInletVelocityFvPatchVectorField.C | 6 +-- ...linedFilmNusseltHeightFvPatchScalarField.C | 3 +- ...lmNusseltInletVelocityFvPatchVectorField.C | 3 +- ...alphatFilmWallFunctionFvPatchScalarField.C | 13 +++-- .../nutkFilmWallFunctionFvPatchScalarField.C | 7 ++- .../thermalBaffleFvPatchScalarField.C | 5 +- src/rigidBodyDynamics/bodies/cuboid/cuboid.C | 11 ++-- .../bodies/masslessBody/masslessBody.C | 3 +- .../bodies/rigidBody/rigidBody.C | 15 ++---- src/rigidBodyDynamics/bodies/sphere/sphere.C | 11 ++-- .../bodies/subBody/subBody.C | 7 +-- src/rigidBodyDynamics/joints/Pa/Pa.C | 3 +- src/rigidBodyDynamics/joints/Ra/Ra.C | 3 +- src/rigidBodyDynamics/joints/joint/joint.C | 2 +- src/rigidBodyDynamics/joints/joint/jointI.H | 4 +- .../linearAxialAngularSpring.C | 15 ++---- .../restraints/linearDamper/linearDamper.C | 3 +- .../restraints/linearSpring/linearSpring.C | 19 ++----- .../restraints/restraint/rigidBodyRestraint.C | 6 +-- .../sphericalAngularDamper.C | 2 +- .../rigidBodyModel/rigidBodyModel.C | 50 +++++++----------- .../rigidBodyModelStateIO.C | 8 +-- .../rigidBodyMotion/rigidBodyMotionIO.C | 9 ++-- ...gidBodyDisplacementPointPatchVectorField.C | 6 +-- .../sixDoFRigidBodyMotionAxisConstraint.C | 3 +- .../sixDoFRigidBodyMotionLineConstraint.C | 6 +-- .../sixDoFRigidBodyMotionPlaneConstraint.C | 6 +-- .../sixDoFRigidBodyMotionPointConstraint.C | 3 +- .../linearAxialAngularSpring.C | 15 ++---- .../restraints/linearDamper/linearDamper.C | 3 +- .../restraints/linearSpring/linearSpring.C | 19 ++----- .../sphericalAngularDamper.C | 2 +- .../sphericalAngularSpring.C | 9 ++-- .../tabulatedAxialAngularSpring.C | 16 ++---- .../sixDoFRigidBodyMotionIO.C | 51 +++++++------------ .../sixDoFRigidBodyMotionStateIO.C | 18 +++---- src/surfMesh/surfZone/surfZone/surfZone.C | 9 ++-- .../MarshakRadiationFvPatchScalarField.C | 2 +- ...iffusiveRadiationMixedFvPatchScalarField.C | 4 +- ...veViewFactorFixedValueFvPatchScalarField.C | 2 +- .../Reactions/solidReaction/solidReaction.C | 3 +- .../Reactions/solidReaction/solidReactionI.H | 2 +- .../solidArrheniusReactionRateI.H | 6 +-- .../NonEquilibriumReversibleReaction.C | 14 ++--- .../reaction/Reactions/Reaction/Reaction.C | 3 +- .../Reactions/ReactionList/ReactionList.C | 15 +++--- .../ArrheniusReactionRateI.H | 6 +-- .../FallOffReactionRateI.H | 34 ++++--------- .../LandauTellerReactionRateI.H | 10 ++-- .../SRIFallOffFunction/SRIFallOffFunctionI.H | 10 ++-- .../TroeFallOffFunctionI.H | 8 +-- .../powerSeries/powerSeriesReactionRateI.H | 8 +-- .../thirdBodyEfficienciesI.H | 2 +- .../specie/transport/const/constTransport.C | 16 +++--- .../logPolynomial/logPolynomialTransport.C | 32 ++++++------ .../polynomial/polynomialTransport.C | 32 ++++++------ .../sutherland/sutherlandTransport.C | 16 +++--- ...emperatureCoupledMixedFvPatchScalarField.C | 16 +++--- .../constant/constantSurfaceTension.C | 6 +-- .../temperatureDependentSurfaceTension.C | 6 +-- ...stantAlphaContactAngleFvPatchScalarField.C | 2 +- ...namicAlphaContactAngleFvPatchScalarField.C | 8 +-- ...ndentAlphaContactAngleFvPatchScalarField.C | 2 +- ...ryingAlphaContactAngleFvPatchScalarField.C | 8 +-- .../waveAlpha/waveAlphaFvPatchScalarField.C | 3 +- .../waveVelocityFvPatchVectorField.C | 3 +- 232 files changed, 856 insertions(+), 1293 deletions(-) diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C index d9a4a4e7df1..0590e8d0980 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C @@ -209,16 +209,14 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_); - writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_); + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_); + os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_); - os.writeKeyword("accommodationCoeff") - << accommodationCoeff_ << token::END_STATEMENT << nl; + os.writeEntry("accommodationCoeff", accommodationCoeff_); Twall_.writeEntry("Twall", os); - os.writeKeyword("gamma") - << gamma_ << token::END_STATEMENT << nl; + os.writeEntry("gamma", gamma_); writeEntry("value", os); } diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C index 7f19817660b..c79f8d5062d 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C @@ -200,18 +200,16 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs() void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "T", "T", TName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_); - writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_); - writeEntryIfDifferent<word>(os, "tauMC", "tauMC", tauMCName_); - - os.writeKeyword("accommodationCoeff") - << accommodationCoeff_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("T", "T", TName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_); + os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_); + os.writeEntryIfDifferent<word>("tauMC", "tauMC", tauMCName_); + + os.writeEntry("accommodationCoeff", accommodationCoeff_); Uwall_.writeEntry("Uwall", os); - os.writeKeyword("thermalCreep") - << thermalCreep_ << token::END_STATEMENT << nl; - os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl; + os.writeEntry("thermalCreep", thermalCreep_); + os.writeEntry("curvature", curvature_); refValue().writeEntry("refValue", os); valueFraction().writeEntry("valueFraction", os); diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C index 5eefe82ff5d..d71824052f5 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C @@ -117,8 +117,8 @@ void Foam::fixedRhoFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "p", "p", this->pName_); - writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_); + os.writeEntryIfDifferent<word>("p", "p", pName_); + os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C index 6872ae0321e..9baa712b958 100644 --- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C +++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C @@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField void alphaContactAngleFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("thetaProperties") - << thetaProps_ << token::END_STATEMENT << nl; + os.writeEntry("thetaProperties", thetaProps_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C index a0d433f4e8b..d9c325a3ba3 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C @@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField void alphaContactAngleFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("thetaProperties") - << thetaProps_ << token::END_STATEMENT << nl; + os.writeEntry("thetaProperties", thetaProps_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C index a0d433f4e8b..d9c325a3ba3 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C @@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField void alphaContactAngleFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("thetaProperties") - << thetaProps_ << token::END_STATEMENT << nl; + os.writeEntry("thetaProperties", thetaProps_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C index b26ec2faa08..284992c64c9 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C @@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField void alphaContactAngleFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("thetaProperties") - << thetaProps_ << token::END_STATEMENT << nl; + os.writeEntry("thetaProperties", thetaProps_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C index 2a4732fd971..464bbd01e42 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C @@ -138,9 +138,9 @@ void alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::write ) const { fvPatchField<scalar>::write(os); - os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl; - os.writeKeyword("fixedDmdt") << fixedDmdt_ << token::END_STATEMENT << nl; - os.writeKeyword("L") << L_ << token::END_STATEMENT << nl; + os.writeEntry("relax", relax_); + os.writeEntry("fixedDmdt", fixedDmdt_); + os.writeEntry("L", L_); dmdt_.writeEntry("dmdt", os); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C index 7b854df507f..f6c4ca196e7 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C @@ -334,10 +334,10 @@ void alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::write ) const { fvPatchField<scalar>::write(os); - os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl; - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeEntry("Prt", Prt_); + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); dmdt_.writeEntry("dmdt", os); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C index a1ac6c46f65..e10422c800f 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C @@ -596,42 +596,36 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("phaseType") << phaseTypeNames_[phaseType_] - << token::END_STATEMENT << nl; + os.writeEntry("phaseType", phaseTypeNames_[phaseType_]); - os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl; + os.writeEntry("relax", relax_); switch (phaseType_) { case vaporPhase: { - os.writeKeyword("partitioningModel") << nl; - os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("partitioningModel"); partitioningModel_->write(os); - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); break; } case liquidPhase: { - os.writeKeyword("partitioningModel") << nl; - os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("partitioningModel"); partitioningModel_->write(os); - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); - os.writeKeyword("nucleationSiteModel") << nl; - os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("nucleationSiteModel"); nucleationSiteModel_->write(os); - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); - os.writeKeyword("departureDiamModel") << nl; - os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("departureDiamModel"); departureDiamModel_->write(os); - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); - os.writeKeyword("departureFreqModel") << nl; - os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("departureFreqModel"); departureFreqModel_->write(os); - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); break; } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C index 63c85938cfd..f9142de5cf0 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C @@ -109,8 +109,7 @@ void Foam::copiedFixedValueFvPatchScalarField::updateCoeffs() void Foam::copiedFixedValueFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("sourceField") - << sourceFieldName_ << token::END_STATEMENT << nl; + os.writeEntry("sourceField", sourceFieldName_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C index c991a1a3336..c84f323e741 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C @@ -183,7 +183,7 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs() void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl; + os.writeEntry("relax", relax_); q_.writeEntry("q", os); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C index 53fe0e2f15b..c18a01cf0b0 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C @@ -114,7 +114,7 @@ void Foam::wallBoilingModels::departureDiameterModels:: KocamustafaogullariIshii::write(Ostream& os) const { departureDiameterModel::write(os); - os.writeKeyword("phi") << phi_ << token::END_STATEMENT << nl; + os.writeEntry("phi", phi_); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C index 71ef4f03c73..e2ec8ef829e 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C @@ -90,9 +90,9 @@ void Foam::wallBoilingModels::departureDiameterModels:: TolubinskiKostanchuk::write(Ostream& os) const { departureDiameterModel::write(os); - os.writeKeyword("dRef") << dRef_ << token::END_STATEMENT << nl; - os.writeKeyword("dMax") << dMax_ << token::END_STATEMENT << nl; - os.writeKeyword("dMin") << dMin_ << token::END_STATEMENT << nl; + os.writeEntry("dRef", dRef_); + os.writeEntry("dMax", dMax_); + os.writeEntry("dMin", dMin_); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C index 4c3564a006b..1c8c3dba407 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C @@ -53,7 +53,7 @@ Foam::wallBoilingModels::departureDiameterModel::~departureDiameterModel() void Foam::wallBoilingModels::departureDiameterModel::write(Ostream& os) const { - os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl; + os.writeEntry("type", this->type()); } // ************************************************************************* // diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C index e87e520096b..e76f789cc60 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C @@ -53,7 +53,7 @@ Foam::wallBoilingModels::departureFrequencyModel::~departureFrequencyModel() void Foam::wallBoilingModels::departureFrequencyModel::write(Ostream& os) const { - os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl; + os.writeEntry("type", this->type()); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C index fbf495a5e2f..16c2112664c 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C @@ -53,7 +53,7 @@ Foam::wallBoilingModels::nucleationSiteModel::~nucleationSiteModel() void Foam::wallBoilingModels::nucleationSiteModel::write(Ostream& os) const { - os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl; + os.writeEntry("type", this->type()); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C index 04b8c2917e2..581a83a6d1b 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C @@ -88,7 +88,7 @@ void Foam::wallBoilingModels::partitioningModels:: Lavieville::write(Ostream& os) const { partitioningModel::write(os); - os.writeKeyword("alphaCrit") << alphaCrit_ << token::END_STATEMENT << nl; + os.writeEntry("alphaCrit", alphaCrit_); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C index 1d157b67ab1..f9528677d4f 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C @@ -97,10 +97,8 @@ void Foam::wallBoilingModels::partitioningModels:: cosine::write(Ostream& os) const { partitioningModel::write(os); - os.writeKeyword("alphaLiquid1") << alphaLiquid1_ - << token::END_STATEMENT << nl; - os.writeKeyword("alphaLiquid0") << alphaLiquid0_ - << token::END_STATEMENT << nl; + os.writeEntry("alphaLiquid1", alphaLiquid1_); + os.writeEntry("alphaLiquid0", alphaLiquid0_); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C index dd1142b1372..cc6d648f849 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C @@ -90,10 +90,8 @@ void Foam::wallBoilingModels::partitioningModels:: linear::write(Ostream& os) const { partitioningModel::write(os); - os.writeKeyword("alphaLiquid1") << alphaLiquid1_ - << token::END_STATEMENT << nl; - os.writeKeyword("alphaLiquid0") << alphaLiquid0_ - << token::END_STATEMENT << nl; + os.writeEntry("alphaLiquid1", alphaLiquid1_); + os.writeEntry("alphaLiquid0", alphaLiquid0_); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C index 7b68289d948..cb12aca1908 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C @@ -53,7 +53,7 @@ Foam::wallBoilingModels::partitioningModel::~partitioningModel() void Foam::wallBoilingModels::partitioningModel::write(Ostream& os) const { - os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl; + os.writeEntry("type", this->type()); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C index 651de2ea03f..a64155e4a0c 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C @@ -245,8 +245,7 @@ void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - os.writeKeyword("specularityCoefficient") - << specularityCoefficient_ << token::END_STATEMENT << nl; + os.writeEntry("specularityCoefficient", specularityCoefficient_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C index 0fa9d5faf62..53431117d55 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C @@ -289,10 +289,8 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("restitutionCoefficient") - << restitutionCoefficient_ << token::END_STATEMENT << nl; - os.writeKeyword("specularityCoefficient") - << specularityCoefficient_ << token::END_STATEMENT << nl; + os.writeEntry("restitutionCoefficient", restitutionCoefficient_); + os.writeEntry("specularityCoefficient", specularityCoefficient_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C index 651de2ea03f..a64155e4a0c 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C @@ -245,8 +245,7 @@ void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - os.writeKeyword("specularityCoefficient") - << specularityCoefficient_ << token::END_STATEMENT << nl; + os.writeEntry("specularityCoefficient", specularityCoefficient_); writeEntry("value", os); } diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C index 0fa9d5faf62..53431117d55 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C @@ -289,10 +289,8 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("restitutionCoefficient") - << restitutionCoefficient_ << token::END_STATEMENT << nl; - os.writeKeyword("specularityCoefficient") - << specularityCoefficient_ << token::END_STATEMENT << nl; + os.writeEntry("restitutionCoefficient", restitutionCoefficient_); + os.writeEntry("specularityCoefficient", specularityCoefficient_); writeEntry("value", os); } diff --git a/etc/codeTemplates/BC/BC.C b/etc/codeTemplates/BC/BC.C index 5e32969aa4c..b0091f6900e 100644 --- a/etc/codeTemplates/BC/BC.C +++ b/etc/codeTemplates/BC/BC.C @@ -220,11 +220,11 @@ void Foam::CLASS::write ) const { FVPATCHF::write(os); - os.writeKeyword("scalarData") << scalarData_ << token::END_STATEMENT << nl; - os.writeKeyword("data") << data_ << token::END_STATEMENT << nl; + os.writeEntry("scalarData", scalarData_); + os.writeEntry("data", data_); fieldData_.writeEntry("fieldData", os); timeVsData_->writeData(os); - os.writeKeyword("wordData") << wordData_ << token::END_STATEMENT << nl; + os.writeEntry("wordData", wordData_); this->writeEntry("value", os); } diff --git a/src/OSspecific/POSIX/cpuInfo/cpuInfo.C b/src/OSspecific/POSIX/cpuInfo/cpuInfo.C index 6dbd6abf4b2..e394ec7b222 100644 --- a/src/OSspecific/POSIX/cpuInfo/cpuInfo.C +++ b/src/OSspecific/POSIX/cpuInfo/cpuInfo.C @@ -174,26 +174,12 @@ void Foam::cpuInfo::write(Ostream& os) const { os.writeEntry("model_name", model_name); } - if (cpu_family != -1) - { - os.writeEntry("cpu_family", cpu_family); - } - if (model != -1) - { - os.writeEntry("model", model); - } - if (cpu_MHz > 0) - { - os.writeEntry("cpu_MHz", cpu_MHz); - } - if (cpu_cores > 0) - { - os.writeEntry("cpu_cores", cpu_cores); - } - if (siblings > 0) - { - os.writeEntry("siblings", siblings); - } + + os.writeEntryIfDifferent<int>("cpu_family", -1, cpu_family); + os.writeEntryIfDifferent<int>("model", -1, model); + os.writeEntryIfDifferent<float>("cpu_MHz", 0, cpu_MHz); + os.writeEntryIfDifferent<int>("cpu_cores", 0, cpu_cores); + os.writeEntryIfDifferent<int>("siblings", 0, siblings); } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index bf0150cb244..1c6d2131bc9 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -211,6 +211,26 @@ public: return endEntry(); } + //- Write a keyword/value entry only when the two values differ. + // \param key the name of the entry + // \param value1 the reference value + // \param value2 the value to write if it differs from value1 + template<class T> + Ostream& writeEntryIfDifferent + ( + const word& key, + const T& value1, + const T& value2 + ) + { + if (value1 != value2) + { + writeEntry(key, value2); + } + + return *this; + } + // Stream state functions diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index f6ca2a766c6..eaaf4830644 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -744,16 +744,15 @@ void Foam::Field<Type>::writeEntry(const word& keyword, Ostream& os) const if (uniform) { - os << "uniform " << this->operator[](0) << token::END_STATEMENT; + os << "uniform " << this->operator[](0); } else { os << "nonuniform "; List<Type>::writeEntry(os); - os << token::END_STATEMENT; } - os << endl; + os << token::END_STATEMENT << nl; } diff --git a/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C b/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C index 94bf0ca6c88..9e722c6569a 100644 --- a/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C +++ b/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C @@ -97,10 +97,8 @@ bool Foam::UniformDimensionedField<Type>::writeData(Ostream& os) const { scalar multiplier; os.writeKeyword("dimensions"); - this->dimensions().write(os, multiplier) << token::END_STATEMENT - << nl; - os.writeKeyword("value") << this->value()/multiplier << token::END_STATEMENT - << nl << nl; + this->dimensions().write(os, multiplier) << token::END_STATEMENT << nl; + os.writeEntry("value", this->value()/multiplier) << nl; return os.good(); } diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C index 6f32877f626..16969e8dc9b 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C @@ -270,8 +270,7 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const // Make sure to construct the patchfield with up-to-date value OStringStream os; - os.writeKeyword("type") << name_ << token::END_STATEMENT - << nl; + os.writeEntry("type", name_); static_cast<const Field<Type>&>(*this).writeEntry("value", os); IStringStream is(os.str()); dictionary dict(is); @@ -333,8 +332,7 @@ template<class Type> void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const { fixedValuePointPatchField<Type>::write(os); - os.writeKeyword("name") << name_ - << token::END_STATEMENT << nl; + os.writeEntry("name", name_); codedBase::writeCodeDict(os, dict_); } diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C index cd99728ca50..c5941fade46 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C @@ -100,8 +100,7 @@ template<class Type> void Foam::fixedNormalSlipPointPatchField<Type>::write(Ostream& os) const { slipPointPatchField<Type>::write(os); - os.writeKeyword("n") - << n_ << token::END_STATEMENT << nl; + os.writeEntry("n", n_); } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C index 2c98caa0e5c..b2016d79a3a 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C @@ -113,29 +113,11 @@ const Foam::objectRegistry& Foam::pointPatchField<Type>::db() const template<class Type> void Foam::pointPatchField<Type>::write(Ostream& os) const { - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); if (patchType_.size()) { - os.writeKeyword("patchType") << patchType_ - << token::END_STATEMENT << nl; - } -} - - -template<class Type> -template<class EntryType> -void Foam::pointPatchField<Type>::writeEntryIfDifferent -( - Ostream& os, - const word& entryName, - const EntryType& value1, - const EntryType& value2 -) const -{ - if (value1 != value2) - { - os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl; + os.writeEntry("patchType", patchType_); } } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index b4ac7f2dc8d..40129b82ec7 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -436,17 +436,6 @@ public: //- Write virtual void write(Ostream&) const; - //- Helper function to write the keyword and entry only if the - // values are not equal. The value is then output as value2 - template<class EntryType> - void writeEntryIfDifferent - ( - Ostream& os, - const word& entryName, - const EntryType& value1, - const EntryType& value2 - ) const; - // Member operators diff --git a/src/OpenFOAM/global/profiling/profilingInformation.C b/src/OpenFOAM/global/profiling/profilingInformation.C index bc73478e518..24957284e1d 100644 --- a/src/OpenFOAM/global/profiling/profilingInformation.C +++ b/src/OpenFOAM/global/profiling/profilingInformation.C @@ -128,18 +128,12 @@ Foam::Ostream& Foam::profilingInformation::write os.beginBlock(word("trigger" + Foam::name(id_))); os.writeEntry("id", id_); - if (id_ != parent().id()) - { - os.writeEntry("parentId", parent().id()); - } + os.writeEntryIfDifferent("parentId", id_, parent().id()); os.writeEntry("description", description()); os.writeEntry("calls", calls() + (offset ? 1 : 0)); os.writeEntry("totalTime", totalTime() + elapsedTime); os.writeEntry("childTime", childTime() + childTimes); - if (maxMem_) - { - os.writeEntry("maxMem", maxMem_); - } + os.writeEntryIfDifferent<int>("maxMem", 0, maxMem_); os.writeEntry("onStack", Switch(onStack())); os.endBlock(); diff --git a/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C b/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C index 32e76884b61..f317ae5f708 100644 --- a/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C +++ b/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C @@ -354,19 +354,15 @@ void Foam::interpolationLookUpTable<Type>::write control.writeHeader(os); - os.writeKeyword("fields") - << entries_ << token::END_STATEMENT << nl; - - os.writeKeyword("output") - << output_ << token::END_STATEMENT << nl; + os.writeEntry("fields", entries_); + os.writeEntry("output", output_); if (this->size() == 0) { FatalErrorInFunction << "table is empty" << nl << exit(FatalError); } - os.writeKeyword("values") - << *this << token::END_STATEMENT << nl; + os.writeEntry("values", *this); } diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C index 51adcb3381c..bf972fda0a1 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C @@ -173,10 +173,8 @@ void Foam::csvTableReader<Type>::write(Ostream& os) const { tableReader<Type>::write(os); - os.writeKeyword("hasHeaderLine") - << headerLine_ << token::END_STATEMENT << nl; - os.writeKeyword("timeColumn") - << timeColumn_ << token::END_STATEMENT << nl; + os.writeEntry("hasHeaderLine", headerLine_); + os.writeEntry("timeColumn", timeColumn_); // Force writing labelList in ascii os.writeKeyword("valueColumns"); @@ -186,10 +184,13 @@ void Foam::csvTableReader<Type>::write(Ostream& os) const os << componentColumns_; os.format(IOstream::BINARY); } + else + { + os << componentColumns_; + } os << token::END_STATEMENT << nl; - os.writeKeyword("separator") - << string(separator_) << token::END_STATEMENT << nl; + os.writeEntry("separator", string(separator_)); } diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C index b3d96d50b0b..b32b3bfdc16 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C @@ -74,10 +74,7 @@ Foam::tableReader<Type>::~tableReader() template<class Type> void Foam::tableReader<Type>::write(Ostream& os) const { - if (this->type() != "openFoam") - { - os.writeEntry("readerType", this->type()); - } + os.writeEntryIfDifferent<word>("readerType", "openFoam", this->type()); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C index 22a1e1b0f78..6421a4ee53e 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C @@ -126,10 +126,10 @@ const Foam::word& Foam::genericPolyPatch::actualType() const void Foam::genericPolyPatch::write(Ostream& os) const { - os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl; + os.writeEntry("type", actualTypeName_); patchIdentifier::write(os); - os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl; - os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl; + os.writeEntry("nFaces", size()); + os.writeEntry("startFace", start()); forAllConstIter(dictionary, dict_, iter) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index d83efd4fed7..6544881f4a2 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -1447,24 +1447,20 @@ void Foam::cyclicPolyPatch::write(Ostream& os) const coupledPolyPatch::write(os); if (!neighbPatchName_.empty()) { - os.writeKeyword("neighbourPatch") << neighbPatchName_ - << token::END_STATEMENT << nl; + os.writeEntry("neighbourPatch", neighbPatchName_); } coupleGroup_.write(os); switch (transform()) { case ROTATIONAL: { - os.writeKeyword("rotationAxis") << rotationAxis_ - << token::END_STATEMENT << nl; - os.writeKeyword("rotationCentre") << rotationCentre_ - << token::END_STATEMENT << nl; + os.writeEntry("rotationAxis", rotationAxis_); + os.writeEntry("rotationCentre", rotationCentre_); break; } case TRANSLATIONAL: { - os.writeKeyword("separationVector") << separationVector_ - << token::END_STATEMENT << nl; + os.writeEntry("separationVector", separationVector_); break; } case NOORDERING: diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C index 7fdf0634754..5001f6e238f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C @@ -1221,28 +1221,24 @@ bool Foam::oldCyclicPolyPatch::order void Foam::oldCyclicPolyPatch::write(Ostream& os) const { // Replacement of polyPatch::write to write 'cyclic' instead of type(): - os.writeKeyword("type") << cyclicPolyPatch::typeName - << token::END_STATEMENT << nl; + os.writeEntry("type", cyclicPolyPatch::typeName); patchIdentifier::write(os); - os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl; - os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl; + os.writeEntry("nFaces", size()); + os.writeEntry("startFace", start()); - os.writeKeyword("featureCos") << featureCos_ << token::END_STATEMENT << nl; + os.writeEntry("featureCos", featureCos_); switch (transform()) { case ROTATIONAL: { - os.writeKeyword("rotationAxis") << rotationAxis_ - << token::END_STATEMENT << nl; - os.writeKeyword("rotationCentre") << rotationCentre_ - << token::END_STATEMENT << nl; + os.writeEntry("rotationAxis", rotationAxis_); + os.writeEntry("rotationCentre", rotationCentre_); break; } case TRANSLATIONAL: { - os.writeKeyword("separationVector") << separationVector_ - << token::END_STATEMENT << nl; + os.writeEntry("separationVector", separationVector_); break; } default: diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 0ad36956cbd..9c27fada851 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -1112,10 +1112,8 @@ bool Foam::processorPolyPatch::order void Foam::processorPolyPatch::write(Ostream& os) const { coupledPolyPatch::write(os); - os.writeKeyword("myProcNo") << myProcNo_ - << token::END_STATEMENT << nl; - os.writeKeyword("neighbProcNo") << neighbProcNo_ - << token::END_STATEMENT << nl; + os.writeEntry("myProcNo", myProcNo_); + os.writeEntry("neighbProcNo", neighbProcNo_); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C index 02dcc6294ad..9163b5c19c3 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C @@ -337,13 +337,8 @@ bool Foam::processorCyclicPolyPatch::order void Foam::processorCyclicPolyPatch::write(Ostream& os) const { processorPolyPatch::write(os); - os.writeKeyword("referPatch") << referPatchName_ - << token::END_STATEMENT << nl; - if (tag_ != -1) - { - os.writeKeyword("tag") << tag_ - << token::END_STATEMENT << nl; - } + os.writeEntry("referPatch", referPatchName_); + os.writeEntryIfDifferent<label>("tag", -1, tag_); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index 1494fb273d5..d48d7e30caa 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -374,10 +374,10 @@ void Foam::polyPatch::clearAddressing() void Foam::polyPatch::write(Ostream& os) const { - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); patchIdentifier::write(os); - os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl; - os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl; + os.writeEntry("nFaces", size()); + os.writeEntry("startFace", start()); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C index db5779edda3..c952a6f6c84 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C @@ -71,11 +71,13 @@ void Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os << token::END_STATEMENT << nl; - os << indent << word(this->name() + "Coeffs") << nl; - os << indent << token::BEGIN_BLOCK << incrIndent << nl; + + os.beginBlock(word(this->name() + "Coeffs")); + scale_->writeData(os); value_->writeData(os); - os << decrIndent << indent << token::END_BLOCK << endl; + + os.endBlock(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C index 0efcbcf1463..5a6e5104114 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C +++ b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C @@ -345,18 +345,19 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const template<class Type> void Foam::Function1Types::TableBase<Type>::writeEntries(Ostream& os) const { - if (bounding_ != bounds::repeatableBounding::CLAMP) - { - os.writeEntry - ( - "outOfBounds", - bounds::repeatableBoundingNames[bounding_] - ); - } - if (interpolationScheme_ != "linear") - { - os.writeEntry("interpolationScheme", interpolationScheme_); - } + os.writeEntryIfDifferent<word> + ( + "outOfBounds", + bounds::repeatableBoundingNames[bounds::repeatableBounding::CLAMP], + bounds::repeatableBoundingNames[bounding_] + ); + + os.writeEntryIfDifferent<word> + ( + "interpolationScheme", + "linear", + interpolationScheme_ + ); } diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C index 40645aa1910..773a072f2ef 100644 --- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C @@ -58,11 +58,13 @@ void Foam::Function1Types::ramp::writeData(Ostream& os) const { Function1<scalar>::writeData(os); os << token::END_STATEMENT << nl; - os << indent << word(this->name() + "Coeffs") << nl; - os << indent << token::BEGIN_BLOCK << incrIndent << nl; - os.writeKeyword("start") << start_ << token::END_STATEMENT << nl; - os.writeKeyword("duration") << duration_ << token::END_STATEMENT << nl; - os << decrIndent << indent << token::END_BLOCK << endl; + + os.beginBlock(word(this->name() + "Coeffs")); + + os.writeEntry("start", start_); + os.writeEntry("duration", duration_); + + os.endBlock(); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C index 3819066c887..6ba0630240d 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C @@ -161,7 +161,7 @@ void convectiveHeatTransferFvPatchScalarField::updateCoeffs() void convectiveHeatTransferFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("L") << L_ << token::END_STATEMENT << nl; + os.writeEntry("L", L_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C index 52de5b816bb..fefc7a9409c 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C @@ -190,9 +190,8 @@ void Foam::lumpedMassWallTemperatureFvPatchScalarField::write mixedFvPatchScalarField::write(os); temperatureCoupledBase::write(os); - os.writeKeyword("Cp")<< Cp_ << token::END_STATEMENT << nl; - os.writeKeyword("mass")<< mass_ - << token::END_STATEMENT << nl; + os.writeEntry("Cp", Cp_); + os.writeEntry("mass", mass_); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C index d495bdbb8cf..3cf2ce56d61 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C @@ -189,12 +189,11 @@ void Foam::outletMappedUniformInletHeatAdditionFvPatchField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("outletPatch") - << outletPatchName_ << token::END_STATEMENT << nl; - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - os.writeKeyword("Q") << Q_ << token::END_STATEMENT << nl; - os.writeKeyword("TMin") << TMin_ << token::END_STATEMENT << nl; - os.writeKeyword("TMax") << TMax_ << token::END_STATEMENT << nl; + os.writeEntry("outletPatch", outletPatchName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntry("Q", Q_); + os.writeEntry("TMin", TMin_); + os.writeEntry("TMax", TMax_); this->writeEntry("value", os); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index 4221ad93de1..00883665e82 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -436,9 +436,8 @@ void thermalBaffle1DFvPatchScalarField<solidType>::write(Ostream& os) const } qrPrevious_.writeEntry("qrPrevious", os); - os.writeKeyword("qr")<< qrName_ << token::END_STATEMENT << nl; - os.writeKeyword("relaxation")<< qrRelaxation_ - << token::END_STATEMENT << nl; + os.writeEntry("qr", qrName_); + os.writeEntry("relaxation", qrRelaxation_); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C index f870ed2abaf..eba0fea41f7 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C @@ -202,10 +202,9 @@ void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; - os.writeKeyword("massFluxFraction") << massFluxFraction_ - << token::END_STATEMENT << nl; + os.writeEntry("phi", phiName_); + os.writeEntry("rho", rhoName_); + os.writeEntry("massFluxFraction", massFluxFraction_); this->writeEntry("value", os); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index 1548c37e626..ff02c97357b 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -260,8 +260,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); - os.writeKeyword("Tnbr")<< TnbrName_ - << token::END_STATEMENT << nl; + os.writeEntry("Tnbr", TnbrName_); thicknessLayers_.writeEntry("thicknessLayers", os); kappaLayers_.writeEntry("kappaLayers", os); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index e232b8198f4..edcdabfa3b0 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -343,12 +343,11 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); - os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl; + os.writeEntry("Tnbr", TnbrName_); - os.writeKeyword("qrNbr")<< qrNbrName_ << token::END_STATEMENT << nl; - os.writeKeyword("qr")<< qrName_ << token::END_STATEMENT << nl; - os.writeKeyword("thermalInertia")<< thermalInertia_ - << token::END_STATEMENT << nl; + os.writeEntry("qrNbr", qrNbrName_); + os.writeEntry("qr", qrName_); + os.writeEntry("thermalInertia", thermalInertia_); thicknessLayers_.writeEntry("thicknessLayers", os); kappaLayers_.writeEntry("kappaLayers", os); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C index 3840262bd21..4aee2a4da74 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C @@ -300,10 +300,10 @@ void alphatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs() void alphatJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl; - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeEntry("Prt", Prt_); + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C index 127f58e9fa4..e8c910680d7 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C @@ -129,7 +129,7 @@ void alphatWallFunctionFvPatchScalarField::updateCoeffs() void alphatWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl; + os.writeEntry("Prt", Prt_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C index 8677d5f8642..c1cb91df3fe 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C @@ -268,10 +268,10 @@ void alphatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs() void alphatJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl; - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeEntry("Prt", Prt_); + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C index 1f95e729cd8..aabf2bab690 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C @@ -154,18 +154,12 @@ tmp<scalarField> atmBoundaryLayer::epsilon(const vectorField& p) const void atmBoundaryLayer::write(Ostream& os) const { z0_.writeEntry("z0", os) ; - os.writeKeyword("flowDir") - << flowDir_ << token::END_STATEMENT << nl; - os.writeKeyword("zDir") - << zDir_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") - << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("Cmu") - << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("Uref") - << Uref_ << token::END_STATEMENT << nl; - os.writeKeyword("Zref") - << Zref_ << token::END_STATEMENT << nl; + os.writeEntry("flowDir", flowDir_); + os.writeEntry("zDir", zDir_); + os.writeEntry("kappa", kappa_); + os.writeEntry("Cmu", Cmu_); + os.writeEntry("Uref", Uref_); + os.writeEntry("Zref", Zref_); zGround_.writeEntry("zGround", os) ; } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C index cd362bfd3b5..5da68948f99 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C @@ -159,10 +159,9 @@ void turbulentMixingLengthDissipationRateInletFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("mixingLength") - << mixingLength_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; + os.writeEntry("mixingLength", mixingLength_); + os.writeEntry("phi", this->phiName_); + os.writeEntry("k", kName_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C index 548c7db7388..7107217c858 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C @@ -155,10 +155,9 @@ void turbulentMixingLengthFrequencyInletFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("mixingLength") - << mixingLength_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; + os.writeEntry("mixingLength", mixingLength_); + os.writeEntry("phi", this->phiName_); + os.writeEntry("k", kName_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C index 0a4ae1c7fee..1f2caddd510 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C @@ -126,7 +126,7 @@ void Foam::fixedShearStressFvPatchVectorField::updateCoeffs() void Foam::fixedShearStressFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("tau") << tau0_ << token::END_STATEMENT << nl; + os.writeEntry("tau", tau0_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C index df4557580f5..486581871a9 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C @@ -190,13 +190,12 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs() void Foam::porousBafflePressureFvPatchField::write(Ostream& os) const { fixedJumpFvPatchField<scalar>::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); D_->writeData(os); I_->writeData(os); - os.writeKeyword("length") << length_ << token::END_STATEMENT << nl; - os.writeKeyword("uniformJump") << uniformJump_ - << token::END_STATEMENT << nl; + os.writeEntry("length", length_); + os.writeEntry("uniformJump", uniformJump_); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 1d8e807045c..c3cf3c22a99 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -57,9 +57,9 @@ void Foam::epsilonWallFunctionFvPatchScalarField::writeLocalEntries Ostream& os ) const { - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C index 862f7e647b6..967b4f4ef94 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C @@ -55,9 +55,9 @@ void fWallFunctionFvPatchScalarField::checkType() void fWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const { - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C index 11873820e05..36d171f8619 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C @@ -233,10 +233,10 @@ void kLowReWallFunctionFvPatchScalarField::evaluate void kLowReWallFunctionFvPatchScalarField::write(Ostream& os) const { - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; - os.writeKeyword("Ceps2") << Ceps2_ << token::END_STATEMENT << nl; + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); + os.writeEntry("Ceps2", Ceps2_); fixedValueFvPatchField<scalar>::write(os); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C index 02844be1a81..cef7574691d 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C @@ -294,12 +294,9 @@ void nutURoughWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); - os.writeKeyword("roughnessHeight") - << roughnessHeight_ << token::END_STATEMENT << nl; - os.writeKeyword("roughnessConstant") - << roughnessConstant_ << token::END_STATEMENT << nl; - os.writeKeyword("roughnessFactor") - << roughnessFactor_ << token::END_STATEMENT << nl; + os.writeEntry("roughnessHeight", roughnessHeight_); + os.writeEntry("roughnessConstant", roughnessConstant_); + os.writeEntry("roughnessFactor", roughnessFactor_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C index ee322ce34be..b40581055c0 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C @@ -204,8 +204,7 @@ tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::yPlus() const void nutUTabulatedWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("uPlusTable") << uPlusTableName_ - << token::END_STATEMENT << nl; + os.writeEntry("uPlusTable", uPlusTableName_); writeEntry("value", os); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 04c5d767465..e2a8006ccf6 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -57,9 +57,9 @@ void Foam::nutWallFunctionFvPatchScalarField::writeLocalEntries Ostream& os ) const { - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 59145dc9881..2bcc382090f 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -59,11 +59,11 @@ void omegaWallFunctionFvPatchScalarField::checkType() void omegaWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const { - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; - os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl; - os.writeKeyword("blended") << blended_ << token::END_STATEMENT << nl; + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); + os.writeEntry("beta1", beta1_); + os.writeEntry("blended", blended_); } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C index e3704f287c5..0546d6a6105 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C @@ -55,9 +55,9 @@ void v2WallFunctionFvPatchScalarField::checkType() void v2WallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const { - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("E", E_); } diff --git a/src/dynamicMesh/attachDetach/attachDetach.C b/src/dynamicMesh/attachDetach/attachDetach.C index 8ce76a11c35..aa8f22f8437 100644 --- a/src/dynamicMesh/attachDetach/attachDetach.C +++ b/src/dynamicMesh/attachDetach/attachDetach.C @@ -463,22 +463,18 @@ void Foam::attachDetach::write(Ostream& os) const void Foam::attachDetach::writeDict(Ostream& os) const { - os << nl << name() << nl << token::BEGIN_BLOCK << nl - << " type " << type() - << token::END_STATEMENT << nl - << " faceZoneName " << faceZoneID_.name() - << token::END_STATEMENT << nl - << " masterPatchName " << masterPatchID_.name() - << token::END_STATEMENT << nl - << " slavePatchName " << slavePatchID_.name() - << token::END_STATEMENT << nl - << " triggerTimes " << triggerTimes_ - << token::END_STATEMENT << nl - << " manualTrigger " << manualTrigger() - << token::END_STATEMENT << nl - << " active " << active() - << token::END_STATEMENT << nl - << token::END_BLOCK << endl; + os << nl; + os.beginBlock(name()); + + os.writeEntry("type", type()); + os.writeEntry("faceZoneName", faceZoneID_.name()); + os.writeEntry("masterPatchName", masterPatchID_.name()); + os.writeEntry("slavePatchName", slavePatchID_.name()); + os.writeEntry("triggerTimes", triggerTimes_); + os.writeEntry("manualTrigger", manualTrigger()); + os.writeEntry("active", active()); + + os.endBlock(); } diff --git a/src/dynamicMesh/boundaryPatch/boundaryPatch.C b/src/dynamicMesh/boundaryPatch/boundaryPatch.C index fe2f9796e4c..38c1d6b91ee 100644 --- a/src/dynamicMesh/boundaryPatch/boundaryPatch.C +++ b/src/dynamicMesh/boundaryPatch/boundaryPatch.C @@ -90,8 +90,8 @@ Foam::boundaryPatch::~boundaryPatch() void Foam::boundaryPatch::write(Ostream& os) const { patchIdentifier::write(os); - os.writeKeyword("nFaces") << size_ << token::END_STATEMENT << nl; - os.writeKeyword("startFace") << start_ << token::END_STATEMENT << nl; + os.writeEntry("nFaces", size_); + os.writeEntry("startFace", start_); } diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C b/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C index 7f3b08d1e96..86043002269 100644 --- a/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C +++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C @@ -174,8 +174,8 @@ write(Ostream& os) const // Note: write value fixedValuePointPatchVectorField::write(os); - os.writeKeyword(solidBodyMotionFunction::typeName) << SBMFPtr_->type() - << token::END_STATEMENT << nl; + os.writeEntry(solidBodyMotionFunction::typeName, SBMFPtr_->type()); + os << indent << word(SBMFPtr_->type() + "Coeffs"); SBMFPtr_->writeData(os); } diff --git a/src/dynamicMesh/perfectInterface/perfectInterface.C b/src/dynamicMesh/perfectInterface/perfectInterface.C index 5aa0b5ed993..1b2475dc479 100644 --- a/src/dynamicMesh/perfectInterface/perfectInterface.C +++ b/src/dynamicMesh/perfectInterface/perfectInterface.C @@ -506,34 +506,16 @@ void Foam::perfectInterface::write(Ostream& os) const void Foam::perfectInterface::writeDict(Ostream& os) const { - os << nl << name() << nl << token::BEGIN_BLOCK << nl - - << " type " << type() - << token::END_STATEMENT << nl - - << " active " << active() - << token::END_STATEMENT << nl - - << " faceZoneName " << faceZoneID_.name() - << token::END_STATEMENT << nl - - << " masterPatchName " << masterPatchID_.name() - << token::END_STATEMENT << nl - - << " slavePatchName " << slavePatchID_.name() - << token::END_STATEMENT << nl - - << token::END_BLOCK << endl; + os << nl; + + os.beginBlock(name()); + os.writeEntry("type", type()); + os.writeEntry("active", active()); + os.writeEntry("faceZoneName", faceZoneID_.name()); + os.writeEntry("masterPatchName", masterPatchID_.name()); + os.writeEntry("slavePatchName", slavePatchID_.name()); + os.endBlock(); } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/dynamicMesh/setUpdater/setUpdater.C b/src/dynamicMesh/setUpdater/setUpdater.C index c121af2a846..f7c4f8edc16 100644 --- a/src/dynamicMesh/setUpdater/setUpdater.C +++ b/src/dynamicMesh/setUpdater/setUpdater.C @@ -45,14 +45,8 @@ namespace Foam ); } - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from dictionary Foam::setUpdater::setUpdater ( const word& name, @@ -111,22 +105,13 @@ void Foam::setUpdater::write(Ostream& os) const void Foam::setUpdater::writeDict(Ostream& os) const { - os << nl << name() << nl << token::BEGIN_BLOCK << nl - << " type " << type() - << token::END_STATEMENT << nl - << " active " << active() - << token::END_STATEMENT << nl - << token::END_BLOCK << endl; -} - + os << nl; -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + os.beginBlock(name()); + os.writeEntry("type", type()); + os.writeEntry("active", active()); + os.endBlock(); +} // ************************************************************************* // diff --git a/src/dynamicMesh/slidingInterface/slidingInterface.C b/src/dynamicMesh/slidingInterface/slidingInterface.C index 7048a5713ab..84caf4901b3 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterface.C +++ b/src/dynamicMesh/slidingInterface/slidingInterface.C @@ -765,30 +765,22 @@ void Foam::slidingInterface::write(Ostream& os) const void Foam::slidingInterface::writeDict(Ostream& os) const { - os << nl << name() << nl << token::BEGIN_BLOCK << nl - << " type " << type() << token::END_STATEMENT << nl - << " masterFaceZoneName " << masterFaceZoneID_.name() - << token::END_STATEMENT << nl - << " slaveFaceZoneName " << slaveFaceZoneID_.name() - << token::END_STATEMENT << nl - << " cutPointZoneName " << cutPointZoneID_.name() - << token::END_STATEMENT << nl - << " cutFaceZoneName " << cutFaceZoneID_.name() - << token::END_STATEMENT << nl - << " masterPatchName " << masterPatchID_.name() - << token::END_STATEMENT << nl - << " slavePatchName " << slavePatchID_.name() - << token::END_STATEMENT << nl - << " typeOfMatch " << typeOfMatchNames_[matchType_] - << token::END_STATEMENT << nl - << " coupleDecouple " << coupleDecouple_ - << token::END_STATEMENT << nl - << " projection " << intersection::algorithmNames_[projectionAlgo_] - << token::END_STATEMENT << nl - << " attached " << attached_ - << token::END_STATEMENT << nl - << " active " << active() - << token::END_STATEMENT << nl; + os << nl; + + os.beginBlock(name()); + + os.writeEntry("type", type()); + os.writeEntry("masterFaceZoneName", masterFaceZoneID_.name()); + os.writeEntry("slaveFaceZoneName", slaveFaceZoneID_.name()); + os.writeEntry("cutPointZoneName", cutPointZoneID_.name()); + os.writeEntry("cutFaceZoneName", cutFaceZoneID_.name()); + os.writeEntry("masterPatchName", masterPatchID_.name()); + os.writeEntry("slavePatchName", slavePatchID_.name()); + os.writeEntry("typeOfMatch", typeOfMatchNames_[matchType_]); + os.writeEntry("coupleDecouple", coupleDecouple_); + os.writeEntry("projection", intersection::algorithmNames_[projectionAlgo_]); + os.writeEntry("attached", attached_); + os.writeEntry("active", active()); if (attached_) { @@ -797,10 +789,8 @@ void Foam::slidingInterface::writeDict(Ostream& os) const masterStickOutFacesPtr_->writeEntry("masterStickOutFaces", os); slaveStickOutFacesPtr_->writeEntry("slaveStickOutFaces", os); - os << " retiredPointMap " << retiredPointMap() - << token::END_STATEMENT << nl - << " cutPointEdgePairMap " << cutPointEdgePairMap() - << token::END_STATEMENT << nl; + os.writeEntry("retiredPointMap", retiredPointMap()); + os.writeEntry("cutPointEdgePairMap", cutPointEdgePairMap()); } WRITE_NON_DEFAULT(pointMergeTol) @@ -812,7 +802,7 @@ void Foam::slidingInterface::writeDict(Ostream& os) const WRITE_NON_DEFAULT(edgeCoPlanarTol) WRITE_NON_DEFAULT(edgeEndCutoffTol) - os << token::END_BLOCK << endl; + os.endBlock(); } diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index b1f64847c58..541b9b0d29c 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -571,21 +571,20 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const void Foam::MRFZone::writeData(Ostream& os) const { os << nl; - os.write(name_) << nl; - os << token::BEGIN_BLOCK << incrIndent << nl; - os.writeKeyword("active") << active_ << token::END_STATEMENT << nl; - os.writeKeyword("cellZone") << cellZoneName_ << token::END_STATEMENT << nl; - os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; - os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; + os.beginBlock(name_); + + os.writeEntry("active", active_); + os.writeEntry("cellZone", cellZoneName_); + os.writeEntry("origin", origin_); + os.writeEntry("axis", axis_); omega_->writeData(os); if (excludedPatchNames_.size()) { - os.writeKeyword("nonRotatingPatches") << excludedPatchNames_ - << token::END_STATEMENT << nl; + os.writeEntry("nonRotatingPatches", excludedPatchNames_); } - os << decrIndent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C index 6749dfb7494..8f33573a0ff 100644 --- a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C +++ b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C @@ -158,9 +158,9 @@ void Foam::SRFFreestreamVelocityFvPatchVectorField::updateCoeffs() void Foam::SRFFreestreamVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("relative") << relative_ << token::END_STATEMENT << nl; - os.writeKeyword("UInf") << UInf_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl; + os.writeEntry("relative", relative_); + os.writeEntry("UInf", UInf_); + os.writeEntry("phi", this->phiName_); writeEntry("value", os); } diff --git a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C index ba3a0457269..590c5390088 100644 --- a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C +++ b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C @@ -153,7 +153,7 @@ void Foam::SRFVelocityFvPatchVectorField::updateCoeffs() void Foam::SRFVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("relative") << relative_ << token::END_STATEMENT << nl; + os.writeEntry("relative", relative_); inletValue_.writeEntry("inletValue", os); writeEntry("value", os); } diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C index 88730167b86..36a87ffec42 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C @@ -29,24 +29,23 @@ License void Foam::fv::option::writeHeader(Ostream& os) const { - os << indent << name_ << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock(name_); } void Foam::fv::option::writeFooter(Ostream& os) const { - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } void Foam::fv::option::writeData(Ostream& os) const { - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; - os.writeKeyword("active") << active_ << token::END_STATEMENT << nl << nl; + os.writeEntry("type", type()); + os.writeEntry("active", active_); - os << indent << word(type() + "Coeffs"); - coeffs_.write(os); + os << nl; + coeffs_.writeEntry(word(type() + "Coeffs"), os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C index 18213659c76..4761e61da7e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C @@ -292,18 +292,12 @@ void Foam::activeBaffleVelocityFvPatchVectorField::updateCoeffs() void Foam::activeBaffleVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "p", "p", pName_); - os.writeKeyword("cyclicPatch") - << cyclicPatchName_ << token::END_STATEMENT << nl; - os.writeKeyword("orientation") - << orientation_ << token::END_STATEMENT << nl; - os.writeKeyword("openingTime") - << openingTime_ << token::END_STATEMENT << nl; - os.writeKeyword("maxOpenFractionDelta") - << maxOpenFractionDelta_ << token::END_STATEMENT << nl; - os.writeKeyword("openFraction") - << openFraction_ << token::END_STATEMENT << nl; - writeEntryIfDifferent<word>(os, "p", "p", pName_); + os.writeEntryIfDifferent<word>("p", "p", pName_); + os.writeEntry("cyclicPatch", cyclicPatchName_); + os.writeEntry("orientation", orientation_); + os.writeEntry("openingTime", openingTime_); + os.writeEntry("maxOpenFractionDelta", maxOpenFractionDelta_); + os.writeEntry("openFraction", openFraction_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C index 438d135ff8d..a0f66f5739c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C @@ -377,21 +377,14 @@ void Foam::activePressureForceBaffleVelocityFvPatchVectorField:: write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "p", "p", pName_); - os.writeKeyword("cyclicPatch") - << cyclicPatchName_ << token::END_STATEMENT << nl; - os.writeKeyword("openingTime") - << openingTime_ << token::END_STATEMENT << nl; - os.writeKeyword("maxOpenFractionDelta") - << maxOpenFractionDelta_ << token::END_STATEMENT << nl; - os.writeKeyword("openFraction") - << openFraction_ << token::END_STATEMENT << nl; - os.writeKeyword("minThresholdValue") - << minThresholdValue_ << token::END_STATEMENT << nl; - os.writeKeyword("forceBased") - << fBased_ << token::END_STATEMENT << nl; - os.writeKeyword("opening") - << opening_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("p", "p", pName_); + os.writeEntry("cyclicPatch", cyclicPatchName_); + os.writeEntry("openingTime", openingTime_); + os.writeEntry("maxOpenFractionDelta", maxOpenFractionDelta_); + os.writeEntry("openFraction", openFraction_); + os.writeEntry("minThresholdValue", minThresholdValue_); + os.writeEntry("forceBased", fBased_); + os.writeEntry("opening", opening_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C index aa86f9936c0..fe7567c9afe 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C @@ -339,13 +339,13 @@ void Foam::advectiveFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - this->template writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - this->template writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); if (lInf_ > 0) { - os.writeKeyword("fieldInf") << fieldInf_ << token::END_STATEMENT << nl; - os.writeKeyword("lInf") << lInf_ << token::END_STATEMENT << nl; + os.writeEntry("fieldInf", fieldInf_); + os.writeEntry("lInf", lInf_); } this->writeEntry("value", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C index 12ab0338479..2081404eac3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C @@ -268,8 +268,7 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const // Make sure to construct the patchfield with up-to-date value OStringStream os; - os.writeKeyword("type") << name_ << token::END_STATEMENT - << nl; + os.writeEntry("type", name_); static_cast<const Field<Type>&>(*this).writeEntry("value", os); IStringStream is(os.str()); dictionary dict(is); @@ -331,8 +330,7 @@ template<class Type> void Foam::codedFixedValueFvPatchField<Type>::write(Ostream& os) const { fixedValueFvPatchField<Type>::write(os); - os.writeKeyword("name") << name_ - << token::END_STATEMENT << nl; + os.writeEntry("name", name_); 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 0dd3600e585..6bbdb3c5a47 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C @@ -343,8 +343,7 @@ template<class Type> void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const { mixedFvPatchField<Type>::write(os); - os.writeKeyword("name") << name_ - << token::END_STATEMENT << nl; + os.writeEntry("name", name_); codedBase::writeCodeDict(os, dict_); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C index d6223500e0d..31a67024a51 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C @@ -147,8 +147,8 @@ void Foam::cylindricalInletVelocityFvPatchVectorField::updateCoeffs() void Foam::cylindricalInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchField<vector>::write(os); - os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl; - os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; + os.writeEntry("centre", centre_); + os.writeEntry("axis", axis_); axialVelocity_->writeData(os); radialVelocity_->writeData(os); rpm_->writeData(os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C index e22d979213d..6e116998906 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C @@ -132,12 +132,9 @@ template<class Type> void Foam::fanFvPatchField<Type>::write(Ostream& os) const { uniformJumpFvPatchField<Type>::write(os); - this->template writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - this->template writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - this->template writeEntryIfDifferent<bool> - ( - os, "uniformJump", false, uniformJump_ - ); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<bool>("uniformJump", false, uniformJump_); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C index 52764fc6a3d..726084c732a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C @@ -155,8 +155,7 @@ template<class Type> void Foam::fixedJumpFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - os.writeKeyword("patchType") << this->interfaceFieldType() - << token::END_STATEMENT << nl; + os.writeEntry("patchType", this->interfaceFieldType()); if (this->cyclicPatch().owner()) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C index 2229069a14d..d043e573c31 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C @@ -169,8 +169,7 @@ template<class Type> void Foam::fixedJumpAMIFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - os.writeKeyword("patchType") << this->interfaceFieldType() - << token::END_STATEMENT << nl; + os.writeEntry("patchType", this->interfaceFieldType()); if (this->cyclicAMIPatch().owner()) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C index e2c2669d2e0..1155c5d022f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C @@ -181,13 +181,13 @@ void Foam::fixedNormalInletOutletVelocityFvPatchVectorField::write const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - os.writeKeyword("fixTangentialInflow") - << fixTangentialInflow_ << token::END_STATEMENT << nl; - os.writeKeyword("normalVelocity") - << nl << indent << token::BEGIN_BLOCK << nl << incrIndent; + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntry("fixTangentialInflow", fixTangentialInflow_); + + os.beginBlock("normalVelocity"); normalVelocity_->write(os); - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); + writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C index 6190926fc8c..cc1b0f4ff93 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C @@ -128,7 +128,7 @@ void Foam::fixedPressureCompressibleDensityFvPatchScalarField::write ) const { fvPatchField<scalar>::write(os); - writeEntryIfDifferent<word>(os, "p", "p", pName_); + os.writeEntryIfDifferent<word>("p", "p", pName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C index be523343383..1deba5890f7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C @@ -158,8 +158,8 @@ void Foam::fixedProfileFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); profile_->writeData(os); - os.writeKeyword("direction") << dir_ << token::END_STATEMENT << nl; - os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; + os.writeEntry("direction", dir_); + os.writeEntry("origin", origin_); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index 2f14a7d2152..f40f399ad34 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -243,11 +243,10 @@ void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const flowRate_->writeData(os); if (!volumetric_) { - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<scalar>(os, "rhoInlet", -VGREAT, rhoInlet_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<scalar>("rhoInlet", -VGREAT, rhoInlet_); } - os.writeKeyword("extrapolateProfile") - << extrapolateProfile_ << token::END_STATEMENT << nl; + os.writeEntry("extrapolateProfile", extrapolateProfile_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C index cd06d768953..ed9d095a2a1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C @@ -228,8 +228,8 @@ void Foam::flowRateOutletVelocityFvPatchVectorField::write(Ostream& os) const flowRate_->writeData(os); if (!volumetric_) { - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<scalar>(os, "rhoOutlet", -VGREAT, rhoOutlet_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<scalar>("rhoOutlet", -VGREAT, rhoOutlet_); } writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C index 10124ec9f83..217b6734604 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C @@ -138,8 +138,8 @@ void Foam::fluxCorrectedVelocityFvPatchVectorField::evaluate void Foam::fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C index 49ae3f5b27a..eac0fe4feb0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C @@ -108,11 +108,7 @@ template<class Type> void Foam::freestreamFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - if (this->phiName_ != "phi") - { - os.writeKeyword("phi") - << this->phiName_ << token::END_STATEMENT << nl; - } + os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_); freestreamValue().writeEntry("freestreamValue", os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C index 1c8787e5e46..1986bc40d68 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C @@ -156,9 +156,9 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs() void Foam::freestreamPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C index 49aa47efad4..59654abb923 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C @@ -138,10 +138,7 @@ template<class Type> void Foam::inletOutletFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - if (phiName_ != "phi") - { - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - } + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); this->refValue().writeEntry("inletValue", os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C index 5735ee62229..679cb120552 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C @@ -189,10 +189,10 @@ void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_); - writeEntryIfDifferent<word>(os, "psi", "psi", psiName_); - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_); + os.writeEntryIfDifferent<word>("psi", "psi", psiName_); + os.writeEntry("gamma", gamma_); T0_.writeEntry("T0", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C index 00f2a8307ef..057be9e9213 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C @@ -143,7 +143,7 @@ void Foam::interstitialInletVelocityFvPatchVectorField::updateCoeffs() void Foam::interstitialInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchField<vector>::write(os); - writeEntryIfDifferent<word>(os, "alpha", "alpha", alphaName_); + os.writeEntryIfDifferent<word>("alpha", "alpha", alphaName_); inletVelocity_.writeEntry("inletVelocity", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C index 52072044ccf..11349a08ca6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C @@ -314,11 +314,10 @@ tmp<Field<Type>> mappedPatchFieldBase<Type>::mappedField() const template<class Type> void mappedPatchFieldBase<Type>::write(Ostream& os) const { - os.writeKeyword("field") << fieldName_ << token::END_STATEMENT << nl; - os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; - os.writeKeyword("average") << average_ << token::END_STATEMENT << nl; - os.writeKeyword("interpolationScheme") << interpolationScheme_ - << token::END_STATEMENT << nl; + os.writeEntry("field", fieldName_); + os.writeEntry("setAverage", setAverage_); + os.writeEntry("average", average_); + os.writeEntry("interpolationScheme", interpolationScheme_); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C index 81cce9b1b52..27d67c67974 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C @@ -186,9 +186,9 @@ void Foam::mappedFlowRateFvPatchVectorField::write ) const { fvPatchField<vector>::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - os.writeKeyword("nbrPhi") << nbrPhiName_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntry("nbrPhi", nbrPhiName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C index 89c0c11bf7c..e35b556c480 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C @@ -233,7 +233,7 @@ void Foam::mappedVelocityFluxFixedValueFvPatchField::write ) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C index 4ea359ee5b2..30987e05dbb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C @@ -244,13 +244,11 @@ void Foam::matchedFlowRateOutletVelocityFvPatchVectorField::write ) const { fvPatchField<vector>::write(os); - os.writeKeyword("inletPatch") - << inletPatchName_ << token::END_STATEMENT << nl; + os.writeEntry("inletPatch", inletPatchName_); if (!volumetric_) { - os.writeKeyword("volumetric") - << volumetric_ << token::END_STATEMENT << nl; - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntry("volumetric", volumetric_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); } writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C index 408b40686b5..80b94c53839 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C @@ -138,10 +138,7 @@ template<class Type> void Foam::outletInletFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - if (phiName_ != "phi") - { - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - } + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); this->refValue().writeEntry("outletValue", os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C index 6cb337ff099..5490a8a930f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C @@ -168,12 +168,8 @@ template<class Type> void Foam::outletMappedUniformInletFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - os.writeKeyword("outletPatch") - << outletPatchName_ << token::END_STATEMENT << nl; - if (phiName_ != "phi") - { - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - } + os.writeEntry("outletPatch", outletPatchName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C index f92a4bf136d..b1fef5b04be 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C @@ -167,10 +167,8 @@ void Foam::outletPhaseMeanVelocityFvPatchVectorField::write { fvPatchField<vector>::write(os); - os.writeKeyword("Umean") << Umean_ - << token::END_STATEMENT << nl; - os.writeKeyword("alpha") << alphaName_ - << token::END_STATEMENT << nl; + os.writeEntry("Umean", Umean_); + os.writeEntry("alpha", alphaName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C index 0dd82e8c443..a585876bd4a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C @@ -163,14 +163,10 @@ void Foam::phaseHydrostaticPressureFvPatchScalarField::updateCoeffs() void Foam::phaseHydrostaticPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - if (phaseFraction_ != "alpha") - { - os.writeKeyword("phaseFraction") - << phaseFraction_ << token::END_STATEMENT << nl; - } - os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl; - os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl; - os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("phaseFraction", "alpha", phaseFraction_); + os.writeEntry("rho", rho_); + os.writeEntry("pRefValue", pRefValue_); + os.writeEntry("pRefPoint", pRefPoint_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C index f1dbf71611c..8464d32d0d5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C @@ -300,32 +300,22 @@ void Foam::plenumPressureFvPatchScalarField::updateCoeffs() void Foam::plenumPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("gamma") << gamma_ - << token::END_STATEMENT << nl; - os.writeKeyword("R") << R_ - << token::END_STATEMENT << nl; - os.writeKeyword("supplyMassFlowRate") << supplyMassFlowRate_ - << token::END_STATEMENT << nl; - os.writeKeyword("supplyTotalTemperature") << supplyTotalTemperature_ - << token::END_STATEMENT << nl; - os.writeKeyword("plenumVolume") << plenumVolume_ - << token::END_STATEMENT << nl; - os.writeKeyword("plenumDensity") << plenumDensity_ - << token::END_STATEMENT << nl; - os.writeKeyword("plenumTemperature") << plenumTemperature_ - << token::END_STATEMENT << nl; + os.writeEntry("gamma", gamma_); + os.writeEntry("R", R_); + os.writeEntry("supplyMassFlowRate", supplyMassFlowRate_); + os.writeEntry("supplyTotalTemperature", supplyTotalTemperature_); + os.writeEntry("plenumVolume", plenumVolume_); + os.writeEntry("plenumDensity", plenumDensity_); + os.writeEntry("plenumTemperature", plenumTemperature_); if (hasRho_) { - os.writeKeyword("rho") << rho_ - << token::END_STATEMENT << nl; + os.writeEntry("rho", rho_); } - os.writeKeyword("inletAreaRatio") << inletAreaRatio_ - << token::END_STATEMENT << nl; - os.writeKeyword("inletDischargeCoefficient") << inletDischargeCoefficient_ - << token::END_STATEMENT << nl; - writeEntryIfDifferent<scalar>(os, "timeScale", 0.0, timeScale_); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "U", "U", UName_); + os.writeEntry("inletAreaRatio", inletAreaRatio_); + os.writeEntry("inletDischargeCoefficient", inletDischargeCoefficient_); + os.writeEntryIfDifferent<scalar>("timeScale", 0.0, timeScale_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("U", "U", UName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C index c472c754eb8..d7b72b17bab 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C @@ -190,8 +190,8 @@ void Foam::pressureDirectedInletOutletVelocityFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); inletDir_.writeEntry("inletDirection", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C index 9ab1bc87ef4..2d42d60d522 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C @@ -178,8 +178,8 @@ void Foam::pressureDirectedInletVelocityFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); inletDir_.writeEntry("inletDirection", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C index 84abe77c3f0..2ddaa235cf7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C @@ -164,8 +164,8 @@ void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C index 32f8aa2cfb2..84aab726fad 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C @@ -188,7 +188,7 @@ void Foam::pressureInletOutletVelocityFvPatchVectorField::write const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); if (tangentialVelocity_.size()) { tangentialVelocity_.writeEntry("tangentialVelocity", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C index 06e58e73bb7..e1a24d4ba0f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C @@ -143,8 +143,8 @@ void Foam::pressureInletVelocityFvPatchVectorField::updateCoeffs() void Foam::pressureInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C index 84689bf1e96..08b71bf468d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C @@ -160,8 +160,8 @@ void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + os.writeEntry("phi", phiName_); + os.writeEntry("rho", rhoName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C index 9b5e347fbd2..68c6e78cb36 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C @@ -365,20 +365,17 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::write { fvPatchField<vector>::write(os); - os.writeKeyword("deltaP") << deltaP_ << token::END_STATEMENT << nl; - os.writeKeyword("upstream") << upstreamName_ << token::END_STATEMENT << nl; - os.writeKeyword("downstream") - << downstreamName_ << token::END_STATEMENT << nl; - os.writeKeyword("shapeFactor") << shapeFactor_ - << token::END_STATEMENT << nl; - writeEntryIfDifferent<word>(os, "p", "p", pName_); - writeEntryIfDifferent<word>(os, "rho", "none", rhoName_); - os.writeKeyword("P") << P_ << token::END_STATEMENT << nl; - os.writeKeyword("I") << I_ << token::END_STATEMENT << nl; - os.writeKeyword("D") << D_ << token::END_STATEMENT << nl; - os.writeKeyword("error") << error_ << token::END_STATEMENT << nl; - os.writeKeyword("errorIntegral") - << errorIntegral_ << token::END_STATEMENT << nl; + os.writeEntry("deltaP", deltaP_); + os.writeEntry("upstream", upstreamName_); + os.writeEntry("downstream", downstreamName_); + os.writeEntry("shapeFactor", shapeFactor_); + os.writeEntryIfDifferent<word>("p", "p", pName_); + os.writeEntryIfDifferent<word>("rho", "none", rhoName_); + os.writeEntry("P", P_); + os.writeEntry("I", I_); + os.writeEntry("D", D_); + os.writeEntry("error", error_); + os.writeEntry("errorIntegral", errorIntegral_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C index c266d27f856..e365010fa15 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C @@ -171,7 +171,7 @@ void Foam::prghPressureFvPatchScalarField::updateCoeffs() void Foam::prghPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); p_.writeEntry("p", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C index e1705e24bcd..9558a893ee5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C @@ -146,10 +146,10 @@ void Foam::prghTotalHydrostaticPressureFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<word>(os, "ph_rgh", "ph_rgh", ph_rghName_); + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("ph_rgh", "ph_rgh", ph_rghName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C index 9a4f9b15721..feeed484333 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C @@ -191,9 +191,9 @@ void Foam::prghTotalPressureFvPatchScalarField::updateCoeffs() void Foam::prghTotalPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); p0_.writeEntry("p0", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C index 4f22a43edad..edaca467e2e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C @@ -128,7 +128,7 @@ void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - os.writeKeyword("phi") << phiName() << token::END_STATEMENT << nl; + os.writeEntry("phi", phiName()); omega_->writeData(os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C index ebc32b0790c..d322862f4a6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C @@ -145,8 +145,8 @@ void Foam::rotatingWallVelocityFvPatchVectorField::updateCoeffs() void Foam::rotatingWallVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; - os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; + os.writeEntry("origin", origin_); + os.writeEntry("axis", axis_); omega_->writeData(os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C index ddfb7c790c2..39c06df42c9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C @@ -297,13 +297,13 @@ void Foam::supersonicFreestreamFvPatchVectorField::updateCoeffs() void Foam::supersonicFreestreamFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "T", "T", TName_); - writeEntryIfDifferent<word>(os, "p", "p", pName_); - writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_); - os.writeKeyword("UInf") << UInf_ << token::END_STATEMENT << nl; - os.writeKeyword("pInf") << pInf_ << token::END_STATEMENT << nl; - os.writeKeyword("TInf") << TInf_ << token::END_STATEMENT << nl; - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("T", "T", TName_); + os.writeEntryIfDifferent<word>("p", "p", pName_); + os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_); + os.writeEntry("UInf", UInf_); + os.writeEntry("pInf", pInf_); + os.writeEntry("TInf", TInf_); + os.writeEntry("gamma", gamma_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C index 861bac7f9b1..44ddaa37ddb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C @@ -199,10 +199,10 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::write ) const { fvPatchField<vector>::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; - os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntry("origin", origin_); + os.writeEntry("axis", axis_); flowRate_->writeData(os); rpm_->writeData(os); writeEntry("value", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C index 79ee1cb2c96..4b76142d9f6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C @@ -145,8 +145,8 @@ void Foam::swirlInletVelocityFvPatchVectorField::updateCoeffs() void Foam::swirlInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchField<vector>::write(os); - os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; - os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; + os.writeEntry("origin", origin_); + os.writeEntry("axis", axis_); axialVelocity_->writeData(os); radialVelocity_->writeData(os); tangentialVelocity_->writeData(os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C index c33db45ca26..a086f891608 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C @@ -233,17 +233,17 @@ void Foam::syringePressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("Ap") << Ap_ << token::END_STATEMENT << nl; - os.writeKeyword("Sp") << Sp_ << token::END_STATEMENT << nl; - os.writeKeyword("VsI") << VsI_ << token::END_STATEMENT << nl; - os.writeKeyword("tas") << tas_ << token::END_STATEMENT << nl; - os.writeKeyword("tae") << tae_ << token::END_STATEMENT << nl; - os.writeKeyword("tds") << tds_ << token::END_STATEMENT << nl; - os.writeKeyword("tde") << tde_ << token::END_STATEMENT << nl; - os.writeKeyword("psI") << psI_ << token::END_STATEMENT << nl; - os.writeKeyword("psi") << psi_ << token::END_STATEMENT << nl; - os.writeKeyword("ams") << ams_ << token::END_STATEMENT << nl; - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); + os.writeEntry("Ap", Ap_); + os.writeEntry("Sp", Sp_); + os.writeEntry("VsI", VsI_); + os.writeEntry("tas", tas_); + os.writeEntry("tae", tae_); + os.writeEntry("tds", tds_); + os.writeEntry("tde", tde_); + os.writeEntry("psI", psI_); + os.writeEntry("psi", psi_); + os.writeEntry("ams", ams_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index 5ba985a24e2..af626c2c5e4 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -568,23 +568,20 @@ void Foam::timeVaryingMappedFixedValueFvPatchField<Type>::write { fvPatchField<Type>::write(os); - this->writeEntryIfDifferent(os, "setAverage", Switch(false), setAverage_); + os.writeEntryIfDifferent("setAverage", Switch(false), setAverage_); + os.writeEntryIfDifferent<scalar>("perturb", 1e-5, perturb_); - this->writeEntryIfDifferent(os, "perturb", scalar(1e-5), perturb_); - - this->writeEntryIfDifferent + os.writeEntryIfDifferent ( - os, "fieldTable", this->internalField().name(), fieldTableName_ ); - this->writeEntryIfDifferent + os.writeEntryIfDifferent<word> ( - os, "mapMethod", - word("planarInterpolation"), + "planarInterpolation", mapMethod_ ); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C index de94aeeffe3..65461cc9c49 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C @@ -243,11 +243,11 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs() void Foam::totalPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; - os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntry("rho", rhoName_); + os.writeEntry("psi", psiName_); + os.writeEntry("gamma", gamma_); p0_.writeEntry("p0", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C index df7d20629c5..771ebb53d84 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C @@ -177,10 +177,10 @@ void Foam::totalTemperatureFvPatchScalarField::updateCoeffs() void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_); - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_); + os.writeEntry("gamma", gamma_); T0_.writeEntry("T0", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C index 5d1bce06740..5dda8366392 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C @@ -1103,12 +1103,12 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::write(Ostream& os) const { fvPatchField<vector>::write(os); writeEntry("value", os); - os.writeKeyword("delta") << delta_ << token::END_STATEMENT << nl; - writeEntryIfDifferent<scalar>(os, "d", 1.0, d_); - writeEntryIfDifferent<scalar>(os, "kappa", 0.41, kappa_); - writeEntryIfDifferent<scalar>(os, "perturb", 1e-5, perturb_); - writeEntryIfDifferent<label>(os, "nCellPerEddy", 5, nCellPerEddy_); - writeEntryIfDifferent(os, "writeEddies", false, writeEddies_); + os.writeEntry("delta", delta_); + os.writeEntryIfDifferent<scalar>("d", 1.0, d_); + os.writeEntryIfDifferent<scalar>("kappa", 0.41, kappa_); + os.writeEntryIfDifferent<scalar>("perturb", 1e-5, perturb_); + os.writeEntryIfDifferent<label>("nCellPerEddy", 5, nCellPerEddy_); + os.writeEntryIfDifferent("writeEddies", false, writeEddies_); if (!interpolateR_) { @@ -1125,14 +1125,14 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::write(Ostream& os) const U_.writeEntry("U", os); } - if - ( - !mapMethod_.empty() - && mapMethod_ != "planarInterpolation" - ) + if (!mapMethod_.empty()) { - os.writeKeyword("mapMethod") << mapMethod_ - << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word> + ( + "mapMethod", + "planarInterpolation", + mapMethod_ + ); } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C index b457ecd85a3..57032e53c0f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C @@ -196,10 +196,9 @@ template<class Type> void Foam::turbulentInletFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - os.writeKeyword("fluctuationScale") - << fluctuationScale_ << token::END_STATEMENT << nl; + os.writeEntry("fluctuationScale", fluctuationScale_); referenceField_.writeEntry("referenceField", os); - os.writeKeyword("alpha") << alpha_ << token::END_STATEMENT << nl; + os.writeEntry("alpha", alpha_); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C index 20369fe63c3..14ec2d187ff 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C @@ -149,9 +149,9 @@ void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl; - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_); + os.writeEntry("intensity", intensity_); + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C index ba14325c6a3..fb6367a51a6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C @@ -144,9 +144,9 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl; - os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl; - os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl; + os.writeEntry("rho", rho_); + os.writeEntry("pRefValue", pRefValue_); + os.writeEntry("pRefPoint", pRefPoint_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C index 011b8552fd4..647398f4b05 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C @@ -160,10 +160,7 @@ template<class Type> void Foam::uniformInletOutletFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - if (phiName_ != "phi") - { - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - } + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); this->uniformInletValue_->writeData(os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C index 152a74937c7..ea3c1705c6c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C @@ -227,11 +227,11 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs() void Foam::uniformTotalPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; - os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntry("rho", rhoName_); + os.writeEntry("psi", psiName_); + os.writeEntry("gamma", gamma_); p0_->writeData(os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C index 341d6134325..9f9f89865ac 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C @@ -173,12 +173,9 @@ void Foam::variableHeightFlowRateFvPatchScalarField::updateCoeffs() void Foam::variableHeightFlowRateFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - if (phiName_ != "phi") - { - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - } - os.writeKeyword("lowerBound") << lowerBound_ << token::END_STATEMENT << nl; - os.writeKeyword("upperBound") << upperBound_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntry("lowerBound", lowerBound_); + os.writeEntry("upperBound", upperBound_); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C index f0f3802339c..40a7ce65d96 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C @@ -133,7 +133,7 @@ void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField::write { fvPatchField<vector>::write(os); flowRate_->writeData(os); - os.writeKeyword("alpha") << alphaName_ << token::END_STATEMENT << nl; + os.writeEntry("alpha", alphaName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C index 4d986bd2914..440c1e28595 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C @@ -229,9 +229,9 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs() void Foam::waveSurfacePressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "zeta", "zeta", zetaName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("zeta", "zeta", zetaName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C index eb80ace5c9c..863ede5a135 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C @@ -139,21 +139,16 @@ void Foam::waveTransmissiveFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - this->template - writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_); - this->template - writeEntryIfDifferent<word>(os, "rho", "rho", this->rhoName_); - this->template - writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_); + os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", this->rhoName_); + os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_); - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; + os.writeEntry("gamma", gamma_); if (this->lInf_ > SMALL) { - os.writeKeyword("fieldInf") << this->fieldInf_ - << token::END_STATEMENT << nl; - os.writeKeyword("lInf") << this->lInf_ - << token::END_STATEMENT << nl; + os.writeEntry("fieldInf", this->fieldInf_); + os.writeEntry("lInf", this->lInf_); } this->writeEntry("value", os); diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index 52bd26e8095..764a266517e 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -362,29 +362,11 @@ void Foam::fvPatchField<Type>::manipulateMatrix template<class Type> void Foam::fvPatchField<Type>::write(Ostream& os) const { - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); if (patchType_.size()) { - os.writeKeyword("patchType") << patchType_ - << token::END_STATEMENT << nl; - } -} - - -template<class Type> -template<class EntryType> -void Foam::fvPatchField<Type>::writeEntryIfDifferent -( - Ostream& os, - const word& entryName, - const EntryType& value1, - const EntryType& value2 -) const -{ - if (value1 != value2) - { - os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl; + os.writeEntry("patchType", patchType_); } } diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index da0953aeba9..71d4a8ffd6f 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -530,17 +530,6 @@ public: //- Write virtual void write(Ostream&) const; - //- Helper function to write the keyword and entry only if the - // values are not equal. The value is then output as value2 - template<class EntryType> - void writeEntryIfDifferent - ( - Ostream& os, - const word& entryName, - const EntryType& value1, - const EntryType& value2 - ) const; - // Check diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C index 8a8c96244c3..61db751a549 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C @@ -166,7 +166,7 @@ void Foam::fvsPatchField<Type>::rmap template<class Type> void Foam::fvsPatchField<Type>::write(Ostream& os) const { - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); this->writeEntry("value", os); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C index e19f500b16c..843b115d07e 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C @@ -179,16 +179,11 @@ void angularOscillatingDisplacementPointPatchVectorField::write ) const { pointPatchField<vector>::write(os); - os.writeKeyword("axis") - << axis_ << token::END_STATEMENT << nl; - os.writeKeyword("origin") - << origin_ << token::END_STATEMENT << nl; - os.writeKeyword("angle0") - << angle0_ << token::END_STATEMENT << nl; - os.writeKeyword("amplitude") - << amplitude_ << token::END_STATEMENT << nl; - os.writeKeyword("omega") - << omega_ << token::END_STATEMENT << nl; + os.writeEntry("axis", axis_); + os.writeEntry("origin", origin_); + os.writeEntry("angle0", angle0_); + os.writeEntry("amplitude", amplitude_); + os.writeEntry("omega", omega_); p0_.writeEntry("p0", os); writeEntry("value", os); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C index 5932d8402c3..3f64821dd71 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C @@ -184,16 +184,11 @@ void angularOscillatingVelocityPointPatchVectorField::write ) const { pointPatchField<vector>::write(os); - os.writeKeyword("axis") - << axis_ << token::END_STATEMENT << nl; - os.writeKeyword("origin") - << origin_ << token::END_STATEMENT << nl; - os.writeKeyword("angle0") - << angle0_ << token::END_STATEMENT << nl; - os.writeKeyword("amplitude") - << amplitude_ << token::END_STATEMENT << nl; - os.writeKeyword("omega") - << omega_ << token::END_STATEMENT << nl; + os.writeEntry("axis", axis_); + os.writeEntry("origin", origin_); + os.writeEntry("angle0", angle0_); + os.writeEntry("amplitude", amplitude_); + os.writeEntry("omega", omega_); p0_.writeEntry("p0", os); writeEntry("value", os); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C index 9e36b8cefbe..98e83d7b88b 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C @@ -117,10 +117,8 @@ void oscillatingDisplacementPointPatchVectorField::updateCoeffs() void oscillatingDisplacementPointPatchVectorField::write(Ostream& os) const { pointPatchField<vector>::write(os); - os.writeKeyword("amplitude") - << amplitude_ << token::END_STATEMENT << nl; - os.writeKeyword("omega") - << omega_ << token::END_STATEMENT << nl; + os.writeEntry("amplitude", amplitude_); + os.writeEntry("omega", omega_); writeEntry("value", os); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C index f75b568ecaf..f99d5385284 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C @@ -160,10 +160,8 @@ void oscillatingVelocityPointPatchVectorField::updateCoeffs() void oscillatingVelocityPointPatchVectorField::write(Ostream& os) const { pointPatchField<vector>::write(os); - os.writeKeyword("amplitude") - << amplitude_ << token::END_STATEMENT << nl; - os.writeKeyword("omega") - << omega_ << token::END_STATEMENT << nl; + os.writeEntry("amplitude", amplitude_); + os.writeEntry("omega", omega_); p0_.writeEntry("p0", os); writeEntry("value", os); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C index 85d3cd19fd8..5e2053ef990 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C @@ -470,10 +470,12 @@ void Foam::surfaceDisplacementPointPatchVectorField::write(Ostream& os) const os.writeEntry("projectDirection", projectDir_); os.writeEntry("wedgePlane", wedgePlane_); - if (frozenPointsZone_ != word::null) - { - os.writeEntry("frozenPointsZone", frozenPointsZone_); - } + os.writeEntryIfDifferent<word> + ( + "frozenPointsZone", + word::null, + frozenPointsZone_ + ); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C index a85df2a8637..469cebfb79b 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C @@ -431,10 +431,13 @@ void Foam::surfaceSlipDisplacementPointPatchVectorField::write os.writeEntry("projectMode", projectModeNames_[projectMode_]); os.writeEntry("projectDirection", projectDir_); os.writeEntry("wedgePlane", wedgePlane_); - if (frozenPointsZone_ != word::null) - { - os.writeEntry("frozenPointsZone", frozenPointsZone_); - } + + os.writeEntryIfDifferent<word> + ( + "frozenPointsZone", + word::null, + frozenPointsZone_ + ); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C index 886f9440e98..1fbcb49f96b 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C @@ -596,23 +596,20 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::write { fixedValuePointPatchField<Type>::write(os); - this->writeEntryIfDifferent(os, "setAverage", Switch(false), setAverage_); + os.writeEntryIfDifferent("setAverage", Switch(false), setAverage_); + os.writeEntryIfDifferent<scalar>("perturb", 1e-5, perturb_); - this->writeEntryIfDifferent(os, "perturb", scalar(1e-5), perturb_); - - this->writeEntryIfDifferent + os.writeEntryIfDifferent ( - os, "fieldTable", this->internalField().name(), fieldTableName_ ); - this->writeEntryIfDifferent + os.writeEntryIfDifferent<word> ( - os, "mapMethod", - word("planarInterpolation"), + "planarInterpolation", mapMethod_ ); diff --git a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C index ca1193bb432..82eee2cddca 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C @@ -260,10 +260,8 @@ void uniformInterpolatedDisplacementPointPatchVectorField::write(Ostream& os) const { pointPatchField<vector>::write(os); - os.writeKeyword("field") - << fieldName_ << token::END_STATEMENT << nl; - os.writeKeyword("interpolationScheme") - << interpolationScheme_ << token::END_STATEMENT << nl; + os.writeEntry("field", fieldName_); + os.writeEntry("interpolationScheme", interpolationScheme_); writeEntry("value", os); } diff --git a/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C index 34976e9827e..e5196ceab99 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C @@ -121,12 +121,9 @@ void Foam::waveDisplacementPointPatchVectorField::updateCoeffs() void Foam::waveDisplacementPointPatchVectorField::write(Ostream& os) const { pointPatchField<vector>::write(os); - os.writeKeyword("amplitude") - << amplitude_ << token::END_STATEMENT << nl; - os.writeKeyword("omega") - << omega_ << token::END_STATEMENT << nl; - os.writeKeyword("waveNumber") - << waveNumber_ << token::END_STATEMENT << nl; + os.writeEntry("amplitude", amplitude_); + os.writeEntry("omega", omega_); + os.writeEntry("waveNumber", waveNumber_); writeEntry("value", os); } diff --git a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C index 24ccdccae6a..d0a7f439d20 100644 --- a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C +++ b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C @@ -774,7 +774,7 @@ const Foam::word& Foam::genericFvPatchField<Type>::actualType() const template<class Type> void Foam::genericFvPatchField<Type>::write(Ostream& os) const { - os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl; + os.writeEntry("type", actualTypeName_); forAllConstIter(dictionary, dict_, iter) { diff --git a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C index 815d7af99b0..52744cdf3cd 100644 --- a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C +++ b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C @@ -567,7 +567,7 @@ const Foam::word& Foam::genericPointPatchField<Type>::actualType() const template<class Type> void Foam::genericPointPatchField<Type>::write(Ostream& os) const { - os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl; + os.writeEntry("type", actualTypeName_); forAllConstIter(dictionary, dict_, iter) { diff --git a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C index e981fc903b9..00ccbe77390 100644 --- a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C +++ b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C @@ -43,9 +43,9 @@ Foam::phaseProperties::phaseProperties(Istream& is) phase_ = phaseTypeNames[phaseInfo.keyword()]; stateLabel_ = phaseToStateLabel(phase_); - if (phaseInfo.size() > 0) + const label nComponents = phaseInfo.size(); + if (nComponents) { - label nComponents = phaseInfo.size(); names_.setSize(nComponents, "unknownSpecie"); Y_.setSize(nComponents, 0.0); carrierIds_.setSize(nComponents, -1); @@ -74,10 +74,9 @@ Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp) pp.phase_ = pp.phaseTypeNames[phaseInfo.keyword()]; pp.stateLabel_ = pp.phaseToStateLabel(pp.phase_); - if (phaseInfo.size() > 0) + const label nComponents = phaseInfo.size(); + if (nComponents) { - label nComponents = phaseInfo.size(); - pp.names_.setSize(nComponents, "unknownSpecie"); pp.Y_.setSize(nComponents, 0.0); pp.carrierIds_.setSize(nComponents, -1); @@ -101,16 +100,14 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const phaseProperties& pp) { os.check(FUNCTION_NAME); - os << pp.phaseTypeNames[pp.phase_] << nl << token::BEGIN_BLOCK << nl - << incrIndent; + os.beginBlock(pp.phaseTypeNames[pp.phase_]); forAll(pp.names_, cmptI) { - os.writeKeyword(pp.names_[cmptI]) << pp.Y_[cmptI] - << token::END_STATEMENT << nl; + os.writeEntry(pp.names_[cmptI], pp.Y_[cmptI]); } - os << decrIndent << token::END_BLOCK << nl; + os.endBlock(); os.check(FUNCTION_NAME); return os; diff --git a/src/lagrangian/intermediate/submodels/CloudSubModelBase.C b/src/lagrangian/intermediate/submodels/CloudSubModelBase.C index 39bcb8da2f2..807fd4e6cec 100644 --- a/src/lagrangian/intermediate/submodels/CloudSubModelBase.C +++ b/src/lagrangian/intermediate/submodels/CloudSubModelBase.C @@ -126,8 +126,7 @@ bool Foam::CloudSubModelBase<CloudType>::writeTime() const template<class CloudType> void Foam::CloudSubModelBase<CloudType>::write(Ostream& os) const { - os.writeKeyword("owner") << owner_.name() << token::END_STATEMENT - << nl; + os.writeEntry("owner", owner_.name()); subModelBase::write(os); } diff --git a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C index 1ed66474989..87bf0d84acb 100644 --- a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C +++ b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C @@ -184,9 +184,8 @@ void Foam::DispersionRASModel<CloudType>::write(Ostream& os) const { DispersionModel<CloudType>::write(os); - os.writeKeyword("ownK") << ownK_ << token::END_STATEMENT << endl; - os.writeKeyword("ownEpsilon") << ownEpsilon_ << token::END_STATEMENT - << endl; + os.writeEntry("ownK", ownK_); + os.writeEntry("ownEpsilon", ownEpsilon_); } diff --git a/src/lumpedPointMotion/lumpedPointState.C b/src/lumpedPointMotion/lumpedPointState.C index 0ef9f5a48fd..e15e3371c1c 100644 --- a/src/lumpedPointMotion/lumpedPointState.C +++ b/src/lumpedPointMotion/lumpedPointState.C @@ -254,7 +254,7 @@ void Foam::lumpedPointState::writeDict(Ostream& os) const os.writeEntry("angles", angles_); if (degrees_) { - os.writeKeyword("degrees") << "true;" << nl; + os.writeEntry("degrees", word("true")); } } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C index d801ec591eb..4fbd6e39c94 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C @@ -592,8 +592,7 @@ void Foam::cyclicACMIPolyPatch::write(Ostream& os) const { cyclicAMIPolyPatch::write(os); - os.writeKeyword("nonOverlapPatch") << nonOverlapPatchName_ - << token::END_STATEMENT << nl; + os.writeEntry("nonOverlapPatch", nonOverlapPatchName_); } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index 74015e3ece1..12f9546fcab 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -1058,8 +1058,7 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const coupledPolyPatch::write(os); if (!nbrPatchName_.empty()) { - os.writeKeyword("neighbourPatch") << nbrPatchName_ - << token::END_STATEMENT << nl; + os.writeEntry("neighbourPatch", nbrPatchName_); } coupleGroup_.write(os); @@ -1067,23 +1066,19 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const { case ROTATIONAL: { - os.writeKeyword("rotationAxis") << rotationAxis_ - << token::END_STATEMENT << nl; - os.writeKeyword("rotationCentre") << rotationCentre_ - << token::END_STATEMENT << nl; + os.writeEntry("rotationAxis", rotationAxis_); + os.writeEntry("rotationCentre", rotationCentre_); if (rotationAngleDefined_) { - os.writeKeyword("rotationAngle") << radToDeg(rotationAngle_) - << token::END_STATEMENT << nl; + os.writeEntry("rotationAngle", radToDeg(rotationAngle_)); } break; } case TRANSLATIONAL: { - os.writeKeyword("separationVector") << separationVector_ - << token::END_STATEMENT << nl; + os.writeEntry("separationVector", separationVector_); break; } case NOORDERING: @@ -1098,30 +1093,29 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const if (AMIMethod_ != AMIPatchToPatchInterpolation::imFaceAreaWeight) { - os.writeKeyword("method") - << AMIPatchToPatchInterpolation::interpolationMethodToWord - ( - AMIMethod_ - ) - << token::END_STATEMENT << nl; + os.writeEntry + ( + "method", + AMIPatchToPatchInterpolation::interpolationMethodToWord + ( + AMIMethod_ + ) + ); } if (AMIReverse_) { - os.writeKeyword("flipNormals") << AMIReverse_ - << token::END_STATEMENT << nl; + os.writeEntry("flipNormals", AMIReverse_); } if (AMILowWeightCorrection_ > 0) { - os.writeKeyword("lowWeightCorrection") << AMILowWeightCorrection_ - << token::END_STATEMENT << nl; + os.writeEntry("lowWeightCorrection", AMILowWeightCorrection_); } if (!surfDict_.empty()) { - os.writeKeyword(surfDict_.dictName()); - os << surfDict_; + surfDict_.writeEntry(surfDict_.dictName(), os); } } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C index fcbf9dd6ab0..46aad8db985 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C @@ -709,25 +709,10 @@ void Foam::cyclicPeriodicAMIPolyPatch::write(Ostream& os) const { cyclicAMIPolyPatch::write(os); - os.writeKeyword("periodicPatch") << periodicPatchName_ - << token::END_STATEMENT << nl; - - if (nTransforms_ != 0) - { - os.writeKeyword("nTransforms") << nTransforms_ << - token::END_STATEMENT << nl; - } - - if (nSectors_ != 0) - { - os.writeKeyword("nSectors") << nSectors_ << - token::END_STATEMENT << nl; - } - - if (maxIter_ != 36) - { - os.writeKeyword("maxIter") << maxIter_ << token::END_STATEMENT << nl; - } + os.writeEntry("periodicPatch", periodicPatchName_); + os.writeEntryIfDifferent<label>("nTransforms", 0, nTransforms_); + os.writeEntryIfDifferent<label>("nSectors", 0, nSectors_); + os.writeEntryIfDifferent<label>("maxIter", 36, maxIter_); } diff --git a/src/meshTools/coordinateSystems/coordinateSystem.C b/src/meshTools/coordinateSystems/coordinateSystem.C index e8c507a7f84..b4a9e788200 100644 --- a/src/meshTools/coordinateSystems/coordinateSystem.C +++ b/src/meshTools/coordinateSystems/coordinateSystem.C @@ -297,25 +297,23 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const { if (subDict) { - os << indent << name_ << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock(name_); } - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); - - // The note entry is optional if (note_.size()) { - os.writeKeyword("note") << note_ << token::END_STATEMENT << nl; + // note is optional + os.writeEntry("note", note_); } - os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; + os.writeEntry("origin", origin_); R_->write(os); if (subDict) { - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 6f114e545b3..bf2a0801932 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -1432,8 +1432,7 @@ void Foam::mappedPatchBase::write(Ostream& os) const if (!surfDict_.empty()) { - os.writeKeyword(surfDict_.dictName()); - os << surfDict_; + surfDict_.writeEntry(surfDict_.dictName(), os); } } } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C index 6248dce6506..2a40a4695d6 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C @@ -167,7 +167,7 @@ Foam::mappedVariableThicknessWallPolyPatch:: void Foam::mappedVariableThicknessWallPolyPatch:: write(Foam::Ostream& os) const { - os.writeKeyword("thickness") << thickness_ << token::END_STATEMENT << nl; + os.writeEntry("thickness", thickness_); } diff --git a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C index bbdb866f94f..9defb4090bd 100644 --- a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C +++ b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C @@ -331,21 +331,17 @@ bool Foam::regionCoupledBase::order void Foam::regionCoupledBase::write(Ostream& os) const { - os.writeKeyword("neighbourPatch") << nbrPatchName_ - << token::END_STATEMENT << nl; - os.writeKeyword("neighbourRegion") << nbrRegionName_ - << token::END_STATEMENT << nl; + os.writeEntry("neighbourPatch", nbrPatchName_); + os.writeEntry("neighbourRegion", nbrRegionName_); if (AMIReverse_) { - os.writeKeyword("flipNormals") << AMIReverse_ - << token::END_STATEMENT << nl; + os.writeEntry("flipNormals", AMIReverse_); } if (!surfDict_.empty()) { - os.writeKeyword(surfDict_.dictName()); - os << surfDict_; + surfDict_.writeEntry(surfDict_.dictName(), os); } } diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C index dac63860b81..86680da8d99 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C @@ -384,28 +384,23 @@ void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "filmRegion", "surfaceFilmProperties", filmRegionName_ ); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "pyrolysisRegion", "pyrolysisProperties", pyrolysisRegionName_ ); - os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl; - os.writeKeyword("qr")<< qrName_ << token::END_STATEMENT << nl; - os.writeKeyword("convectiveScaling") << convectiveScaling_ - << token::END_STATEMENT << nl; - os.writeKeyword("filmDeltaDry") << filmDeltaDry_ - << token::END_STATEMENT << nl; - os.writeKeyword("filmDeltaWet") << filmDeltaWet_ - << token::END_STATEMENT << endl; + os.writeEntry("Tnbr", TnbrName_); + os.writeEntry("qr", qrName_); + os.writeEntry("convectiveScaling", convectiveScaling_); + os.writeEntry("filmDeltaDry", filmDeltaDry_); + os.writeEntry("filmDeltaWet", filmDeltaWet_); temperatureCoupledBase::write(os); } diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C index 3616268333e..6b1aee17452 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C @@ -186,22 +186,20 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "filmRegion", "surfaceFilmProperties", filmRegionName_ ); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "pyrolysisRegion", "pyrolysisProperties", pyrolysisRegionName_ ); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); writeEntry("value", os); } diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C index c5507e06a22..f4b4d445552 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C @@ -212,22 +212,20 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "filmRegion", "surfaceFilmProperties", filmRegionName_ ); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "pyrolysisRegion", "pyrolysisProperties", pyrolysisRegionName_ ); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); writeEntry("value", os); } diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C index 18a0bc751eb..a4c48dfb133 100644 --- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C +++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C @@ -132,9 +132,9 @@ void Foam::filmHeightInletVelocityFvPatchVectorField::updateCoeffs() void Foam::filmHeightInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<word>(os, "deltaf", "deltaf", deltafName_); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("deltaf", "deltaf", deltafName_); writeEntry("value", os); } diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C index e34296a1079..c2f1c552a5b 100644 --- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C +++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C @@ -192,9 +192,8 @@ void Foam::inclinedFilmNusseltHeightFvPatchScalarField::write ) const { fixedValueFvPatchScalarField::write(os); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "filmRegion", "surfaceFilmProperties", filmRegionName_ diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C index 3bbc164e0af..084e4ad6dfd 100644 --- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C +++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C @@ -191,9 +191,8 @@ void Foam::inclinedFilmNusseltInletVelocityFvPatchVectorField::write ) const { fvPatchVectorField::write(os); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "filmRegion", "surfaceFilmProperties", filmRegionName_ diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C index 09e76db86e9..f468aff4c6b 100644 --- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C +++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C @@ -237,18 +237,17 @@ void alphatFilmWallFunctionFvPatchScalarField::updateCoeffs() void alphatFilmWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "filmRegion", "surfaceFilmProperties", filmRegionName_ ); - os.writeKeyword("B") << B_ << token::END_STATEMENT << nl; - os.writeKeyword("yPlusCrit") << yPlusCrit_ << token::END_STATEMENT << nl; - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl; + os.writeEntry("B", B_); + os.writeEntry("yPlusCrit", yPlusCrit_); + os.writeEntry("Cmu", Cmu_); + os.writeEntry("kappa", kappa_); + os.writeEntry("Prt", Prt_); writeEntry("value", os); } diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C index b35804673e4..4b733d82680 100644 --- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C +++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C @@ -247,16 +247,15 @@ tmp<scalarField> nutkFilmWallFunctionFvPatchScalarField::yPlus() const void nutkFilmWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - writeEntryIfDifferent<word> + os.writeEntryIfDifferent<word> ( - os, "filmRegion", "surfaceFilmProperties", filmRegionName_ ); writeLocalEntries(os); - os.writeKeyword("B") << B_ << token::END_STATEMENT << nl; - os.writeKeyword("yPlusCrit") << yPlusCrit_ << token::END_STATEMENT << nl; + os.writeEntry("B", B_); + os.writeEntry("yPlusCrit", yPlusCrit_); writeEntry("value", os); } diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C index 58f78403985..9895f146bc1 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C @@ -285,11 +285,10 @@ void thermalBaffleFvPatchScalarField::write(Ostream& os) const os << dict_.subDict(extrudeModel) << nl; word regionName = dict_.lookup("region"); - os.writeKeyword("region") << regionName << token::END_STATEMENT << nl; + os.writeEntry("region", regionName); bool active = readBool(dict_.lookup("active")); - os.writeKeyword("active") << active - << token::END_STATEMENT << nl; + os.writeEntry("active", active); os.writeKeyword("thermoType"); os << dict_.subDict("thermoType") << nl; diff --git a/src/rigidBodyDynamics/bodies/cuboid/cuboid.C b/src/rigidBodyDynamics/bodies/cuboid/cuboid.C index 5309ae50b48..36f4cc4c1b1 100644 --- a/src/rigidBodyDynamics/bodies/cuboid/cuboid.C +++ b/src/rigidBodyDynamics/bodies/cuboid/cuboid.C @@ -62,14 +62,9 @@ Foam::RBD::cuboid::~cuboid() void Foam::RBD::cuboid::write(Ostream& os) const { - os.writeKeyword("type") - << type() << token::END_STATEMENT << nl; - - os.writeKeyword("mass") - << m() << token::END_STATEMENT << nl; - - os.writeKeyword("L") - << L() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); + os.writeEntry("mass", m()); + os.writeEntry("L", L()); } diff --git a/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C b/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C index 61e5b4bc757..ad5c7ed99a1 100644 --- a/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C +++ b/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C @@ -68,8 +68,7 @@ bool Foam::RBD::masslessBody::massless() const void Foam::RBD::masslessBody::write(Ostream& os) const { - os.writeKeyword("type") - << type() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); } diff --git a/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C b/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C index d13772c1000..51831470059 100644 --- a/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C +++ b/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C @@ -118,17 +118,10 @@ void Foam::RBD::rigidBody::merge(const subBody& subBody) void Foam::RBD::rigidBody::write(Ostream& os) const { - os.writeKeyword("type") - << type() << token::END_STATEMENT << nl; - - os.writeKeyword("mass") - << m() << token::END_STATEMENT << nl; - - os.writeKeyword("centreOfMass") - << c() << token::END_STATEMENT << nl; - - os.writeKeyword("inertia") - << Ic() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); + os.writeEntry("mass", m()); + os.writeEntry("centreOfMass", c()); + os.writeEntry("inertia", Ic()); } diff --git a/src/rigidBodyDynamics/bodies/sphere/sphere.C b/src/rigidBodyDynamics/bodies/sphere/sphere.C index ea4d13653e7..6e1c6b9b310 100644 --- a/src/rigidBodyDynamics/bodies/sphere/sphere.C +++ b/src/rigidBodyDynamics/bodies/sphere/sphere.C @@ -62,14 +62,9 @@ Foam::RBD::sphere::~sphere() void Foam::RBD::sphere::write(Ostream& os) const { - os.writeKeyword("type") - << type() << token::END_STATEMENT << nl; - - os.writeKeyword("mass") - << m() << token::END_STATEMENT << nl; - - os.writeKeyword("radius") - << r() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); + os.writeEntry("mass", m()); + os.writeEntry("radius", r()); } diff --git a/src/rigidBodyDynamics/bodies/subBody/subBody.C b/src/rigidBodyDynamics/bodies/subBody/subBody.C index 96924506beb..06586248ac8 100644 --- a/src/rigidBodyDynamics/bodies/subBody/subBody.C +++ b/src/rigidBodyDynamics/bodies/subBody/subBody.C @@ -29,11 +29,8 @@ License void Foam::RBD::subBody::write(Ostream& os) const { - os.writeKeyword("master") - << masterName_ << token::END_STATEMENT << nl; - - os.writeKeyword("transform") - << masterXT_ << token::END_STATEMENT << nl; + os.writeEntry("master", masterName_); + os.writeEntry("transform", masterXT_); } diff --git a/src/rigidBodyDynamics/joints/Pa/Pa.C b/src/rigidBodyDynamics/joints/Pa/Pa.C index b30997acadf..30cc3711e30 100644 --- a/src/rigidBodyDynamics/joints/Pa/Pa.C +++ b/src/rigidBodyDynamics/joints/Pa/Pa.C @@ -98,8 +98,7 @@ void Foam::RBD::joints::Pa::jcalc void Foam::RBD::joints::Pa::write(Ostream& os) const { joint::write(os); - os.writeKeyword("axis") - << S_[0].l() << token::END_STATEMENT << nl; + os.writeEntry("axis", S_[0].l()); } diff --git a/src/rigidBodyDynamics/joints/Ra/Ra.C b/src/rigidBodyDynamics/joints/Ra/Ra.C index 468985ea67c..df4f9048d65 100644 --- a/src/rigidBodyDynamics/joints/Ra/Ra.C +++ b/src/rigidBodyDynamics/joints/Ra/Ra.C @@ -98,8 +98,7 @@ void Foam::RBD::joints::Ra::jcalc void Foam::RBD::joints::Ra::write(Ostream& os) const { joint::write(os); - os.writeKeyword("axis") - << S_[0].w() << token::END_STATEMENT << nl; + os.writeEntry("axis", S_[0].w()); } diff --git a/src/rigidBodyDynamics/joints/joint/joint.C b/src/rigidBodyDynamics/joints/joint/joint.C index 92204ffebd8..6448bb6f8b8 100644 --- a/src/rigidBodyDynamics/joints/joint/joint.C +++ b/src/rigidBodyDynamics/joints/joint/joint.C @@ -79,7 +79,7 @@ Foam::RBD::joint::~joint() void Foam::RBD::joint::write(Ostream& os) const { - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; + os.writeEntry("type", type()); } diff --git a/src/rigidBodyDynamics/joints/joint/jointI.H b/src/rigidBodyDynamics/joints/joint/jointI.H index eb6e36a2ca8..de655ff6c55 100644 --- a/src/rigidBodyDynamics/joints/joint/jointI.H +++ b/src/rigidBodyDynamics/joints/joint/jointI.H @@ -112,9 +112,9 @@ Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::iNew::operator() inline Foam::Ostream& Foam::RBD::operator<<(Ostream& os, const joint& j) { - os << indent << token::BEGIN_BLOCK << incrIndent << endl; + os.beginBlock(); j.write(os); - os << decrIndent << indent << token::END_BLOCK; + os.endBlock(); return os; } diff --git a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C index 8f0b6143e5c..379a69c4f4e 100644 --- a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C +++ b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C @@ -184,17 +184,10 @@ void Foam::RBD::restraints::linearAxialAngularSpring::write { restraint::write(os); - os.writeKeyword("referenceOrientation") - << refQ_ << token::END_STATEMENT << nl; - - os.writeKeyword("axis") - << axis_ << token::END_STATEMENT << nl; - - os.writeKeyword("stiffness") - << stiffness_ << token::END_STATEMENT << nl; - - os.writeKeyword("damping") - << damping_ << token::END_STATEMENT << nl; + os.writeEntry("referenceOrientation", refQ_); + os.writeEntry("axis", axis_); + os.writeEntry("stiffness", stiffness_); + os.writeEntry("damping", damping_); } diff --git a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C index d3e4e063da4..b15c39cb4dc 100644 --- a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C +++ b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C @@ -109,8 +109,7 @@ void Foam::RBD::restraints::linearDamper::write { restraint::write(os); - os.writeKeyword("coeff") - << coeff_ << token::END_STATEMENT << nl; + os.writeEntry("coeff", coeff_); } diff --git a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C index 9449d60042d..189a7e9a9b4 100644 --- a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C +++ b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C @@ -134,20 +134,11 @@ void Foam::RBD::restraints::linearSpring::write { restraint::write(os); - os.writeKeyword("anchor") - << anchor_ << token::END_STATEMENT << nl; - - os.writeKeyword("refAttachmentPt") - << refAttachmentPt_ << token::END_STATEMENT << nl; - - os.writeKeyword("stiffness") - << stiffness_ << token::END_STATEMENT << nl; - - os.writeKeyword("damping") - << damping_ << token::END_STATEMENT << nl; - - os.writeKeyword("restLength") - << restLength_ << token::END_STATEMENT << nl; + os.writeEntry("anchor", anchor_); + os.writeEntry("refAttachmentPt", refAttachmentPt_); + os.writeEntry("stiffness", stiffness_); + os.writeEntry("damping", damping_); + os.writeEntry("restLength", restLength_); } diff --git a/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C b/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C index be56e7b0842..229e64ae3f5 100644 --- a/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C +++ b/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C @@ -78,10 +78,8 @@ bool Foam::RBD::restraint::read(const dictionary& dict) void Foam::RBD::restraint::write(Ostream& os) const { - os.writeKeyword("type") - << type() << token::END_STATEMENT << nl; - os.writeKeyword("body") - << model_.name(bodyID_) << token::END_STATEMENT << nl; + os.writeEntry("type", type()); + os.writeEntry("body", model_.name(bodyID_)); } diff --git a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C index 8ef17486b78..441bfafc1f9 100644 --- a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C +++ b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C @@ -109,7 +109,7 @@ void Foam::RBD::restraints::sphericalAngularDamper::write { restraint::write(os); - os.writeKeyword("coeff") << coeff_ << token::END_STATEMENT << nl; + os.writeEntry("coeff", coeff_); } diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C index 4a8de4eac4d..1fbe3fc60e9 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C +++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C @@ -377,17 +377,14 @@ Foam::spatialTransform Foam::RBD::rigidBodyModel::X0 const subBody& mBody = mergedBody(bodyId); return mBody.masterXT() & X0_[mBody.masterID()]; } - else - { - return X0_[bodyId]; - } + + return X0_[bodyId]; } void Foam::RBD::rigidBodyModel::write(Ostream& os) const { - os << indent << "bodies" << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("bodies"); // Write the moving bodies for (label i=1; i<nBodies(); i++) @@ -396,61 +393,52 @@ void Foam::RBD::rigidBodyModel::write(Ostream& os) const // of composite joints if (!isType<jointBody>(bodies_[i])) { - os << indent << bodies_[i].name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << endl; + os.beginBlock(bodies_[i].name()); bodies_[i].write(os); - os.writeKeyword("parent") - << bodies_[lambda_[i]].name() << token::END_STATEMENT << nl; - - os.writeKeyword("transform") - << XT_[i] << token::END_STATEMENT << nl; + os.writeEntry("parent", bodies_[lambda_[i]].name()); + os.writeEntry("transform", XT_[i]); - os << indent << "joint" << nl << joints_[i] << endl; + os << indent << "joint" << nl + << joints_[i] << endl; - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } } // Write the bodies merged into the parent bodies for efficiency forAll(mergedBodies_, i) { - os << indent << mergedBodies_[i].name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << endl; + os.beginBlock(mergedBodies_[i].name()); mergedBodies_[i].body().write(os); - os.writeKeyword("transform") - << mergedBodies_[i].masterXT() << token::END_STATEMENT << nl; - - os.writeKeyword("mergeWith") - << mergedBodies_[i].masterName() << token::END_STATEMENT << nl; + os.writeEntry("transform", mergedBodies_[i].masterXT()); + os.writeEntry("mergeWith", mergedBodies_[i].masterName()); - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); if (!restraints_.empty()) { - os << indent << "restraints" << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("restraints"); forAll(restraints_, ri) { - word restraintType = restraints_[ri].type(); + const word& restraintType(restraints_[ri].type()); - os << indent << restraints_[ri].name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << endl; + os.beginBlock(restraints_[ri].name()); restraints_[ri].write(os); - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); } } diff --git a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C index 038d42a31a0..66a7418cd51 100644 --- a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C +++ b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C @@ -39,10 +39,10 @@ void Foam::RBD::rigidBodyModelState::write(dictionary& dict) const void Foam::RBD::rigidBodyModelState::write(Ostream& os) const { - os.writeKeyword("q") << q_ << token::END_STATEMENT << nl; - os.writeKeyword("qDot") << qDot_ << token::END_STATEMENT << nl; - os.writeKeyword("qDdot") << qDdot_ << token::END_STATEMENT << nl; - os.writeKeyword("deltaT") << deltaT_ << token::END_STATEMENT << nl; + os.writeEntry("q", q_); + os.writeEntry("qDot", qDot_); + os.writeEntry("qDdot", qDdot_); + os.writeEntry("deltaT", deltaT_); } diff --git a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C index 915af7f56f1..eed9c95b468 100644 --- a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C +++ b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C @@ -44,12 +44,9 @@ void Foam::RBD::rigidBodyMotion::write(Ostream& os) const { rigidBodyModel::write(os); - os.writeKeyword("accelerationRelaxation") - << aRelax_ << token::END_STATEMENT << nl; - os.writeKeyword("accelerationDamping") - << aDamp_ << token::END_STATEMENT << nl; - os.writeKeyword("report") - << report_ << token::END_STATEMENT << nl; + os.writeEntry("accelerationRelaxation", aRelax_); + os.writeEntry("accelerationDamping", aDamp_); + os.writeEntry("report", report_); } diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C index daeb9adf8d9..e1508439b6e 100644 --- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -255,16 +255,16 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const { pointPatchField<vector>::write(os); - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + os.writeEntry("rho", rhoName_); if (rhoName_ == "rhoInf") { - os.writeKeyword("rhoInf") << rhoInf_ << token::END_STATEMENT << nl; + os.writeEntry("rhoInf", rhoInf_); } if (lookupGravity_ == 0 || lookupGravity_ == -2) { - os.writeKeyword("g") << g_ << token::END_STATEMENT << nl; + os.writeEntry("g", g_); } motion_.write(os); diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C index 985d7ae4caa..0650986bfd2 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C @@ -116,8 +116,7 @@ void Foam::sixDoFRigidBodyMotionConstraints::axis::write Ostream& os ) const { - os.writeKeyword("axis") - << axis_ << token::END_STATEMENT << nl; + os.writeEntry("axis", axis_); } // ************************************************************************* // diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C index 7e7189b0d1d..6da64ea471b 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C @@ -130,10 +130,8 @@ void Foam::sixDoFRigidBodyMotionConstraints::line::write Ostream& os ) const { - os.writeKeyword("centreOfRotation") - << centreOfRotation_ << token::END_STATEMENT << nl; - os.writeKeyword("direction") - << direction_ << token::END_STATEMENT << nl; + os.writeEntry("centreOfRotation", centreOfRotation_); + os.writeEntry("direction", direction_); } // ************************************************************************* // diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C index 7c291dee64c..90190f2c63f 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C @@ -117,10 +117,8 @@ void Foam::sixDoFRigidBodyMotionConstraints::plane::write Ostream& os ) const { - os.writeKeyword("centreOfRotation") - << centreOfRotation_ << token::END_STATEMENT << nl; - os.writeKeyword("normal") - << normal_ << token::END_STATEMENT << nl; + os.writeEntry("centreOfRotation", centreOfRotation_); + os.writeEntry("normal", normal_); } // ************************************************************************* // diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C index 32021c07476..5fc63648f20 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C @@ -116,8 +116,7 @@ void Foam::sixDoFRigidBodyMotionConstraints::point::write Ostream& os ) const { - os.writeKeyword("centreOfRotation") - << centreOfRotation_ << token::END_STATEMENT << nl; + os.writeEntry("centreOfRotation", centreOfRotation_); } // ************************************************************************* // diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C index 2237bf6963c..8575a52e774 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C @@ -186,17 +186,10 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::write Ostream& os ) const { - os.writeKeyword("referenceOrientation") - << refQ_ << token::END_STATEMENT << nl; - - os.writeKeyword("axis") - << axis_ << token::END_STATEMENT << nl; - - os.writeKeyword("stiffness") - << stiffness_ << token::END_STATEMENT << nl; - - os.writeKeyword("damping") - << damping_ << token::END_STATEMENT << nl; + os.writeEntry("referenceOrientation", refQ_); + os.writeEntry("axis", axis_); + os.writeEntry("stiffness", stiffness_); + os.writeEntry("damping", damping_); } // ************************************************************************* // diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C index 5d70d4db112..1e6d31ce8ea 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C @@ -105,8 +105,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearDamper::write Ostream& os ) const { - os.writeKeyword("coeff") - << coeff_ << token::END_STATEMENT << nl; + os.writeEntry("coeff", coeff_); } diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C index 40b19b2006c..c993c4d8143 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C @@ -125,20 +125,11 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::write Ostream& os ) const { - os.writeKeyword("anchor") - << anchor_ << token::END_STATEMENT << nl; - - os.writeKeyword("refAttachmentPt") - << refAttachmentPt_ << token::END_STATEMENT << nl; - - os.writeKeyword("stiffness") - << stiffness_ << token::END_STATEMENT << nl; - - os.writeKeyword("damping") - << damping_ << token::END_STATEMENT << nl; - - os.writeKeyword("restLength") - << restLength_ << token::END_STATEMENT << nl; + os.writeEntry("anchor", anchor_); + os.writeEntry("refAttachmentPt", refAttachmentPt_); + os.writeEntry("stiffness", stiffness_); + os.writeEntry("damping", damping_); + os.writeEntry("restLength", restLength_); } // ************************************************************************* // diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C index f0731256666..27f890590a0 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C @@ -107,7 +107,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularDamper::write Ostream& os ) const { - os.writeKeyword("coeff") << coeff_ << token::END_STATEMENT << nl; + os.writeEntry("coeff", coeff_); } diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C index aa012153ce9..35db712d8f4 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C @@ -145,12 +145,9 @@ void Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::write Ostream& os ) const { - os.writeKeyword("referenceOrientation") - << refQ_ << token::END_STATEMENT << nl; - - os.writeKeyword("stiffness") << stiffness_ << token::END_STATEMENT << nl; - - os.writeKeyword("damping") << damping_ << token::END_STATEMENT << nl; + os.writeEntry("referenceOrientation", refQ_); + os.writeEntry("stiffness", stiffness_); + os.writeEntry("damping", damping_); } diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C index 000ca2618f3..601184e0a5d 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C @@ -205,27 +205,21 @@ void Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::write Ostream& os ) const { - os.writeKeyword("referenceOrientation") - << refQ_ << token::END_STATEMENT << nl; - - os.writeKeyword("axis") - << axis_ << token::END_STATEMENT << nl; + os.writeEntry("referenceOrientation", refQ_); + os.writeEntry("axis", axis_); moment_.write(os); - os.writeKeyword("angleFormat"); - if (convertToDegrees_) { - os << "degrees" << token::END_STATEMENT << nl; + os.writeEntry("angleFormat", "degrees"); } else { - os << "radians" << token::END_STATEMENT << nl; + os.writeEntry("angleFormat", "radians"); } - os.writeKeyword("damping") - << damping_ << token::END_STATEMENT << nl; + os.writeEntry("damping", damping_); } diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C index e04a11d4788..4b54e45b175 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C @@ -51,67 +51,54 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const { motionState_.write(os); - os.writeKeyword("centreOfMass") - << initialCentreOfMass_ << token::END_STATEMENT << nl; - os.writeKeyword("initialOrientation") - << initialQ_ << token::END_STATEMENT << nl; - os.writeKeyword("mass") - << mass_ << token::END_STATEMENT << nl; - os.writeKeyword("momentOfInertia") - << momentOfInertia_ << token::END_STATEMENT << nl; - os.writeKeyword("accelerationRelaxation") - << aRelax_ << token::END_STATEMENT << nl; - os.writeKeyword("accelerationDamping") - << aDamp_ << token::END_STATEMENT << nl; - os.writeKeyword("report") - << report_ << token::END_STATEMENT << nl; + os.writeEntry("centreOfMass", initialCentreOfMass_); + os.writeEntry("initialOrientation", initialQ_); + os.writeEntry("mass", mass_); + os.writeEntry("momentOfInertia", momentOfInertia_); + os.writeEntry("accelerationRelaxation", aRelax_); + os.writeEntry("accelerationDamping", aDamp_); + os.writeEntry("report", report_); if (!restraints_.empty()) { - os << indent << "restraints" << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("restraints"); forAll(restraints_, rI) { - word restraintType = restraints_[rI].type(); + const word& restraintType(restraints_[rI].type()); - os << indent << restraints_[rI].name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << endl; + os.beginBlock(restraints_[rI].name()); - os.writeKeyword("sixDoFRigidBodyMotionRestraint") - << restraintType << token::END_STATEMENT << nl; + os.writeEntry("sixDoFRigidBodyMotionRestraint", restraintType); restraints_[rI].write(os); - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); } if (!constraints_.empty()) { - os << indent << "constraints" << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("constraints"); forAll(constraints_, rI) { - word constraintType = constraints_[rI].type(); + const word& constraintType(constraints_[rI].type()); - os << indent << constraints_[rI].name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << endl; + os.beginBlock(constraints_[rI].name()); - os.writeKeyword("sixDoFRigidBodyMotionConstraint") - << constraintType << token::END_STATEMENT << nl; + os.writeEntry("sixDoFRigidBodyMotionConstraint", constraintType); constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os); constraints_[rI].write(os); - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } - os << decrIndent << indent << token::END_BLOCK << nl; + os.endBlock(); } if (!solver_.empty()) diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C index e24f81f448c..3924adde78c 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C @@ -41,18 +41,12 @@ void Foam::sixDoFRigidBodyMotionState::write(dictionary& dict) const void Foam::sixDoFRigidBodyMotionState::write(Ostream& os) const { - os.writeKeyword("centreOfRotation") - << centreOfRotation_ << token::END_STATEMENT << nl; - os.writeKeyword("orientation") - << Q_ << token::END_STATEMENT << nl; - os.writeKeyword("velocity") - << v_ << token::END_STATEMENT << nl; - os.writeKeyword("acceleration") - << a_ << token::END_STATEMENT << nl; - os.writeKeyword("angularMomentum") - << pi_ << token::END_STATEMENT << nl; - os.writeKeyword("torque") - << tau_ << token::END_STATEMENT << nl; + os.writeEntry("centreOfRotation", centreOfRotation_); + os.writeEntry("orientation", Q_); + os.writeEntry("velocity", v_); + os.writeEntry("acceleration", a_); + os.writeEntry("angularMomentum", pi_); + os.writeEntry("torque", tau_); } diff --git a/src/surfMesh/surfZone/surfZone/surfZone.C b/src/surfMesh/surfZone/surfZone/surfZone.C index e2699243b5c..b51cdcf60bf 100644 --- a/src/surfMesh/surfZone/surfZone/surfZone.C +++ b/src/surfMesh/surfZone/surfZone/surfZone.C @@ -112,14 +112,13 @@ void Foam::surfZone::write(Ostream& os) const void Foam::surfZone::writeDict(Ostream& os) const { - os << indent << name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock(name()); surfZoneIdentifier::write(os); - os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl; - os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl; + os.writeEntry("nFaces", size()); + os.writeEntry("startFace", start()); - os << decrIndent << indent << token::END_BLOCK << endl; + os.endBlock(); } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C index 751e1ece9e5..f6935495813 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C @@ -187,7 +187,7 @@ void Foam::radiation::MarshakRadiationFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "T", "T", TName_); + os.writeEntryIfDifferent<word>("T", "T", TName_); } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C index 70423f1a722..ca42809813e 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -248,8 +248,8 @@ void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "T", "T", TName_); - os.writeKeyword("solarLoad") << solarLoad_ << token::END_STATEMENT << nl; + os.writeEntryIfDifferent<word>("T", "T", TName_); + os.writeEntry("solarLoad", solarLoad_); } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C index 44e347f28c9..f7adff2068e 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C @@ -192,7 +192,7 @@ write { fixedValueFvPatchScalarField::write(os); qro_.writeEntry("qro", os); - os.writeKeyword("solarLoad") << solarLoad_ << token::END_STATEMENT << nl; + os.writeEntry("solarLoad", solarLoad_); } diff --git a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C index 18d2a9367c8..da945226ce3 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C +++ b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C @@ -112,8 +112,7 @@ template<class ReactionThermo> void Foam::solidReaction<ReactionThermo>::write(Ostream& os) const { OStringStream reaction; - os.writeKeyword("reaction") << solidReactionStr(reaction) - << token::END_STATEMENT << nl; + os.writeEntry("reaction", solidReactionStr(reaction)); } diff --git a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H index 9bad3ba7784..897904f5073 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H +++ b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H @@ -40,7 +40,7 @@ inline Ostream& operator<< ) { OStringStream reaction; - os << r.solidReactionStr(reaction)<< token::END_STATEMENT <<nl; + os << r.solidReactionStr(reaction) << token::END_STATEMENT <<nl; return os; } diff --git a/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H b/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H index 1ab4bcb50dd..b9e86890473 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H +++ b/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H @@ -77,9 +77,9 @@ inline Foam::scalar Foam::solidArrheniusReactionRate::operator() inline void Foam::solidArrheniusReactionRate::write(Ostream& os) const { - os.writeKeyword("A") << A_ << token::END_STATEMENT << nl; - os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl; - os.writeKeyword("Tcrit") << Tcrit_ << token::END_STATEMENT << nl; + os.writeEntry("A", A_); + os.writeEntry("Ta", Ta_); + os.writeEntry("Tcrit", Tcrit_); } diff --git a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C index 255cf2b93fd..2911baca562 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C @@ -196,19 +196,13 @@ void Foam::NonEquilibriumReversibleReaction { ReactionType<ReactionThermo>::write(os); - os << indent << "forward" << nl; - os << indent << token::BEGIN_BLOCK << nl; - os << incrIndent; + os.beginBlock("forward"); fk_.write(os); - os << decrIndent; - os << indent << token::END_BLOCK << nl; + os.endBlock(); - os << indent << "reverse" << nl; - os << indent << token::BEGIN_BLOCK << nl; - os << incrIndent; + os.beginBlock("reverse"); rk_.write(os); - os << decrIndent; - os << indent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C index 5da2f878c4b..913f11a712b 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C @@ -386,8 +386,7 @@ template<class ReactionThermo> void Foam::Reaction<ReactionThermo>::write(Ostream& os) const { OStringStream reaction; - os.writeKeyword("reaction") << reactionStr(reaction) - << token::END_STATEMENT << nl; + os.writeEntry("reaction", reactionStr(reaction)); } diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C index 6d3f2539fc3..f2a1e0c698d 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C @@ -106,20 +106,21 @@ bool Foam::ReactionList<ThermoType>::readReactionDict() template<class ThermoType> void Foam::ReactionList<ThermoType>::write(Ostream& os) const { - os << "reactions" << nl; - os << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock("reactions"); forAllConstIter(typename SLPtrList<Reaction<ThermoType>>, *this, iter) { const Reaction<ThermoType>& r = iter(); - os << indent << r.name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; - os.writeKeyword("type") << r.type() << token::END_STATEMENT << nl; + + os.beginBlock(r.name()); + + os.writeEntry("type", r.type()); r.write(os); - os << decrIndent << indent << token::END_BLOCK << nl; + + os.endBlock(); } - os << decrIndent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H index 49ec48c71e4..75bed82ef27 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H @@ -77,9 +77,9 @@ inline Foam::scalar Foam::ArrheniusReactionRate::operator() inline void Foam::ArrheniusReactionRate::write(Ostream& os) const { - os.writeKeyword("A") << A_ << token::END_STATEMENT << nl; - os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl; - os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl; + os.writeEntry("A", A_); + os.writeEntry("beta", beta_); + os.writeEntry("Ta", Ta_); } diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H index fff348d4810..1ff54cd5f43 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H @@ -68,10 +68,10 @@ Foam::FallOffReactionRate<ReactionRate, FallOffFunction>::operator() const scalarField& c ) const { - scalar k0 = k0_(p, T, c); - scalar kInf = kInf_(p, T, c); + const scalar k0 = k0_(p, T, c); + const scalar kInf = kInf_(p, T, c); - scalar Pr = k0*thirdBodyEfficiencies_.M(c)/kInf; + const scalar Pr = k0*thirdBodyEfficiencies_.M(c)/kInf; return kInf*(Pr/(1 + Pr))*F_(T, Pr); } @@ -83,33 +83,21 @@ inline void Foam::FallOffReactionRate<ReactionRate, FallOffFunction>::write Ostream& os ) const { - os << indent << "k0" << nl; - os << indent << token::BEGIN_BLOCK << nl; - os << incrIndent; + os.beginBlock("k0"); k0_.write(os); - os << decrIndent; - os << indent << token::END_BLOCK << nl; + os.endBlock(); - os << indent << "kInf" << nl; - os << indent << token::BEGIN_BLOCK << nl; - os << incrIndent; + os.beginBlock("kInf"); kInf_.write(os); - os << decrIndent; - os << indent << token::END_BLOCK << nl; + os.endBlock(); - os << indent << "F" << nl; - os << indent << token::BEGIN_BLOCK << nl; - os << incrIndent; + os.beginBlock("F"); F_.write(os); - os << decrIndent; - os << indent << token::END_BLOCK << nl; + os.endBlock(); - os << indent << "thirdBodyEfficiencies" << nl; - os << indent << token::BEGIN_BLOCK << nl; - os << incrIndent; + os.beginBlock("thirdBodyEfficiencies"); thirdBodyEfficiencies_.write(os); - os << decrIndent; - os << indent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H index 7d2c9ecd791..992b3d9ea42 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H @@ -100,11 +100,11 @@ inline Foam::scalar Foam::LandauTellerReactionRate::operator() inline void Foam::LandauTellerReactionRate::write(Ostream& os) const { - os.writeKeyword("A") << A_ << token::END_STATEMENT << nl; - os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl; - os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl; - os.writeKeyword("B") << B_ << token::END_STATEMENT << nl; - os.writeKeyword("C") << C_ << token::END_STATEMENT << nl; + os.writeEntry("A", A_); + os.writeEntry("beta", beta_); + os.writeEntry("Ta", Ta_); + os.writeEntry("B", B_); + os.writeEntry("C", C_); } diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H index 68cce0350da..58975727b4e 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H @@ -67,11 +67,11 @@ inline Foam::scalar Foam::SRIFallOffFunction::operator() inline void Foam::SRIFallOffFunction::write(Ostream& os) const { - os.writeKeyword("a") << a_ << token::END_STATEMENT << nl; - os.writeKeyword("b") << b_ << token::END_STATEMENT << nl; - os.writeKeyword("c") << c_ << token::END_STATEMENT << nl; - os.writeKeyword("d") << d_ << token::END_STATEMENT << nl; - os.writeKeyword("e") << e_ << token::END_STATEMENT << nl; + os.writeEntry("a", a_); + os.writeEntry("b", b_); + os.writeEntry("c", c_); + os.writeEntry("d", d_); + os.writeEntry("e", e_); } diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H index 1913985c18d..ab654e2103e 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H @@ -77,10 +77,10 @@ inline Foam::scalar Foam::TroeFallOffFunction::operator() inline void Foam::TroeFallOffFunction::write(Ostream& os) const { - os.writeKeyword("alpha") << alpha_ << token::END_STATEMENT << nl; - os.writeKeyword("Tsss") << Tsss_ << token::END_STATEMENT << nl; - os.writeKeyword("Ts") << Ts_ << token::END_STATEMENT << nl; - os.writeKeyword("Tss") << Tss_ << token::END_STATEMENT << nl; + os.writeEntry("alpha", alpha_); + os.writeEntry("Tsss", Tsss_); + os.writeEntry("Ts", Ts_); + os.writeEntry("Tss", Tss_); } diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H index fcf9b808c3b..40dd2680032 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H @@ -84,10 +84,10 @@ inline Foam::scalar Foam::powerSeriesReactionRate::operator() inline void Foam::powerSeriesReactionRate::write(Ostream& os) const { - os.writeKeyword("A") << A_ << token::END_STATEMENT << nl; - os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl; - os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl; - os.writeKeyword("coeffs") << coeffs_ << token::END_STATEMENT << nl; + os.writeEntry("A", A_); + os.writeEntry("beta", beta_); + os.writeEntry("Ta", Ta_); + os.writeEntry("coeffs", coeffs_); } diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H b/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H index 97a0e8eeed9..bcec76284b9 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H @@ -102,7 +102,7 @@ inline void Foam::thirdBodyEfficiencies::write(Ostream& os) const coeffs[i].second() = operator[](i); } - os.writeKeyword("coeffs") << coeffs << token::END_STATEMENT << nl; + os.writeEntry("coeffs", coeffs); } diff --git a/src/thermophysicalModels/specie/transport/const/constTransport.C b/src/thermophysicalModels/specie/transport/const/constTransport.C index 8b709c9c821..2408dfb9cc6 100644 --- a/src/thermophysicalModels/specie/transport/const/constTransport.C +++ b/src/thermophysicalModels/specie/transport/const/constTransport.C @@ -42,17 +42,19 @@ Foam::constTransport<Thermo>::constTransport(const dictionary& dict) template<class Thermo> void Foam::constTransport<Thermo>::constTransport::write(Ostream& os) const { - os << this->name() << endl; - os << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock(this->name()); Thermo::write(os); - dictionary dict("transport"); - dict.add("mu", mu_); - dict.add("Pr", 1.0/rPr_); - os << indent << dict.dictName() << dict; + // Entries in dictionary format + { + os.beginBlock("transport"); + os.writeEntry("mu", mu_); + os.writeEntry("Pr", scalar(1.0/rPr_)); + os.endBlock(); + } - os << decrIndent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C index 27366f28931..b35e2003df6 100644 --- a/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C +++ b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C @@ -57,25 +57,27 @@ Foam::logPolynomialTransport<Thermo, PolySize>::logPolynomialTransport template<class Thermo, int PolySize> void Foam::logPolynomialTransport<Thermo, PolySize>::write(Ostream& os) const { - os << this->name() << endl; - os << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock(this->name()); Thermo::write(os); - dictionary dict("transport"); - dict.add - ( - word("muLogCoeffs<" + Foam::name(PolySize) + '>'), - muCoeffs_ - ); - dict.add - ( - word("kappaLogCoeffs<" + Foam::name(PolySize) + '>'), - kappaCoeffs_ - ); - os << indent << dict.dictName() << dict; + // Entries in dictionary format + { + os.beginBlock("transport"); + os.writeEntry + ( + word("muLogCoeffs<" + Foam::name(PolySize) + '>'), + muCoeffs_ + ); + os.writeEntry + ( + word("kappaLogCoeffs<" + Foam::name(PolySize) + '>'), + kappaCoeffs_ + ); + os.endBlock(); + } - os << decrIndent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C index cb907dd01d5..88331a715ca 100644 --- a/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C +++ b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C @@ -57,25 +57,27 @@ Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport template<class Thermo, int PolySize> void Foam::polynomialTransport<Thermo, PolySize>::write(Ostream& os) const { - os << this->name() << endl; - os << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock(this->name()); Thermo::write(os); - dictionary dict("transport"); - dict.add - ( - word("muCoeffs<" + Foam::name(PolySize) + '>'), - muCoeffs_ - ); - dict.add - ( - word("kappaCoeffs<" + Foam::name(PolySize) + '>'), - kappaCoeffs_ - ); - os << indent << dict.dictName() << dict; + // Entries in dictionary format + { + os.beginBlock("transport"); + os.writeEntry + ( + word("muCoeffs<" + Foam::name(PolySize) + '>'), + muCoeffs_ + ); + os.writeEntry + ( + word("kappaCoeffs<" + Foam::name(PolySize) + '>'), + kappaCoeffs_ + ); + os.endBlock(); + } - os << decrIndent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C index 1fa07890149..d3576c52ee3 100644 --- a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C +++ b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C @@ -68,17 +68,19 @@ Foam::sutherlandTransport<Thermo>::sutherlandTransport template<class Thermo> void Foam::sutherlandTransport<Thermo>::write(Ostream& os) const { - os << this->specie::name() << endl - << token::BEGIN_BLOCK << incrIndent << nl; + os.beginBlock(this->specie::name()); Thermo::write(os); - dictionary dict("transport"); - dict.add("As", As_); - dict.add("Ts", Ts_); + // Entries in dictionary format + { + os.beginBlock("transport"); + os.writeEntry("As", As_); + os.writeEntry("Ts", Ts_); + os.endBlock(); + } - os << indent << dict.dictName() << dict - << decrIndent << token::END_BLOCK << nl; + os.endBlock(); } diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C index e12b63b7253..3f7bf842d0d 100644 --- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C @@ -727,19 +727,19 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "p", "p", pName_); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_); - writeEntryIfDifferent<word>(os, "Tnbr", "T", TnbrName_); - writeEntryIfDifferent<word>(os, "qrNbr", "none", qrNbrName_); - writeEntryIfDifferent<word>(os, "qr", "none", qrName_); + os.writeEntryIfDifferent<word>("p", "p", pName_); + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_); + os.writeEntryIfDifferent<word>("Tnbr", "T", TnbrName_); + os.writeEntryIfDifferent<word>("qrNbr", "none", qrNbrName_); + os.writeEntryIfDifferent<word>("qr", "none", qrName_); if (fluid_) { os.writeEntry("mode", massModeTypeNames_[mode_]); - writeEntryIfDifferent<word>(os, "specie", "none", specieName_); + os.writeEntryIfDifferent<word>("specie", "none", specieName_); os.writeEntry("carrierMolWeight", Mcomp_); diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C index 9a19092e046..58593465835 100644 --- a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C +++ b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C @@ -106,10 +106,8 @@ bool Foam::surfaceTensionModels::constant::writeData(Ostream& os) const os << sigma_ << token::END_STATEMENT << nl; return os.good(); } - else - { - return false; - } + + return false; } diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C index 03fb3a106c7..0cf8f63b8bf 100644 --- a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C +++ b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C @@ -128,10 +128,8 @@ bool Foam::surfaceTensionModels::temperatureDependent::writeData os << sigma_() << token::END_STATEMENT << nl; return os.good(); } - else - { - return false; - } + + return false; } diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C index c94e36ce778..4594202d38c 100644 --- a/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C +++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C @@ -113,7 +113,7 @@ void Foam::constantAlphaContactAngleFvPatchScalarField::write ) const { alphaContactAngleFvPatchScalarField::write(os); - os.writeKeyword("theta0") << theta0_ << token::END_STATEMENT << nl; + os.writeEntry("theta0", theta0_); writeEntry("value", os); } diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C index b4a9db0062a..e488fcd9ebb 100644 --- a/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C +++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C @@ -146,10 +146,10 @@ Foam::dynamicAlphaContactAngleFvPatchScalarField::theta void Foam::dynamicAlphaContactAngleFvPatchScalarField::write(Ostream& os) const { alphaContactAngleFvPatchScalarField::write(os); - os.writeKeyword("theta0") << theta0_ << token::END_STATEMENT << nl; - os.writeKeyword("uTheta") << uTheta_ << token::END_STATEMENT << nl; - os.writeKeyword("thetaA") << thetaA_ << token::END_STATEMENT << nl; - os.writeKeyword("thetaR") << thetaR_ << token::END_STATEMENT << nl; + os.writeEntry("theta0", theta0_); + os.writeEntry("uTheta", uTheta_); + os.writeEntry("thetaA", thetaA_); + os.writeEntry("thetaR", thetaR_); writeEntry("value", os); } diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C index 5eba3cc0b6c..8dfa30a477c 100644 --- a/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C +++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C @@ -121,7 +121,7 @@ void Foam::temperatureDependentAlphaContactAngleFvPatchScalarField::write ) const { alphaContactAngleFvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "T", "T", TName_); + os.writeEntryIfDifferent<word>("T", "T", TName_); theta0_->writeData(os); writeEntry("value", os); } diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C index d014b1c6fcd..3ed663eb687 100644 --- a/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C +++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C @@ -131,10 +131,10 @@ void Foam::timeVaryingAlphaContactAngleFvPatchScalarField::write ) const { alphaContactAngleFvPatchScalarField::write(os); - os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl; - os.writeKeyword("thetaT0") << thetaT0_ << token::END_STATEMENT << nl; - os.writeKeyword("te") << te_ << token::END_STATEMENT << nl; - os.writeKeyword("thetaTe") << thetaTe_ << token::END_STATEMENT << nl; + os.writeEntry("t0", t0_); + os.writeEntry("thetaT0", thetaT0_); + os.writeEntry("te", te_); + os.writeEntry("thetaTe", thetaTe_); writeEntry("value", os); } diff --git a/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C b/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C index 6117513bc99..4e57fcba84f 100644 --- a/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C +++ b/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C @@ -120,8 +120,7 @@ void Foam::waveAlphaFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); - os.writeKeyword("waveDictName") << waveDictName_ - << token::END_STATEMENT << nl; + os.writeEntry("waveDictName", waveDictName_); writeEntry("value", os); } diff --git a/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C b/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C index a237aabbc17..83fa6c64eae 100644 --- a/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C +++ b/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C @@ -120,8 +120,7 @@ void Foam::waveVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchField<vector>::write(os); - os.writeKeyword("waveDictName") << waveDictName_ - << token::END_STATEMENT << nl; + os.writeEntry("waveDictName", waveDictName_); writeEntry("value", os); } -- GitLab From ad116ef7f28b72fc89b24c90becf4b197c997055 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 6 Nov 2017 17:38:53 +0100 Subject: [PATCH 099/126] ENH: use updated ITstream for parsing strings to token lists --- src/OpenFOAM/db/dictionary/dictionary.C | 21 +++++++-------- .../primitiveEntry/primitiveEntry.C | 26 ++++++++++--------- .../primitiveEntry/primitiveEntry.H | 9 +++---- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 6c4697e7edb..d5815133b53 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -28,7 +28,6 @@ License #include "dictionaryEntry.H" #include "regExp.H" #include "OSHA1stream.H" -#include "DynamicList.H" /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ @@ -214,22 +213,20 @@ Foam::SHA1Digest Foam::dictionary::digest() const Foam::tokenList Foam::dictionary::tokens() const { - // Serialize dictionary into a string + // Serialize dictionary entries into a string OStringStream os; - write(os, false); - IStringStream is(os.str()); - - DynamicList<token> tokens; - - // Parse string as tokens - token tok; - while (is.read(tok)) + // Process entries + forAllConstIter(parent_type, *this, iter) { - tokens.append(std::move(tok)); + os << *iter; } - return tokenList(tokens.xfer()); + // String re-parsed as a list of tokens + return static_cast<tokenList> + ( + ITstream("tokens", os.str(), os.format(), os.version()) + ); } diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C index 76a0c482c41..1202375bd14 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C @@ -30,24 +30,23 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::primitiveEntry::appendTokenList(const UList<token>& varTokens) +void Foam::primitiveEntry::appendTokenList(const UList<token>& toks) { - for (const token& tok : varTokens) + for (const token& tok : toks) { - newElmt(tokenIndex()++) = tok; // append copy + newElmt(tokenIndex()++) = tok; // copy append } } -void Foam::primitiveEntry::appendTokensFromString(const string& input) +void Foam::primitiveEntry::appendTokenList(List<token>&& toks) { - IStringStream is(input); - - token tok; - while (!is.read(tok).bad() && tok.good()) + for (token& tok : toks) { - newElmt(tokenIndex()++) = std::move(tok); + newElmt(tokenIndex()++) = std::move(tok); // move append } + + toks.clear(); } @@ -97,13 +96,16 @@ bool Foam::primitiveEntry::expandVariable return false; } - // Split input string into a stream of tokens and append to list - appendTokensFromString(str); + // String parsed as a list of tokens + ITstream its("env", str); + appendTokenList(std::move(static_cast<tokenList&>(its))); } else if (eptr->isDict()) { // Found dictionary entry - appendTokenList(eptr->dict().tokens()); + + tokenList toks(eptr->dict().tokens().xfer()); + appendTokenList(std::move(toks)); } else { diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H index 59c2a757346..c035f4451a9 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H @@ -73,14 +73,13 @@ class primitiveEntry Istream& is ); - //- Append the given tokens at the current tokenIndex + //- Copy append the given tokens at the current tokenIndex // No filtering on the tokens. - void appendTokenList(const UList<token>& varTokens); + void appendTokenList(const UList<token>& toks); - //- Split input string into a stream of tokens and append at the - //- current tokenIndex. + //- Move append the given tokens at the current tokenIndex // No filtering on the tokens. - void appendTokensFromString(const string& input); + void appendTokenList(List<token>&& toks); //- Expand the given variable. -- GitLab From 4bc9c98695e1f20a7f793eb0eae6fa5e2a90d166 Mon Sep 17 00:00:00 2001 From: Prashant <prashantS.sonakar@esi-group.com> Date: Tue, 7 Nov 2017 16:08:30 +0530 Subject: [PATCH 100/126] STYLE: Corrected file name in surface noise, added README file --- tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun | 5 +++++ tutorials/incompressible/pimpleFoam/LES/vortexShed/README | 3 +++ .../pimpleFoam/LES/vortexShed/system/noiseDict-surface | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tutorials/incompressible/pimpleFoam/LES/vortexShed/README diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun index df2af133800..89808888c0e 100755 --- a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun +++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun @@ -13,4 +13,9 @@ runApplication decomposePar runParallel $(getApplication) +# Run noise tool for both point and surface + +runParallel -s point noise -dict system/noiseDict-point + +runParallel -s surface noise -dict system/noiseDict-surface #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/README b/tutorials/incompressible/pimpleFoam/LES/vortexShed/README new file mode 100644 index 00000000000..10722d1a6a4 --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/README @@ -0,0 +1,3 @@ +- Acoustic pressure is calculated based on Curle's analogy. +- Such field is sampled for point (probe) and surface (cutting plane) +- noise utility is operated onto these samples to obtain frequency information diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface b/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface index 7a192df56ee..a1206332108 100644 --- a/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface +++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface @@ -34,7 +34,7 @@ surfaceNoiseCoeffs // Input file - file "postProcessing/cuttingPlane/yNormal_0.0/yNormal_0.0.case"; + file "postProcessing/cuttingPlane/zNormal/zNormal.case"; // Surface reader reader ensight; @@ -48,7 +48,7 @@ surfaceNoiseCoeffs ensight { collateTimes 1; - format binary; + format binary; } } -- GitLab From b8d5880447dafefebd46edb527847fa15d466dac Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Tue, 7 Nov 2017 11:22:58 +0000 Subject: [PATCH 101/126] STYLE: Header clean-up --- .../BCs/T/smoluchowskiJumpTFvPatchScalarField.H | 7 ++++--- .../chtMultiRegionFoam/solid/solidRegionDiffNo.H | 4 ++-- .../twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H | 4 ++-- .../diameterModels/constantDiameter/constantDiameter.H | 4 ++-- .../diameterModels/isothermalDiameter/isothermalDiameter.H | 6 +++--- .../saturationModels/function1/function1.H | 4 ++-- .../diameterModels/constantDiameter/constantDiameter.H | 4 ++-- .../diameterModels/isothermalDiameter/isothermalDiameter.H | 4 ++-- .../surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H | 4 ++-- etc/caseDicts/postProcessing/flowRate/flowRateFaceZone | 2 +- etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg | 4 ++-- .../functions/Function1/Function1/Function1Fwd.H | 4 ++-- .../alphatPhaseChangeWallFunctionFvPatchScalarField.H | 4 ++-- .../alphatWallFunctionFvPatchScalarField.H | 4 ++-- .../turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H | 4 ++-- .../LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H | 4 ++-- ...entMixingLengthDissipationRateInletFvPatchScalarField.H | 4 ++-- .../porousBafflePressureFvPatchFieldFwd.H | 4 ++-- src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H | 4 ++-- src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H | 4 ++-- .../fixedFluxExtrapolatedPressureFvPatchScalarField.H | 4 ++-- .../fixedFluxPressureFvPatchScalarField.H | 4 ++-- .../freestreamPressureFvPatchScalarField.H | 4 ++-- .../supersonicFreestreamFvPatchVectorField.H | 4 ++-- .../field/streamLine/streamLineParticleCloud.H | 4 ++-- .../wallBoundedStreamLineParticleCloud.H | 4 ++-- .../parcels/include/makeParcelDispersionModels.H | 4 ++-- .../cloudAbsorptionEmission/cloudAbsorptionEmission.H | 4 ++-- .../addOns/radiation/scatter/cloudScatter/cloudScatter.H | 4 ++-- .../parcels/include/makeParcelTurbulenceDispersionModels.H | 4 ++-- .../parcels/include/makeThermoParcelTurbulenceForces.H | 4 ++-- .../mappedVariableThicknessWallFvPatch.H | 4 ++-- src/sampling/meshToMesh0/meshToMesh0.H | 4 ++-- .../reduction/noChemistryReduction/noChemistryReduction.H | 4 ++-- .../tabulation/ISAT/binaryNode/binaryNode.H | 4 ++-- .../chemistrySolver/noChemistrySolver/noChemistrySolver.H | 4 ++-- .../MarshakRadiation/MarshakRadiationFvPatchScalarField.H | 4 ++-- src/thermophysicalModels/radiation/radiationModels/P1/P1.H | 4 ++-- .../fvDOM/blackBodyEmission/blackBodyEmission.H | 4 ++-- .../radiation/radiationModels/fvDOM/fvDOM/fvDOM.H | 4 ++-- .../radiation/radiationModels/solarLoad/solarLoad.H | 4 ++-- .../radiation/radiationModels/viewFactor/viewFactor.H | 4 ++-- .../absorptionEmissionModel/absorptionEmissionModel.H | 4 ++-- .../binaryAbsorptionEmission/binaryAbsorptionEmission.H | 4 ++-- .../constantAbsorptionEmission.H | 4 ++-- .../noAbsorptionEmission/noAbsorptionEmission.H | 4 ++-- .../scatterModel/constantScatter/constantScatter.H | 4 ++-- .../radiation/submodels/scatterModel/noScatter/noScatter.H | 4 ++-- .../radiation/submodels/sootModel/sootModel/sootModel.H | 4 ++-- .../constantTransmissivity/constantTransmissivity.H | 4 ++-- .../noTransmissivity/noTransmissivity.H | 4 ++-- .../reactionThermo/psiuReactionThermo/heheuPsiThermo.H | 4 ++-- .../solidSpecie/reaction/reactions/makeSolidReaction.H | 4 ++-- tutorials/IO/fileHandler/0/U | 4 ++-- tutorials/IO/fileHandler/constant/g | 4 ++-- tutorials/IO/fileHandler/constant/kinematicCloudPositions | 4 ++-- tutorials/IO/fileHandler/constant/kinematicCloudProperties | 4 ++-- tutorials/IO/fileHandler/constant/transportProperties | 4 ++-- tutorials/IO/fileHandler/constant/turbulenceProperties | 4 ++-- tutorials/IO/fileHandler/system/blockMeshDict | 4 ++-- tutorials/IO/fileHandler/system/controlDict | 4 ++-- tutorials/IO/fileHandler/system/decomposeParDict | 4 ++-- tutorials/IO/fileHandler/system/fvSchemes | 4 ++-- tutorials/IO/fileHandler/system/fvSolution | 4 ++-- .../mixerVesselAMI2D/0/U | 4 ++-- .../mixerVesselAMI2D/constant/dynamicMeshDict | 4 ++-- .../mixerVesselAMI2D/constant/g | 4 ++-- .../mixerVesselAMI2D/constant/kinematicCloudPositions | 4 ++-- .../mixerVesselAMI2D/constant/kinematicCloudProperties | 4 ++-- .../mixerVesselAMI2D/constant/transportProperties | 4 ++-- .../mixerVesselAMI2D/constant/turbulenceProperties | 4 ++-- .../mixerVesselAMI2D/system/blockMeshDict.m4 | 4 ++-- .../mixerVesselAMI2D/system/controlDict | 4 ++-- .../mixerVesselAMI2D/system/fvSchemes | 4 ++-- .../mixerVesselAMI2D/system/fvSolution | 4 ++-- .../reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh | 4 ++-- .../lagrangian/reactingParcelFoam/filter/0.orig/p_rgh | 4 ++-- .../lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh | 4 ++-- .../reactingParcelFoam/verticalChannel/0.orig/p_rgh | 4 ++-- .../reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh | 4 ++-- tutorials/mesh/parallel/filter/0.orig/p_rgh | 4 ++-- 81 files changed, 164 insertions(+), 163 deletions(-) diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H index 03625d89682..a854e75458d 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef smoluchowskiJumpTFvPatchScalarFields_H -#define smoluchowskiJumpTFvPatchScalarFields_H +#ifndef smoluchowskiJumpTFvPatchScalarField_H +#define smoluchowskiJumpTFvPatchScalarField_H #include "mixedFvPatchFields.H" @@ -43,7 +43,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class smoluchowskiJumpTFvPatch Declaration + Class smoluchowskiJumpTFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class smoluchowskiJumpTFvPatchScalarField @@ -74,6 +74,7 @@ class smoluchowskiJumpTFvPatchScalarField //- Heat capacity ratio (default 1.4) scalar gamma_; + public: //- Runtime type information diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H index 797bb765a0c..3dd4e261ad4 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H @@ -27,8 +27,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef solidRegionDiff_H -#define solidRegionDiff_H +#ifndef solidRegionDiffNo_H +#define solidRegionDiffNo_H #include "fvMesh.H" diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H index cc61acf6749..cdeb8aaf2a9 100644 --- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H +++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef flashThermo_H -#define flashThermo_H +#ifndef twoPhaseMixtureEThermo_H +#define twoPhaseMixtureEThermo_H #include "volFields.H" diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H index 738b7ae5704..ab24c737369 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef constant_H -#define constant_H +#ifndef diameterModels_constant_H +#define diameterModels_constant_H #include "diameterModel.H" diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H index 0d155ad16e0..8bdb54eff64 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::isothermal + Foam::diameterModels::isothermal Description Isothermal dispersed-phase particle diameter model. @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef isothermal_H -#define isothermal_H +#ifndef diameterModels_isothermal_H +#define diameterModels_isothermal_H #include "diameterModel.H" diff --git a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H index bbac62d50b3..23710027e3f 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H +++ b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H @@ -72,8 +72,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef function1_saturationModel_H -#define function1_saturationModel_H +#ifndef saturationModels_function1_H +#define saturationModels_function1_H #include "saturationModel.H" #include "Function1.H" diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H index 6f616c6f73d..fbf20426e8f 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef constant_H -#define constant_H +#ifndef diameterModels_constant_H +#define diameterModels_constant_H #include "diameterModel.H" diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H index 6e997a210ae..1d83bc575a8 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef isothermal_H -#define isothermal_H +#ifndef diameterModels_isothermal_H +#define diameterModels_isothermal_H #include "diameterModel.H" diff --git a/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H index e17039cd034..53c4fa494e6 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H +++ b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H @@ -33,8 +33,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef IndexedPolyhedron_H -#define IndexedPolyhedron_H +#ifndef CGALIndexedPolyhedron_H +#define CGALIndexedPolyhedron_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone index ed81df016e3..5158dde377b 100644 --- a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone +++ b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Web: www.OpenFOAM.org + \\ / A nd | Web: www.OpenFOAM.com \\/ M anipulation | ------------------------------------------------------------------------------- Description diff --git a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg index b68815887d5..1ba17a794f9 100644 --- a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg +++ b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H index 6e3b14ba0c0..ad78b17f553 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef Function1Fws_H -#define Function1Fws_H +#ifndef Function1Fwd_H +#define Function1Fwd_H #include "Function1.H" #include "vector.H" diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H index 763e71df514..8184600ff13 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H @@ -39,8 +39,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef compressibleAlphatPhaseChangeWallFunctionFvPatchScalarField_H -#define compressibleAlphatPhaseChangeWallFunctionFvPatchScalarField_H +#ifndef compressible_alphatPhaseChangeWallFunctionFvPatchScalarField_H +#define compressible_alphatPhaseChangeWallFunctionFvPatchScalarField_H #include "fixedValueFvPatchFields.H" diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H index ca4c35bc5d5..8aeddced40c 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H @@ -72,8 +72,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef compressibleAlphatWallFunctionFvPatchScalarField_H -#define compressibleAlphatWallFunctionFvPatchScalarField_H +#ifndef compressible_alphatWallFunctionFvPatchScalarField_H +#define compressible_alphatWallFunctionFvPatchScalarField_H #include "fixedValueFvPatchFields.H" diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H index eef6e95959b..55b0332e84a 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef IDDESDeltaDelta_H -#define IDDESDeltaDelta_H +#ifndef LESModels_IDDESDelta_H +#define LESModels_IDDESDelta_H #include "maxDeltaxyz.H" diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H index de439813221..f981aaf6eab 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef maxDeltaxyzDelta_H -#define maxDeltaxyzDelta_H +#ifndef LESModels_maxDeltaxyz_H +#define LESModels_maxDeltaxyz_H #include "LESdelta.H" diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H index d71c85ea810..2a4ab54c601 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H @@ -74,8 +74,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef turbulentMixingLengthDissipationRateInlet_H -#define turbulentMixingLengthDissipationRateInlet_H +#ifndef turbulentMixingLengthDissipationRateInletFvPatchScalarField_H +#define turbulentMixingLengthDissipationRateInletFvPatchScalarField_H #include "inletOutletFvPatchFields.H" diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H index 946f45d0762..2e5d92089cb 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef porousBafflePressureFvPatchFieldsFwd_H -#define porousBafflePressureFvPatchFieldsFwd_H +#ifndef porousBafflePressureFvPatchFieldFwd_H +#define porousBafflePressureFvPatchFieldFwd_H #include "fieldTypes.H" diff --git a/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H b/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H index 1b6499934fe..1adaed982b6 100644 --- a/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H +++ b/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H @@ -33,8 +33,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef SRFModelRpm_H -#define SRFModelRpm_H +#ifndef SRF_rpm_H +#define SRF_rpm_H #include "SRFModel.H" diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H index 3d4ffefe357..a173f7c6dda 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef options_H -#define options_H +#ifndef fv_options_H +#define fv_options_H #include "fvOptionList.H" #include "IOdictionary.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H index 1bdaee71b8a..9a1f051bf7e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H @@ -48,8 +48,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fixedFluxExtrapolatedPressureFvPatchScalarFields_H -#define fixedFluxExtrapolatedPressureFvPatchScalarFields_H +#ifndef fixedFluxExtrapolatedPressureFvPatchScalarField_H +#define fixedFluxExtrapolatedPressureFvPatchScalarField_H #include "fixedFluxPressureFvPatchScalarField.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H index aaafe055a90..94bfcf9feee 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H @@ -48,8 +48,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fixedFluxPressureFvPatchScalarFields_H -#define fixedFluxPressureFvPatchScalarFields_H +#ifndef fixedFluxPressureFvPatchScalarField_H +#define fixedFluxPressureFvPatchScalarField_H #include "fvPatchFields.H" #include "fixedGradientFvPatchFields.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H index e8b5f28114b..950e8908450 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H @@ -60,8 +60,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef freestreamPressureFvPatchScalarFields_H -#define freestreamPressureFvPatchScalarFields_H +#ifndef freestreamPressureFvPatchScalarField_H +#define freestreamPressureFvPatchScalarField_H #include "fvPatchFields.H" #include "zeroGradientFvPatchFields.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H index 54d0e92a699..69a6a04eab2 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H @@ -69,8 +69,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef supersonicFreestreamFvPatchVectorFields_H -#define supersonicFreestreamFvPatchVectorFields_H +#ifndef supersonicFreestreamFvPatchVectorField_H +#define supersonicFreestreamFvPatchVectorField_H #include "fvPatchFields.H" #include "mixedFvPatchFields.H" diff --git a/src/functionObjects/field/streamLine/streamLineParticleCloud.H b/src/functionObjects/field/streamLine/streamLineParticleCloud.H index 9fdbad50f5d..dfe1461a7e9 100644 --- a/src/functionObjects/field/streamLine/streamLineParticleCloud.H +++ b/src/functionObjects/field/streamLine/streamLineParticleCloud.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef streamLineCloud_H -#define streamLineCloud_H +#ifndef streamLineParticleCloud_H +#define streamLineParticleCloud_H #include "Cloud.H" #include "streamLineParticle.H" diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H index 8ce123d6a55..dc270ffa0d8 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef streamLineCloud_H -#define streamLineCloud_H +#ifndef wallBoundedStreamLineParticleCloud_H +#define wallBoundedStreamLineParticleCloud_H #include "Cloud.H" #include "wallBoundedStreamLineParticle.H" diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H b/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H index 855d307277a..bbff6f2de6a 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef makeParcelDispersionModels_h -#define makeParcelDispersionModels_h +#ifndef makeParcelDispersionModels_H +#define makeParcelDispersionModels_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H index 99a63183a27..336b29a1aa6 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationCloudAbsorptionEmission_H -#define radiationCloudAbsorptionEmission_H +#ifndef radiation_cloudAbsorptionEmission_H +#define radiation_cloudAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H index fa4a9338080..44b6de546c5 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationCloudScatter_H -#define radiationCloudScatter_H +#ifndef radiation_cloudScatter_H +#define radiation_cloudScatter_H #include "scatterModel.H" diff --git a/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H b/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H index f10a1220570..7d3473b062b 100644 --- a/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H +++ b/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef makeParcelTurbulenceDispersionModels_h -#define makeParcelTurbulenceDispersionModels_h +#ifndef makeParcelTurbulenceDispersionModels_H +#define makeParcelTurbulenceDispersionModels_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H b/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H index db6d224dd31..fccd7734b07 100644 --- a/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H +++ b/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef makeThermoParcelTurbulenceForces_h -#define makeThermoParcelTurbulenceForces_h +#ifndef makeThermoParcelTurbulenceForces_H +#define makeThermoParcelTurbulenceForces_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H b/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H index f4709bb62e6..cb3185cbad6 100644 --- a/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H +++ b/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef mappedWallFvPatch_H -#define mappedWallFvPatch_H +#ifndef mappedVariableThicknessWallFvPatch_H +#define mappedVariableThicknessWallFvPatch_H #include "wallFvPatch.H" #include "mappedVariableThicknessWallPolyPatch.H" diff --git a/src/sampling/meshToMesh0/meshToMesh0.H b/src/sampling/meshToMesh0/meshToMesh0.H index 885d4baeb05..989173f0738 100644 --- a/src/sampling/meshToMesh0/meshToMesh0.H +++ b/src/sampling/meshToMesh0/meshToMesh0.H @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef meshtoMesh_H -#define meshtoMesh_H +#ifndef meshToMesh0_H +#define meshToMesh0_H #include "fvMesh.H" #include "HashTable.H" diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H index e3bbc0b4331..cde61c91b72 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H @@ -31,8 +31,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef none_H -#define none_H +#ifndef chemistryReductionMethods_none_H +#define chemistryReductionMethods_none_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H index 99952a51f68..d321fff5804 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H @@ -32,8 +32,8 @@ SourceFile \*---------------------------------------------------------------------------*/ -#ifndef BINARY_NODE_H -#define BINARY_NODE_H +#ifndef binaryNode_H +#define binaryNode_H #include "chemPointISAT.H" diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H index e0f5db3f60c..d37290e0169 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H @@ -33,8 +33,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef noChemistySolver_H -#define noChemistySolver_H +#ifndef noChemistrySolver_H +#define noChemistrySolver_H #include "chemistrySolver.H" diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H index d175c9e358a..5e9b7a11388 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H @@ -59,8 +59,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef MarshakRadiationMixedFvPatchField_H -#define MarshakRadiationMixedFvPatchField_H +#ifndef radiation_MarshakRadiationFvPatchScalarField_H +#define radiation_MarshakRadiationFvPatchScalarField_H #include "mixedFvPatchFields.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H index e52733e3eae..6532f8223c4 100644 --- a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H +++ b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H @@ -41,8 +41,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelP1_H -#define radiationModelP1_H +#ifndef radiation_P1_H +#define radiation_P1_H #include "radiationModel.H" #include "volFields.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H index d7f175fc5c6..c22319fc244 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef blackModyEmission_H -#define blackModyEmission_H +#ifndef radiation_blackBodyEmission_H +#define radiation_blackBodyEmission_H #include "volFields.H" #include "dimensionedScalar.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H index 3c00d3b2872..419389c30c3 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H @@ -74,8 +74,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelfvDOM_H -#define radiationModelfvDOM_H +#ifndef radiation_fvDOM_H +#define radiation_fvDOM_H #include "radiativeIntensityRay.H" #include "radiationModel.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H index 52e2e9a36e2..be1e993710c 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H @@ -59,8 +59,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelsolarLoad_H -#define radiationModelsolarLoad_H +#ifndef radiation_solarLoad_H +#define radiation_solarLoad_H #include "radiationModel.H" #include "singleCellFvMesh.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H index 5bd75d92ae6..92ec802b459 100644 --- a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H +++ b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H @@ -45,8 +45,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelviewFactor_H -#define radiationModelviewFactor_H +#ifndef radiation_viewFactor_H +#define radiation_viewFactor_H #include "radiationModel.H" #include "singleCellFvMesh.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H index f02d4a079d9..8350cba6f7b 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H @@ -30,8 +30,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef radiationAbsorptionEmissionModel_H -#define radiationAbsorptionEmissionModel_H +#ifndef radiation_absorptionEmissionModel_H +#define radiation_absorptionEmissionModel_H #include "IOdictionary.H" #include "autoPtr.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H index 2771f938b61..cf9397aac53 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationBinaryAbsorptionEmission_H -#define radiationBinaryAbsorptionEmission_H +#ifndef radiation_binaryAbsorptionEmission_H +#define radiation_binaryAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H index 357a31d2ba4..18fc7f349e1 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantAbsorptionEmission_H -#define radiationConstantAbsorptionEmission_H +#ifndef radiation_constantAbsorptionEmission_H +#define radiation_constantAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H index 011df68dbb1..23ab5e9bb34 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationNoAbsorptionEmission_H -#define radiationNoAbsorptionEmission_H +#ifndef radiation_noAbsorptionEmission_H +#define radiation_noAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H index ac6357c3554..ccf024e6b22 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantScatter_H -#define radiationConstantScatter_H +#ifndef radiation_constantScatter_H +#define radiation_constantScatter_H #include "scatterModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H index 095b4d96692..2fb19569df2 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationNoScatter_H -#define radiationNoScatter_H +#ifndef radiation_noScatter_H +#define radiation_noScatter_H #include "scatterModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H b/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H index a3c2dee676b..2967f4c9595 100644 --- a/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H +++ b/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H @@ -29,8 +29,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef radiationsootModel_H -#define radiationsootModel_H +#ifndef radiation_sootModel_H +#define radiation_sootModel_H #include "IOdictionary.H" #include "autoPtr.H" diff --git a/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H b/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H index 44593c42ebe..e06c4e48298 100644 --- a/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H +++ b/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantTransmissivity_H -#define radiationConstantTransmissivity_H +#ifndef radiation_constantTransmissivity_H +#define radiation_constantTransmissivity_H #include "transmissivityModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H b/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H index 517bf43771b..9d264f82c6c 100644 --- a/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H +++ b/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantScatter_H -#define radiationConstantScatter_H +#ifndef radiation_noTransmissivity_H +#define radiation_noTransmissivity_H #include "transmissivityModel.H" diff --git a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H index 725ce90e3a8..4506f4cb6ea 100644 --- a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H +++ b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef heheuReactionThermo_H -#define heheuReactionThermo_H +#ifndef heheuPsiThermo_H +#define heheuPsiThermo_H #include "heThermo.H" diff --git a/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H b/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H index b5444f1e59a..b278c3c4605 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H +++ b/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H @@ -29,8 +29,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef makeSolidReactionThermo_H -#define makeSolidReactionThermo_H +#ifndef makeSolidReaction_H +#define makeSolidReaction_H #include "solidReaction.H" #include "IrreversibleReaction.H" diff --git a/tutorials/IO/fileHandler/0/U b/tutorials/IO/fileHandler/0/U index 75ed42fbdb4..04b73f9a935 100644 --- a/tutorials/IO/fileHandler/0/U +++ b/tutorials/IO/fileHandler/0/U @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/g b/tutorials/IO/fileHandler/constant/g index 0cc222ca345..4702e33f63d 100644 --- a/tutorials/IO/fileHandler/constant/g +++ b/tutorials/IO/fileHandler/constant/g @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/kinematicCloudPositions b/tutorials/IO/fileHandler/constant/kinematicCloudPositions index 1e2be4ebc84..f2d697e58e0 100644 --- a/tutorials/IO/fileHandler/constant/kinematicCloudPositions +++ b/tutorials/IO/fileHandler/constant/kinematicCloudPositions @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/kinematicCloudProperties b/tutorials/IO/fileHandler/constant/kinematicCloudProperties index 41b8c64e80d..a52b7d2a0a4 100644 --- a/tutorials/IO/fileHandler/constant/kinematicCloudProperties +++ b/tutorials/IO/fileHandler/constant/kinematicCloudProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/transportProperties b/tutorials/IO/fileHandler/constant/transportProperties index dbbab9e9f0a..375de077121 100644 --- a/tutorials/IO/fileHandler/constant/transportProperties +++ b/tutorials/IO/fileHandler/constant/transportProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/turbulenceProperties b/tutorials/IO/fileHandler/constant/turbulenceProperties index c2c3b28a1b4..5eec0426726 100644 --- a/tutorials/IO/fileHandler/constant/turbulenceProperties +++ b/tutorials/IO/fileHandler/constant/turbulenceProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/blockMeshDict b/tutorials/IO/fileHandler/system/blockMeshDict index 359a48779aa..f67edf5308b 100644 --- a/tutorials/IO/fileHandler/system/blockMeshDict +++ b/tutorials/IO/fileHandler/system/blockMeshDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/controlDict b/tutorials/IO/fileHandler/system/controlDict index 2ac8dc57876..d2090358217 100644 --- a/tutorials/IO/fileHandler/system/controlDict +++ b/tutorials/IO/fileHandler/system/controlDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/decomposeParDict b/tutorials/IO/fileHandler/system/decomposeParDict index 0f07bb6aa8b..341581df062 100644 --- a/tutorials/IO/fileHandler/system/decomposeParDict +++ b/tutorials/IO/fileHandler/system/decomposeParDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/fvSchemes b/tutorials/IO/fileHandler/system/fvSchemes index 12c112d4e08..2d037571545 100644 --- a/tutorials/IO/fileHandler/system/fvSchemes +++ b/tutorials/IO/fileHandler/system/fvSchemes @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/fvSolution b/tutorials/IO/fileHandler/system/fvSolution index 740eb61a4bc..b72ad9583f3 100644 --- a/tutorials/IO/fileHandler/system/fvSolution +++ b/tutorials/IO/fileHandler/system/fvSolution @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U index 843a28d50f4..8a3472efb14 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict index 180fa548d9f..098df40ce85 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g index 7db1127c4e7..e385acd7d9a 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions index 72e44ae6a1c..0e75a13567c 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties index d2c439ffa10..dc1b7a9f5ca 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties index 3a1bb800c6f..104081599aa 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties index c2c3b28a1b4..5eec0426726 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 index d6cc8a50c8c..9b6f8a5e2bc 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict index 3bf92c6e366..245a1149e04 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes index 9c5ef530909..93fc8434787 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution index b0b21145a2b..cb6c43877e5 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh index b51753afdff..430890dd3cb 100644 --- a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh index 889e4cf1113..42af2c294a2 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh index 14453a39681..70182381f81 100644 --- a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh index 462a0fa1054..616e1c783f6 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh index bab3fe3b901..6d61fe59762 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/mesh/parallel/filter/0.orig/p_rgh b/tutorials/mesh/parallel/filter/0.orig/p_rgh index 889e4cf1113..42af2c294a2 100644 --- a/tutorials/mesh/parallel/filter/0.orig/p_rgh +++ b/tutorials/mesh/parallel/filter/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile -- GitLab From 2ae278363534577035c88177494b359aab97a908 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 7 Nov 2017 13:12:43 +0100 Subject: [PATCH 102/126] ENH: add a test dictionary token streaming class --- applications/test/dictionaryTokens/Make/files | 4 + .../test/dictionaryTokens/Make/options | 1 + .../dictionaryTokens/Test-dictionaryTokens.C | 95 ++++++ .../test/dictionaryTokens/dictionaryTokens.C | 309 ++++++++++++++++++ .../test/dictionaryTokens/dictionaryTokens.H | 289 ++++++++++++++++ 5 files changed, 698 insertions(+) create mode 100644 applications/test/dictionaryTokens/Make/files create mode 100644 applications/test/dictionaryTokens/Make/options create mode 100644 applications/test/dictionaryTokens/Test-dictionaryTokens.C create mode 100644 applications/test/dictionaryTokens/dictionaryTokens.C create mode 100644 applications/test/dictionaryTokens/dictionaryTokens.H diff --git a/applications/test/dictionaryTokens/Make/files b/applications/test/dictionaryTokens/Make/files new file mode 100644 index 00000000000..413023a0147 --- /dev/null +++ b/applications/test/dictionaryTokens/Make/files @@ -0,0 +1,4 @@ +Test-dictionaryTokens.C +dictionaryTokens.C + +EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens diff --git a/applications/test/dictionaryTokens/Make/options b/applications/test/dictionaryTokens/Make/options new file mode 100644 index 00000000000..41306609f20 --- /dev/null +++ b/applications/test/dictionaryTokens/Make/options @@ -0,0 +1 @@ +EXE_INC = diff --git a/applications/test/dictionaryTokens/Test-dictionaryTokens.C b/applications/test/dictionaryTokens/Test-dictionaryTokens.C new file mode 100644 index 00000000000..6e77cddc5f8 --- /dev/null +++ b/applications/test/dictionaryTokens/Test-dictionaryTokens.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + printDictionary + +Description + + Test dictionaryTokens + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "IOstreams.H" +#include "IOobject.H" +#include "IFstream.H" + +#include "dictionaryTokens.H" + +using namespace Foam; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noBanner(); + argList::noParallel(); + argList::noFunctionObjects(); + argList::addBoolOption("info", "report token info"); + argList::addBoolOption("value", "report token value"); + + argList::validArgs.insert("dict .. dictN"); + argList args(argc, argv, false, true); + + const bool optInfo = args.optionFound("info"); + const bool optValue = args.optionFound("value"); + + for (label argi=1; argi < args.size(); ++argi) + { + IFstream is(args[argi]); + + dictionary dict(is); + + dictionaryTokens dictTokens(dict); + + while (dictTokens.good()) + { + if (optInfo) + { + // Token info + Info<< (*dictTokens).info() << nl; + } + else if (optValue) + { + // Token value + Info<< *dictTokens << nl; + } + else + { + // Token type + Info<< (*dictTokens).name() << nl; + } + ++dictTokens; + } + + Info<< nl; + } + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/dictionaryTokens/dictionaryTokens.C b/applications/test/dictionaryTokens/dictionaryTokens.C new file mode 100644 index 00000000000..28cb9f30cf6 --- /dev/null +++ b/applications/test/dictionaryTokens/dictionaryTokens.C @@ -0,0 +1,309 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "dictionaryTokens.H" +#include "IOstream.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::token Foam::dictionaryTokens::keywordToken(const entry& e) +{ + const keyType& k = e.keyword(); + + if (k.empty()) + { + return token::undefinedToken; + } + if (k.isPattern()) + { + return token(static_cast<string>(k)); // quoted + } + else + { + return token(static_cast<word>(k)); // unquoted + } +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::dictionaryTokens::setIterator() const +{ + primIter_.clear(); + dictIter_.clear(); + + if (entryIter_ != dict_.cend()) + { + const entry& base = *entryIter_; + + if (isA<primitiveEntry>(base)) + { + primIter_.reset + ( + new dictionaryTokens::primitive_iterator + ( + dynamicCast<const primitiveEntry&>(base) + ) + ); + + return true; + } + else if (isA<dictionaryListEntry>(base)) + { + // Must check for isA<dictionaryListEntry> before checking + // for isA<dictionaryEntry> ! + + dictIter_.reset + ( + new dictionaryTokens::dictionary_iterator + ( + dynamicCast<const dictionaryListEntry&>(base) + ) + ); + + return true; + } + else if (isA<dictionaryEntry>(base)) + { + dictIter_.reset + ( + new dictionaryTokens::dictionary_iterator + ( + dynamicCast<const dictionaryEntry&>(base) + ) + ); + + return true; + } + + } + + return false; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dictionaryTokens::dictionaryTokens(const dictionary& dict) +: + dict_(dict), + entryIter_(dict_.cbegin()), + primIter_(nullptr), + dictIter_(nullptr) +{ + rewind(); +} + + +Foam::dictionaryTokens::primitive_iterator::primitive_iterator +( + const primitiveEntry& e +) +: + tokensPtr_(&(static_cast<const tokenList&>(e))), + key_(dictionaryTokens::keywordToken(e)), + end_(token::punctuationToken::END_STATEMENT), + pos_((key_.good() ? -1 : 0)) +{} + + +Foam::dictionaryTokens::dictionary_iterator::dictionary_iterator +( + const dictionaryEntry& e +) +: + key_(dictionaryTokens::keywordToken(e)), + lbrace_(token::punctuationToken::BEGIN_BLOCK), + rbrace_(token::punctuationToken::END_BLOCK), + state_(key_.good() ? states::KEY : states::OPEN), + dictTokens_(e.dict()) +{} + + +Foam::dictionaryTokens::dictionary_iterator::dictionary_iterator +( + const dictionaryListEntry& e +) +: + key_(e.size()), + lbrace_(token::punctuationToken::BEGIN_LIST), + rbrace_(token::punctuationToken::END_LIST), + state_(states::KEY), + dictTokens_(e.dict()) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::dictionaryTokens::good() const +{ + return + ( + entryIter_ != dict_.cend() + && + ( + (primIter_.valid() && primIter_().good()) + || (dictIter_.valid() && dictIter_().good()) + ) + ); +} + + +bool Foam::dictionaryTokens::primitive_iterator::good() const +{ + return (tokensPtr_ && pos_ <= tokensPtr_->size()); +} + + +bool Foam::dictionaryTokens::dictionary_iterator::good() const +{ + return (state_ != states::END); +} + + +const Foam::token& Foam::dictionaryTokens::operator*() const +{ + if (good()) + { + if (primIter_.valid()) return *(primIter_()); + if (dictIter_.valid()) return *(dictIter_()); + } + + return token::undefinedToken; +} + + +const Foam::token& +Foam::dictionaryTokens::primitive_iterator::operator*() const +{ + if (good()) + { + if (pos_ == -1) + { + return key_; + } + else if (pos_ >= tokensPtr_->size()) + { + return end_; // The trailing ';' + } + + return tokensPtr_->operator[](pos_); + } + + return token::undefinedToken; +} + + +const Foam::token& +Foam::dictionaryTokens::dictionary_iterator::operator*() const +{ + if (good()) + { + if (state_ == states::KEY) + { + return key_; // keyword + } + if (state_ == states::OPEN) + { + return lbrace_; // Opening '{' + } + if (state_ == states::CONTENT) + { + return *(dictTokens_); + } + if (state_ == states::CLOSE) + { + return rbrace_; // Closing '}' + } + } + + return token::undefinedToken; +} + + +bool Foam::dictionaryTokens::operator++() +{ + bool ok = good(); + + if (ok) + { + if (primIter_.valid()) ok = ++(primIter_()); + if (dictIter_.valid()) ok = ++(dictIter_()); + + if (!ok) + { + ++entryIter_; // Next entry + setIterator(); + } + } + + return ok; +} + + +bool Foam::dictionaryTokens::primitive_iterator::operator++() +{ + // Advance good iterators. + // + // Going beyond trailing ';' makes it into an end iterator + + if (tokensPtr_ && (++pos_ > tokensPtr_->size())) + { + tokensPtr_ = nullptr; + return false; + } + + return this->good(); +} + + +bool Foam::dictionaryTokens::dictionary_iterator::operator++() +{ + if + ( + state_ == states::KEY + || state_ == states::OPEN + || state_ == states::CLOSE + ) + { + ++state_; + } + else if (state_ == states::CONTENT && !(++dictTokens_)) + { + ++state_; + } + + return good(); +} + + +void Foam::dictionaryTokens::rewind() +{ + entryIter_ = dict_.cbegin(); + setIterator(); +} + + +// ************************************************************************* // diff --git a/applications/test/dictionaryTokens/dictionaryTokens.H b/applications/test/dictionaryTokens/dictionaryTokens.H new file mode 100644 index 00000000000..f6866335679 --- /dev/null +++ b/applications/test/dictionaryTokens/dictionaryTokens.H @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::dictionaryTokens + +Description + Provides a stream of tokens from a dictionary. + + This can be used to return a stream of tokens from a dictionary + without overhead or needing to reparse information. + + For example, + + \code + OPstream os = ...; + dictionaryTokens toks(dict); + + while (toks.good()) + { + os.write(*toks); + ++toks; + } + + \endcode + Or alternatively, + + \code + dictionaryTokens toks(dict); + + while (toks.good()) + { + os << *toks << nl; + ++toks; + } + \endcode + +SourceFiles + dictionaryTokens.C + +\*---------------------------------------------------------------------------*/ + +#ifndef dictionaryTokens_H +#define dictionaryTokens_H + +#include "dictionary.H" +#include "primitiveEntry.H" +#include "dictionaryEntry.H" +#include "dictionaryListEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declarations +class dictionaryTokens; + + +/*---------------------------------------------------------------------------*\ + Class dictionaryTokens Declaration +\*---------------------------------------------------------------------------*/ + +class dictionaryTokens +{ +public: + + // Forward declarations + class primitive_iterator; + class dictionary_iterator; + + +private: + + // Private Member Data + + //- Reference to the dictionary being streamed. + const dictionary& dict_; + + //- The current entry iterator + IDLList<entry>::const_iterator entryIter_; + + //- The current entry iterator for primitiveEntry types + mutable autoPtr<primitive_iterator> primIter_; + + //- The current entry iterator for dictionaryEntry and + //- dictionaryListEntry types + mutable autoPtr<dictionary_iterator> dictIter_; + + //- Set/unset primitive and dictionary when changing to next entry + bool setIterator() const; + + + // Private Member Functions + + //- Disallow bitwise copy/assignment + dictionaryTokens(const dictionaryTokens&) = delete; + void operator=(const dictionaryTokens&) = delete; + + +public: + + // Static Member Functions + + //- The entry keyword as word or string token + static token keywordToken(const entry& e); + + + // Constructors + + //- Construct from reference to dictionary to be streamed + dictionaryTokens(const dictionary& dict); + + + // Member Functions + + //- True if the token stream is in a valid state + bool good() const; + + //- The current token, or undefined if the stream is in an invalid + //- invalid state. + const token& operator*() const; + + //- Advance to the next token and return the updated stream stream. + bool operator++(); + + //- Reset to beginning + void rewind(); + +}; + + +/*---------------------------------------------------------------------------*\ + Class dictionaryTokens::primitive_iterator Declaration +\*---------------------------------------------------------------------------*/ + +//- An iterator for a primitiveEntry +// +// The token stream output has the form +// +// \verbatim +// keyword content tokens ';' +// \endverbatim +// +class dictionaryTokens::primitive_iterator +{ + // Private Member Data + + //- Reference to the tokenList being streamed. + const tokenList* tokensPtr_; + + //- The keyword as a token (string, word or undefined) + const token key_; + + //- The closing ';' as a token + const token end_; + + //- The current position within the tokenList + label pos_; + + + // Private Member Functions + + //- Disallow bitwise copy/assignment + primitive_iterator(const primitive_iterator&) = delete; + void operator=(const primitive_iterator&) = delete; + +public: + + // Constructors + + //- Construct from reference to primitiveEntry + primitive_iterator(const primitiveEntry& e); + + + // Member Functions + + //- True if the entry has keyword or tokens and has not indexed beyond + //- the final trailing ';' + bool good() const; + + //- The current token, or undefined if the stream is invalid. + const token& operator*() const; + + //- Advance to the next token and return the updated stream stream. + bool operator++(); + +}; + + +/*---------------------------------------------------------------------------*\ + Class dictionaryTokens::dictionary_iterator Declaration +\*---------------------------------------------------------------------------*/ + +//- An iterator for a dictionaryEntry and dictionaryListEntry +// +// The token stream output has the form +// +// \verbatim +// keyword '{' content '}' +// \endverbatim +// +// or for the dictionaryListEntry the form +// +// \verbatim +// size '(' content ')' +// \endverbatim +// +class dictionaryTokens::dictionary_iterator +{ + // Private Member Data + + //- The possible output states + enum states { KEY=0, OPEN, CONTENT, CLOSE, END }; + + //- The keyword or the size (dictionaryListEntry) as a token + const token key_; + + //- The opening brace '{' or bracket '(' + const token lbrace_; + + //- The closing brace ')' or bracket ')' + const token rbrace_; + + //- The current output state + int state_; + + //- A streamer for the dictionary content + dictionaryTokens dictTokens_; + + + // Private Member Functions + + //- Disallow bitwise copy/assignment + dictionary_iterator(const dictionary_iterator&) = delete; + void operator=(const dictionary_iterator&) = delete; + + +public: + + // Constructors + + //- Construct from reference to dictionaryEntry + dictionary_iterator(const dictionaryEntry& e); + + //- Construct from reference to dictionaryListEntry + dictionary_iterator(const dictionaryListEntry& e); + + + // Member Functions + + //- In a valid state + bool good() const; + + //- The current token, or undefined if the stream is invalid. + const token& operator*() const; + + //- Advance to the next token and return the updated stream stream. + bool operator++(); + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +#endif + +// ************************************************************************* // -- GitLab From 6aa7b6ac2aff7303ab0789f2d85db80d7d21ab70 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Tue, 7 Nov 2017 11:22:58 +0000 Subject: [PATCH 103/126] STYLE: Header clean-up --- .../BCs/T/smoluchowskiJumpTFvPatchScalarField.H | 7 ++++--- .../chtMultiRegionFoam/solid/solidRegionDiffNo.H | 4 ++-- .../twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H | 4 ++-- .../diameterModels/constantDiameter/constantDiameter.H | 4 ++-- .../diameterModels/isothermalDiameter/isothermalDiameter.H | 6 +++--- .../saturationModels/function1/function1.H | 4 ++-- .../diameterModels/constantDiameter/constantDiameter.H | 4 ++-- .../diameterModels/isothermalDiameter/isothermalDiameter.H | 4 ++-- .../surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H | 4 ++-- etc/caseDicts/postProcessing/flowRate/flowRateFaceZone | 2 +- etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg | 4 ++-- .../functions/Function1/Function1/Function1Fwd.H | 4 ++-- .../alphatPhaseChangeWallFunctionFvPatchScalarField.H | 4 ++-- .../alphatWallFunctionFvPatchScalarField.H | 4 ++-- .../turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H | 4 ++-- .../LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H | 4 ++-- ...entMixingLengthDissipationRateInletFvPatchScalarField.H | 4 ++-- .../porousBafflePressureFvPatchFieldFwd.H | 4 ++-- src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H | 4 ++-- src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H | 4 ++-- .../fixedFluxExtrapolatedPressureFvPatchScalarField.H | 4 ++-- .../fixedFluxPressureFvPatchScalarField.H | 4 ++-- .../freestreamPressureFvPatchScalarField.H | 4 ++-- .../supersonicFreestreamFvPatchVectorField.H | 4 ++-- .../field/streamLine/streamLineParticleCloud.H | 4 ++-- .../wallBoundedStreamLineParticleCloud.H | 4 ++-- .../parcels/include/makeParcelDispersionModels.H | 4 ++-- .../cloudAbsorptionEmission/cloudAbsorptionEmission.H | 4 ++-- .../addOns/radiation/scatter/cloudScatter/cloudScatter.H | 4 ++-- .../parcels/include/makeParcelTurbulenceDispersionModels.H | 4 ++-- .../parcels/include/makeThermoParcelTurbulenceForces.H | 4 ++-- .../mappedVariableThicknessWallFvPatch.H | 4 ++-- src/sampling/meshToMesh0/meshToMesh0.H | 4 ++-- .../reduction/noChemistryReduction/noChemistryReduction.H | 4 ++-- .../tabulation/ISAT/binaryNode/binaryNode.H | 4 ++-- .../chemistrySolver/noChemistrySolver/noChemistrySolver.H | 4 ++-- .../MarshakRadiation/MarshakRadiationFvPatchScalarField.H | 4 ++-- src/thermophysicalModels/radiation/radiationModels/P1/P1.H | 4 ++-- .../fvDOM/blackBodyEmission/blackBodyEmission.H | 4 ++-- .../radiation/radiationModels/fvDOM/fvDOM/fvDOM.H | 4 ++-- .../radiation/radiationModels/solarLoad/solarLoad.H | 4 ++-- .../radiation/radiationModels/viewFactor/viewFactor.H | 4 ++-- .../absorptionEmissionModel/absorptionEmissionModel.H | 4 ++-- .../binaryAbsorptionEmission/binaryAbsorptionEmission.H | 4 ++-- .../constantAbsorptionEmission.H | 4 ++-- .../noAbsorptionEmission/noAbsorptionEmission.H | 4 ++-- .../scatterModel/constantScatter/constantScatter.H | 4 ++-- .../radiation/submodels/scatterModel/noScatter/noScatter.H | 4 ++-- .../radiation/submodels/sootModel/sootModel/sootModel.H | 4 ++-- .../constantTransmissivity/constantTransmissivity.H | 4 ++-- .../noTransmissivity/noTransmissivity.H | 4 ++-- .../reactionThermo/psiuReactionThermo/heheuPsiThermo.H | 4 ++-- .../solidSpecie/reaction/reactions/makeSolidReaction.H | 4 ++-- tutorials/IO/fileHandler/0/U | 4 ++-- tutorials/IO/fileHandler/constant/g | 4 ++-- tutorials/IO/fileHandler/constant/kinematicCloudPositions | 4 ++-- tutorials/IO/fileHandler/constant/kinematicCloudProperties | 4 ++-- tutorials/IO/fileHandler/constant/transportProperties | 4 ++-- tutorials/IO/fileHandler/constant/turbulenceProperties | 4 ++-- tutorials/IO/fileHandler/system/blockMeshDict | 4 ++-- tutorials/IO/fileHandler/system/controlDict | 4 ++-- tutorials/IO/fileHandler/system/decomposeParDict | 4 ++-- tutorials/IO/fileHandler/system/fvSchemes | 4 ++-- tutorials/IO/fileHandler/system/fvSolution | 4 ++-- .../mixerVesselAMI2D/0/U | 4 ++-- .../mixerVesselAMI2D/constant/dynamicMeshDict | 4 ++-- .../mixerVesselAMI2D/constant/g | 4 ++-- .../mixerVesselAMI2D/constant/kinematicCloudPositions | 4 ++-- .../mixerVesselAMI2D/constant/kinematicCloudProperties | 4 ++-- .../mixerVesselAMI2D/constant/transportProperties | 4 ++-- .../mixerVesselAMI2D/constant/turbulenceProperties | 4 ++-- .../mixerVesselAMI2D/system/blockMeshDict.m4 | 4 ++-- .../mixerVesselAMI2D/system/controlDict | 4 ++-- .../mixerVesselAMI2D/system/fvSchemes | 4 ++-- .../mixerVesselAMI2D/system/fvSolution | 4 ++-- .../reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh | 4 ++-- .../lagrangian/reactingParcelFoam/filter/0.orig/p_rgh | 4 ++-- .../lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh | 4 ++-- .../reactingParcelFoam/verticalChannel/0.orig/p_rgh | 4 ++-- .../reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh | 4 ++-- tutorials/mesh/parallel/filter/0.orig/p_rgh | 4 ++-- 81 files changed, 164 insertions(+), 163 deletions(-) diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H index 03625d89682..a854e75458d 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef smoluchowskiJumpTFvPatchScalarFields_H -#define smoluchowskiJumpTFvPatchScalarFields_H +#ifndef smoluchowskiJumpTFvPatchScalarField_H +#define smoluchowskiJumpTFvPatchScalarField_H #include "mixedFvPatchFields.H" @@ -43,7 +43,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class smoluchowskiJumpTFvPatch Declaration + Class smoluchowskiJumpTFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class smoluchowskiJumpTFvPatchScalarField @@ -74,6 +74,7 @@ class smoluchowskiJumpTFvPatchScalarField //- Heat capacity ratio (default 1.4) scalar gamma_; + public: //- Runtime type information diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H index 797bb765a0c..3dd4e261ad4 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H @@ -27,8 +27,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef solidRegionDiff_H -#define solidRegionDiff_H +#ifndef solidRegionDiffNo_H +#define solidRegionDiffNo_H #include "fvMesh.H" diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H index cc61acf6749..cdeb8aaf2a9 100644 --- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H +++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef flashThermo_H -#define flashThermo_H +#ifndef twoPhaseMixtureEThermo_H +#define twoPhaseMixtureEThermo_H #include "volFields.H" diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H index 738b7ae5704..ab24c737369 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef constant_H -#define constant_H +#ifndef diameterModels_constant_H +#define diameterModels_constant_H #include "diameterModel.H" diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H index 0d155ad16e0..8bdb54eff64 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::isothermal + Foam::diameterModels::isothermal Description Isothermal dispersed-phase particle diameter model. @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef isothermal_H -#define isothermal_H +#ifndef diameterModels_isothermal_H +#define diameterModels_isothermal_H #include "diameterModel.H" diff --git a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H index bbac62d50b3..23710027e3f 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H +++ b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H @@ -72,8 +72,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef function1_saturationModel_H -#define function1_saturationModel_H +#ifndef saturationModels_function1_H +#define saturationModels_function1_H #include "saturationModel.H" #include "Function1.H" diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H index 6f616c6f73d..fbf20426e8f 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef constant_H -#define constant_H +#ifndef diameterModels_constant_H +#define diameterModels_constant_H #include "diameterModel.H" diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H index 6e997a210ae..1d83bc575a8 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef isothermal_H -#define isothermal_H +#ifndef diameterModels_isothermal_H +#define diameterModels_isothermal_H #include "diameterModel.H" diff --git a/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H index e17039cd034..53c4fa494e6 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H +++ b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H @@ -33,8 +33,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef IndexedPolyhedron_H -#define IndexedPolyhedron_H +#ifndef CGALIndexedPolyhedron_H +#define CGALIndexedPolyhedron_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone index ed81df016e3..5158dde377b 100644 --- a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone +++ b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Web: www.OpenFOAM.org + \\ / A nd | Web: www.OpenFOAM.com \\/ M anipulation | ------------------------------------------------------------------------------- Description diff --git a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg index b68815887d5..1ba17a794f9 100644 --- a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg +++ b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H index 6e3b14ba0c0..ad78b17f553 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef Function1Fws_H -#define Function1Fws_H +#ifndef Function1Fwd_H +#define Function1Fwd_H #include "Function1.H" #include "vector.H" diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H index 763e71df514..8184600ff13 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H @@ -39,8 +39,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef compressibleAlphatPhaseChangeWallFunctionFvPatchScalarField_H -#define compressibleAlphatPhaseChangeWallFunctionFvPatchScalarField_H +#ifndef compressible_alphatPhaseChangeWallFunctionFvPatchScalarField_H +#define compressible_alphatPhaseChangeWallFunctionFvPatchScalarField_H #include "fixedValueFvPatchFields.H" diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H index ca4c35bc5d5..8aeddced40c 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H @@ -72,8 +72,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef compressibleAlphatWallFunctionFvPatchScalarField_H -#define compressibleAlphatWallFunctionFvPatchScalarField_H +#ifndef compressible_alphatWallFunctionFvPatchScalarField_H +#define compressible_alphatWallFunctionFvPatchScalarField_H #include "fixedValueFvPatchFields.H" diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H index eef6e95959b..55b0332e84a 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef IDDESDeltaDelta_H -#define IDDESDeltaDelta_H +#ifndef LESModels_IDDESDelta_H +#define LESModels_IDDESDelta_H #include "maxDeltaxyz.H" diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H index de439813221..f981aaf6eab 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef maxDeltaxyzDelta_H -#define maxDeltaxyzDelta_H +#ifndef LESModels_maxDeltaxyz_H +#define LESModels_maxDeltaxyz_H #include "LESdelta.H" diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H index d71c85ea810..2a4ab54c601 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H @@ -74,8 +74,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef turbulentMixingLengthDissipationRateInlet_H -#define turbulentMixingLengthDissipationRateInlet_H +#ifndef turbulentMixingLengthDissipationRateInletFvPatchScalarField_H +#define turbulentMixingLengthDissipationRateInletFvPatchScalarField_H #include "inletOutletFvPatchFields.H" diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H index 946f45d0762..2e5d92089cb 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef porousBafflePressureFvPatchFieldsFwd_H -#define porousBafflePressureFvPatchFieldsFwd_H +#ifndef porousBafflePressureFvPatchFieldFwd_H +#define porousBafflePressureFvPatchFieldFwd_H #include "fieldTypes.H" diff --git a/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H b/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H index 1b6499934fe..1adaed982b6 100644 --- a/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H +++ b/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H @@ -33,8 +33,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef SRFModelRpm_H -#define SRFModelRpm_H +#ifndef SRF_rpm_H +#define SRF_rpm_H #include "SRFModel.H" diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H index 3d4ffefe357..a173f7c6dda 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef options_H -#define options_H +#ifndef fv_options_H +#define fv_options_H #include "fvOptionList.H" #include "IOdictionary.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H index 1bdaee71b8a..9a1f051bf7e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H @@ -48,8 +48,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fixedFluxExtrapolatedPressureFvPatchScalarFields_H -#define fixedFluxExtrapolatedPressureFvPatchScalarFields_H +#ifndef fixedFluxExtrapolatedPressureFvPatchScalarField_H +#define fixedFluxExtrapolatedPressureFvPatchScalarField_H #include "fixedFluxPressureFvPatchScalarField.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H index aaafe055a90..94bfcf9feee 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H @@ -48,8 +48,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fixedFluxPressureFvPatchScalarFields_H -#define fixedFluxPressureFvPatchScalarFields_H +#ifndef fixedFluxPressureFvPatchScalarField_H +#define fixedFluxPressureFvPatchScalarField_H #include "fvPatchFields.H" #include "fixedGradientFvPatchFields.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H index e8b5f28114b..950e8908450 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H @@ -60,8 +60,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef freestreamPressureFvPatchScalarFields_H -#define freestreamPressureFvPatchScalarFields_H +#ifndef freestreamPressureFvPatchScalarField_H +#define freestreamPressureFvPatchScalarField_H #include "fvPatchFields.H" #include "zeroGradientFvPatchFields.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H index 54d0e92a699..69a6a04eab2 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H @@ -69,8 +69,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef supersonicFreestreamFvPatchVectorFields_H -#define supersonicFreestreamFvPatchVectorFields_H +#ifndef supersonicFreestreamFvPatchVectorField_H +#define supersonicFreestreamFvPatchVectorField_H #include "fvPatchFields.H" #include "mixedFvPatchFields.H" diff --git a/src/functionObjects/field/streamLine/streamLineParticleCloud.H b/src/functionObjects/field/streamLine/streamLineParticleCloud.H index 9fdbad50f5d..dfe1461a7e9 100644 --- a/src/functionObjects/field/streamLine/streamLineParticleCloud.H +++ b/src/functionObjects/field/streamLine/streamLineParticleCloud.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef streamLineCloud_H -#define streamLineCloud_H +#ifndef streamLineParticleCloud_H +#define streamLineParticleCloud_H #include "Cloud.H" #include "streamLineParticle.H" diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H index 8ce123d6a55..dc270ffa0d8 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef streamLineCloud_H -#define streamLineCloud_H +#ifndef wallBoundedStreamLineParticleCloud_H +#define wallBoundedStreamLineParticleCloud_H #include "Cloud.H" #include "wallBoundedStreamLineParticle.H" diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H b/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H index 855d307277a..bbff6f2de6a 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef makeParcelDispersionModels_h -#define makeParcelDispersionModels_h +#ifndef makeParcelDispersionModels_H +#define makeParcelDispersionModels_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H index 99a63183a27..336b29a1aa6 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationCloudAbsorptionEmission_H -#define radiationCloudAbsorptionEmission_H +#ifndef radiation_cloudAbsorptionEmission_H +#define radiation_cloudAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H index fa4a9338080..44b6de546c5 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationCloudScatter_H -#define radiationCloudScatter_H +#ifndef radiation_cloudScatter_H +#define radiation_cloudScatter_H #include "scatterModel.H" diff --git a/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H b/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H index f10a1220570..7d3473b062b 100644 --- a/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H +++ b/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef makeParcelTurbulenceDispersionModels_h -#define makeParcelTurbulenceDispersionModels_h +#ifndef makeParcelTurbulenceDispersionModels_H +#define makeParcelTurbulenceDispersionModels_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H b/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H index db6d224dd31..fccd7734b07 100644 --- a/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H +++ b/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H @@ -23,8 +23,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef makeThermoParcelTurbulenceForces_h -#define makeThermoParcelTurbulenceForces_h +#ifndef makeThermoParcelTurbulenceForces_H +#define makeThermoParcelTurbulenceForces_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H b/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H index f4709bb62e6..cb3185cbad6 100644 --- a/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H +++ b/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef mappedWallFvPatch_H -#define mappedWallFvPatch_H +#ifndef mappedVariableThicknessWallFvPatch_H +#define mappedVariableThicknessWallFvPatch_H #include "wallFvPatch.H" #include "mappedVariableThicknessWallPolyPatch.H" diff --git a/src/sampling/meshToMesh0/meshToMesh0.H b/src/sampling/meshToMesh0/meshToMesh0.H index 885d4baeb05..989173f0738 100644 --- a/src/sampling/meshToMesh0/meshToMesh0.H +++ b/src/sampling/meshToMesh0/meshToMesh0.H @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef meshtoMesh_H -#define meshtoMesh_H +#ifndef meshToMesh0_H +#define meshToMesh0_H #include "fvMesh.H" #include "HashTable.H" diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H index e3bbc0b4331..cde61c91b72 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H @@ -31,8 +31,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef none_H -#define none_H +#ifndef chemistryReductionMethods_none_H +#define chemistryReductionMethods_none_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H index 99952a51f68..d321fff5804 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H @@ -32,8 +32,8 @@ SourceFile \*---------------------------------------------------------------------------*/ -#ifndef BINARY_NODE_H -#define BINARY_NODE_H +#ifndef binaryNode_H +#define binaryNode_H #include "chemPointISAT.H" diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H index e0f5db3f60c..d37290e0169 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H @@ -33,8 +33,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef noChemistySolver_H -#define noChemistySolver_H +#ifndef noChemistrySolver_H +#define noChemistrySolver_H #include "chemistrySolver.H" diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H index d175c9e358a..5e9b7a11388 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H @@ -59,8 +59,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef MarshakRadiationMixedFvPatchField_H -#define MarshakRadiationMixedFvPatchField_H +#ifndef radiation_MarshakRadiationFvPatchScalarField_H +#define radiation_MarshakRadiationFvPatchScalarField_H #include "mixedFvPatchFields.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H index e52733e3eae..6532f8223c4 100644 --- a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H +++ b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H @@ -41,8 +41,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelP1_H -#define radiationModelP1_H +#ifndef radiation_P1_H +#define radiation_P1_H #include "radiationModel.H" #include "volFields.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H index d7f175fc5c6..c22319fc244 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef blackModyEmission_H -#define blackModyEmission_H +#ifndef radiation_blackBodyEmission_H +#define radiation_blackBodyEmission_H #include "volFields.H" #include "dimensionedScalar.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H index 3c00d3b2872..419389c30c3 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H @@ -74,8 +74,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelfvDOM_H -#define radiationModelfvDOM_H +#ifndef radiation_fvDOM_H +#define radiation_fvDOM_H #include "radiativeIntensityRay.H" #include "radiationModel.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H index 52e2e9a36e2..be1e993710c 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H @@ -59,8 +59,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelsolarLoad_H -#define radiationModelsolarLoad_H +#ifndef radiation_solarLoad_H +#define radiation_solarLoad_H #include "radiationModel.H" #include "singleCellFvMesh.H" diff --git a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H index 5bd75d92ae6..92ec802b459 100644 --- a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H +++ b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H @@ -45,8 +45,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationModelviewFactor_H -#define radiationModelviewFactor_H +#ifndef radiation_viewFactor_H +#define radiation_viewFactor_H #include "radiationModel.H" #include "singleCellFvMesh.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H index f02d4a079d9..8350cba6f7b 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H @@ -30,8 +30,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef radiationAbsorptionEmissionModel_H -#define radiationAbsorptionEmissionModel_H +#ifndef radiation_absorptionEmissionModel_H +#define radiation_absorptionEmissionModel_H #include "IOdictionary.H" #include "autoPtr.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H index 2771f938b61..cf9397aac53 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationBinaryAbsorptionEmission_H -#define radiationBinaryAbsorptionEmission_H +#ifndef radiation_binaryAbsorptionEmission_H +#define radiation_binaryAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H index 357a31d2ba4..18fc7f349e1 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantAbsorptionEmission_H -#define radiationConstantAbsorptionEmission_H +#ifndef radiation_constantAbsorptionEmission_H +#define radiation_constantAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H index 011df68dbb1..23ab5e9bb34 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationNoAbsorptionEmission_H -#define radiationNoAbsorptionEmission_H +#ifndef radiation_noAbsorptionEmission_H +#define radiation_noAbsorptionEmission_H #include "absorptionEmissionModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H index ac6357c3554..ccf024e6b22 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantScatter_H -#define radiationConstantScatter_H +#ifndef radiation_constantScatter_H +#define radiation_constantScatter_H #include "scatterModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H index 095b4d96692..2fb19569df2 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationNoScatter_H -#define radiationNoScatter_H +#ifndef radiation_noScatter_H +#define radiation_noScatter_H #include "scatterModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H b/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H index a3c2dee676b..2967f4c9595 100644 --- a/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H +++ b/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H @@ -29,8 +29,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef radiationsootModel_H -#define radiationsootModel_H +#ifndef radiation_sootModel_H +#define radiation_sootModel_H #include "IOdictionary.H" #include "autoPtr.H" diff --git a/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H b/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H index 44593c42ebe..e06c4e48298 100644 --- a/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H +++ b/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantTransmissivity_H -#define radiationConstantTransmissivity_H +#ifndef radiation_constantTransmissivity_H +#define radiation_constantTransmissivity_H #include "transmissivityModel.H" diff --git a/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H b/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H index 517bf43771b..9d264f82c6c 100644 --- a/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H +++ b/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef radiationConstantScatter_H -#define radiationConstantScatter_H +#ifndef radiation_noTransmissivity_H +#define radiation_noTransmissivity_H #include "transmissivityModel.H" diff --git a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H index 725ce90e3a8..4506f4cb6ea 100644 --- a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H +++ b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef heheuReactionThermo_H -#define heheuReactionThermo_H +#ifndef heheuPsiThermo_H +#define heheuPsiThermo_H #include "heThermo.H" diff --git a/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H b/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H index b5444f1e59a..b278c3c4605 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H +++ b/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H @@ -29,8 +29,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef makeSolidReactionThermo_H -#define makeSolidReactionThermo_H +#ifndef makeSolidReaction_H +#define makeSolidReaction_H #include "solidReaction.H" #include "IrreversibleReaction.H" diff --git a/tutorials/IO/fileHandler/0/U b/tutorials/IO/fileHandler/0/U index 75ed42fbdb4..04b73f9a935 100644 --- a/tutorials/IO/fileHandler/0/U +++ b/tutorials/IO/fileHandler/0/U @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/g b/tutorials/IO/fileHandler/constant/g index 0cc222ca345..4702e33f63d 100644 --- a/tutorials/IO/fileHandler/constant/g +++ b/tutorials/IO/fileHandler/constant/g @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/kinematicCloudPositions b/tutorials/IO/fileHandler/constant/kinematicCloudPositions index 1e2be4ebc84..f2d697e58e0 100644 --- a/tutorials/IO/fileHandler/constant/kinematicCloudPositions +++ b/tutorials/IO/fileHandler/constant/kinematicCloudPositions @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/kinematicCloudProperties b/tutorials/IO/fileHandler/constant/kinematicCloudProperties index 41b8c64e80d..a52b7d2a0a4 100644 --- a/tutorials/IO/fileHandler/constant/kinematicCloudProperties +++ b/tutorials/IO/fileHandler/constant/kinematicCloudProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/transportProperties b/tutorials/IO/fileHandler/constant/transportProperties index dbbab9e9f0a..375de077121 100644 --- a/tutorials/IO/fileHandler/constant/transportProperties +++ b/tutorials/IO/fileHandler/constant/transportProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/constant/turbulenceProperties b/tutorials/IO/fileHandler/constant/turbulenceProperties index c2c3b28a1b4..5eec0426726 100644 --- a/tutorials/IO/fileHandler/constant/turbulenceProperties +++ b/tutorials/IO/fileHandler/constant/turbulenceProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/blockMeshDict b/tutorials/IO/fileHandler/system/blockMeshDict index 359a48779aa..f67edf5308b 100644 --- a/tutorials/IO/fileHandler/system/blockMeshDict +++ b/tutorials/IO/fileHandler/system/blockMeshDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/controlDict b/tutorials/IO/fileHandler/system/controlDict index 2ac8dc57876..d2090358217 100644 --- a/tutorials/IO/fileHandler/system/controlDict +++ b/tutorials/IO/fileHandler/system/controlDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/decomposeParDict b/tutorials/IO/fileHandler/system/decomposeParDict index 0f07bb6aa8b..341581df062 100644 --- a/tutorials/IO/fileHandler/system/decomposeParDict +++ b/tutorials/IO/fileHandler/system/decomposeParDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/fvSchemes b/tutorials/IO/fileHandler/system/fvSchemes index 12c112d4e08..2d037571545 100644 --- a/tutorials/IO/fileHandler/system/fvSchemes +++ b/tutorials/IO/fileHandler/system/fvSchemes @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/IO/fileHandler/system/fvSolution b/tutorials/IO/fileHandler/system/fvSolution index 740eb61a4bc..b72ad9583f3 100644 --- a/tutorials/IO/fileHandler/system/fvSolution +++ b/tutorials/IO/fileHandler/system/fvSolution @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U index 843a28d50f4..8a3472efb14 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict index 180fa548d9f..098df40ce85 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g index 7db1127c4e7..e385acd7d9a 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions index 72e44ae6a1c..0e75a13567c 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties index d2c439ffa10..dc1b7a9f5ca 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties index 3a1bb800c6f..104081599aa 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties index c2c3b28a1b4..5eec0426726 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 index d6cc8a50c8c..9b6f8a5e2bc 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict index 3bf92c6e366..245a1149e04 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes index 9c5ef530909..93fc8434787 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution index b0b21145a2b..cb6c43877e5 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh index b51753afdff..430890dd3cb 100644 --- a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh index 889e4cf1113..42af2c294a2 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh index 14453a39681..70182381f81 100644 --- a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh index 462a0fa1054..616e1c783f6 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh index bab3fe3b901..6d61fe59762 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile diff --git a/tutorials/mesh/parallel/filter/0.orig/p_rgh b/tutorials/mesh/parallel/filter/0.orig/p_rgh index 889e4cf1113..42af2c294a2 100644 --- a/tutorials/mesh/parallel/filter/0.orig/p_rgh +++ b/tutorials/mesh/parallel/filter/0.orig/p_rgh @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile -- GitLab From c1b7854cf70d84dedbc8cf39f76b034201ab9111 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Tue, 7 Nov 2017 11:31:21 +0000 Subject: [PATCH 104/126] COMP: Removed unused variable --- src/lagrangian/basic/particle/particleIO.C | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C index 5ed13963da6..8115ad62f57 100644 --- a/src/lagrangian/basic/particle/particleIO.C +++ b/src/lagrangian/basic/particle/particleIO.C @@ -199,7 +199,6 @@ void Foam::particle::writePosition(Ostream& os) const p.position = position(); p.celli = celli_; - vector pos(position()); os.write(reinterpret_cast<const char*>(&p.position), s); } -- GitLab From 3611f03914f2ef5926c70af9a062d3636445c351 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Tue, 7 Nov 2017 11:31:21 +0000 Subject: [PATCH 105/126] COMP: Removed unused variable --- src/lagrangian/basic/particle/particleIO.C | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C index 5ed13963da6..8115ad62f57 100644 --- a/src/lagrangian/basic/particle/particleIO.C +++ b/src/lagrangian/basic/particle/particleIO.C @@ -199,7 +199,6 @@ void Foam::particle::writePosition(Ostream& os) const p.position = position(); p.celli = celli_; - vector pos(position()); os.write(reinterpret_cast<const char*>(&p.position), s); } -- GitLab From ec9a7cc0164f6d49208d509d552a2d623319fd85 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Tue, 7 Nov 2017 17:33:09 +0000 Subject: [PATCH 106/126] ENH: function objects - enabled 'fields' entry to use patterns for some objects --- .../postProcessing/postProcess/postProcess.C | 21 ++- .../db/functionObjects/writeFile/writeFile.C | 25 +++- .../db/functionObjects/writeFile/writeFile.H | 6 + .../include/addFunctionObjectOptions.H | 3 +- src/finiteVolume/Make/files | 4 + .../fieldSelection/fieldSelection.C | 85 +++++++++++ .../fieldSelection/fieldSelection.H | 139 ++++++++++++++++++ .../fieldSelection/fieldSelectionTemplates.C | 47 ++++++ .../fieldSelection/fileFieldSelection.C | 64 ++++++++ .../fieldSelection/fileFieldSelection.H | 115 +++++++++++++++ .../fileFieldSelectionTemplates.C | 77 ++++++++++ .../fieldSelection/solverFieldSelection.C | 81 ++++++++++ .../fieldSelection/solverFieldSelection.H | 89 +++++++++++ .../fieldSelection/volFieldSelection.C | 61 ++++++++ .../fieldSelection/volFieldSelection.H | 104 +++++++++++++ .../volFieldSelectionTemplates.C | 44 ++++++ .../fieldCoordinateSystemTransform.C | 32 ++-- .../fieldCoordinateSystemTransform.H | 3 +- .../field/fieldMinMax/fieldMinMax.C | 48 ++++-- .../field/fieldMinMax/fieldMinMax.H | 7 +- .../field/nearWallFields/nearWallFields.H | 2 +- .../regionSizeDistribution.C | 2 +- .../utilities/residuals/residuals.C | 46 +++--- .../utilities/residuals/residuals.H | 7 +- 24 files changed, 1043 insertions(+), 69 deletions(-) create mode 100644 src/finiteVolume/functionObjects/fieldSelection/fieldSelection.C create mode 100644 src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H create mode 100644 src/finiteVolume/functionObjects/fieldSelection/fieldSelectionTemplates.C create mode 100644 src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.C create mode 100644 src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.H create mode 100644 src/finiteVolume/functionObjects/fieldSelection/fileFieldSelectionTemplates.C create mode 100644 src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.C create mode 100644 src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.H create mode 100644 src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.C create mode 100644 src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.H create mode 100644 src/finiteVolume/functionObjects/fieldSelection/volFieldSelectionTemplates.C diff --git a/applications/utilities/postProcessing/postProcess/postProcess.C b/applications/utilities/postProcessing/postProcess/postProcess.C index 8a01c21eb44..884fe1d3983 100644 --- a/applications/utilities/postProcessing/postProcess/postProcess.C +++ b/applications/utilities/postProcessing/postProcess/postProcess.C @@ -39,6 +39,7 @@ Description #include "surfaceFields.H" #include "pointFields.H" #include "uniformDimensionedFields.H" +#include "fileFieldSelection.H" using namespace Foam; @@ -153,14 +154,14 @@ int main(int argc, char *argv[]) #include "createNamedMesh.H" // Initialize the set of selected fields from the command-line options - HashSet<word> selectedFields; + functionObjects::fileFieldSelection fields(mesh); if (args.optionFound("fields")) { - args.optionLookup("fields")() >> selectedFields; + args.optionLookup("fields")() >> fields; } if (args.optionFound("field")) { - selectedFields.insert(args.optionLookup("field")()); + fields.insert(args.optionLookup("field")()); } // Externally stored dictionary for functionObjectList @@ -170,7 +171,13 @@ int main(int argc, char *argv[]) // Construct functionObjectList autoPtr<functionObjectList> functionsPtr ( - functionObjectList::New(args, runTime, functionsDict, selectedFields) + functionObjectList::New + ( + args, + runTime, + functionsDict, + fields.selection() + ) ); forAll(timeDirs, timei) @@ -179,6 +186,8 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << endl; + fields.updateSelection(); + if (mesh.readUpdate() != polyMesh::UNCHANGED) { // Update functionObjectList if mesh changes @@ -187,7 +196,7 @@ int main(int argc, char *argv[]) args, runTime, functionsDict, - selectedFields + fields.selection() ); } @@ -200,7 +209,7 @@ int main(int argc, char *argv[]) args, runTime, mesh, - selectedFields, + fields.selection(), functionsPtr(), timei == timeDirs.size()-1 ); diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 3c71b2713d2..60a2a8b764f 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -150,7 +150,8 @@ Foam::functionObjects::writeFile::writeFile fileName_("undefined"), filePtr_(), writePrecision_(IOstream::defaultPrecision()), - writeToFile_(true) + writeToFile_(true), + writtenHeader_(false) {} @@ -167,7 +168,8 @@ Foam::functionObjects::writeFile::writeFile fileName_(fileName), filePtr_(), writePrecision_(IOstream::defaultPrecision()), - writeToFile_(true) + writeToFile_(true), + writtenHeader_(false) { read(dict); @@ -234,8 +236,13 @@ void Foam::functionObjects::writeFile::writeCommented const string& str ) const { - os << setw(1) << "#" << setw(1) << ' ' - << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str(); + os << setw(1) << "#"; + + if (str.size()) + { + os << setw(1) << ' ' + << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str(); + } } @@ -255,8 +262,8 @@ void Foam::functionObjects::writeFile::writeHeader const string& str ) const { - os << setw(1) << "#" << setw(1) << ' ' - << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str() << nl; + writeCommented(os, str); + os << nl; } @@ -267,4 +274,10 @@ void Foam::functionObjects::writeFile::writeTime(Ostream& os) const } +void Foam::functionObjects::writeFile::writeBreak(Ostream& os) const +{ + writeHeader(os, "==="); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index 1f7f1edfce3..918d86a1335 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -79,6 +79,9 @@ protected: //- Flag to enable/disable writing to file bool writeToFile_; + //- Flag to identify whether the header has been written + bool writtenHeader_; + // Protected Member Functions @@ -171,6 +174,9 @@ public: //- Write the current time to stream virtual void writeTime(Ostream& os) const; + //- Write a break marker to the stream + virtual void writeBreak(Ostream& os) const; + //- Write a (commented) header property and value pair template<class Type> void writeHeaderValue diff --git a/src/OpenFOAM/include/addFunctionObjectOptions.H b/src/OpenFOAM/include/addFunctionObjectOptions.H index 7747c16d4f8..35f8503e7d8 100644 --- a/src/OpenFOAM/include/addFunctionObjectOptions.H +++ b/src/OpenFOAM/include/addFunctionObjectOptions.H @@ -9,8 +9,7 @@ Foam::argList::addOption ( "fields", "list", - "Specify a list of fields to be processed, e.g. '(U T p)' - " - "regular expressions not currently supported" + "Specify a list of fields to be processed, e.g. '(U T p)'" ); Foam::argList::addOption ( diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index abdef097789..db88df52ae7 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -93,6 +93,10 @@ $(faceToCell)/MeshObjects/centredCFCFaceToCellStencilObject.C functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C functionObjects/volRegion/volRegion.C +functionObjects/fieldSelection/fieldSelection.C +functionObjects/fieldSelection/fileFieldSelection.C +functionObjects/fieldSelection/volFieldSelection.C +functionObjects/fieldSelection/solverFieldSelection.C fvPatchFields = fields/fvPatchFields $(fvPatchFields)/fvPatchField/fvPatchFields.C diff --git a/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.C new file mode 100644 index 00000000000..b8f9ad29ba9 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.C @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "fieldSelection.H" +#include "objectRegistry.H" +#include "dictionary.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::fieldSelection::fieldSelection +( + const objectRegistry& obr +) +: + HashSet<wordRe>(), + obr_(obr), + selection_() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::fieldSelection::~fieldSelection() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::fieldSelection::read(const dictionary& dict) +{ + dict.lookup("fields") >> *this; + + return true; +} + + +bool Foam::functionObjects::fieldSelection::containsPattern() const +{ + for (const wordRe& fieldName : *this) + { + if (fieldName.isPattern()) + { + return true; + } + } + + return false; +} + + +void Foam::functionObjects::fieldSelection::clearSelection() +{ + selection_.clear(); +} + + +bool Foam::functionObjects::fieldSelection::updateSelection() +{ + return false; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H new file mode 100644 index 00000000000..9d874f8322f --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::fieldSelection + +Description + Helper class to manage field selections + +SourceFiles + fieldSelection.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_fieldSelection_H +#define functionObjects_fieldSelection_H + +#include "HashSet.H" +#include "wordRe.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class dictionary; +class objectRegistry; + +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class fieldSelection Declaration +\*---------------------------------------------------------------------------*/ + +class fieldSelection +: + public HashSet<wordRe> +{ +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + fieldSelection(const fieldSelection&) = delete; + + +protected: + + // Protected member data + + //- Reference to the database + const objectRegistry& obr_; + + //- Current field selection + wordHashSet selection_; + + + // Protected Member Functions + + //- Add registered objects of a given type + template<class Type> + void addRegistered(wordHashSet& set) const; + + +public: + + //- Construct from object registry + fieldSelection(const objectRegistry& obr); + + + //- Destructor + virtual ~fieldSelection(); + + + // Member Functions + + //- Return the current field selection + const wordHashSet& selection() const + { + return selection_; + } + + //- Return the current field selection + wordHashSet& selection() + { + return selection_; + } + + //- Read the fieldSelection data from dictionary + virtual bool read(const dictionary& dict); + + //- Return whether the field names contain a pattern + virtual bool containsPattern() const; + + //- Clear the current selection + virtual void clearSelection(); + + //- Update the selection using current contents of obr_ + virtual bool updateSelection(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "fieldSelectionTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/fieldSelectionTemplates.C b/src/finiteVolume/functionObjects/fieldSelection/fieldSelectionTemplates.C new file mode 100644 index 00000000000..80c476a44e1 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/fieldSelectionTemplates.C @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "DynamicList.H" +#include "objectRegistry.H" + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +template<class Type> +void Foam::functionObjects::fieldSelection::addRegistered +( + wordHashSet& set +) const +{ + DynamicList<word> names; + for (const wordRe& name : *this) + { + names.append(obr_.names<Type>(name)); + } + + set.insert(names); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.C new file mode 100644 index 00000000000..9d55a553939 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.C @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "fileFieldSelection.H" +#include "objectRegistry.H" +#include "volMesh.H" +#include "fvPatchField.H" +#include "surfaceMesh.H" +#include "fvsPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::fileFieldSelection::fileFieldSelection +( + const objectRegistry& obr +) +: + fieldSelection(obr) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::fileFieldSelection::~fileFieldSelection() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::fileFieldSelection::updateSelection() +{ + wordHashSet oldSet; + oldSet.swap(selection_); + + addFileGeoFields<fvPatchField, volMesh>(selection_); + addFileGeoFields<fvsPatchField, surfaceMesh>(selection_); + + return selection_ != oldSet; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.H b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.H new file mode 100644 index 00000000000..d1d3a986c70 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.H @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::fileFieldSelection + +Description + Helper class to manage file-based field selections + +SourceFiles + fieldSelection.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_fileFieldSelection_H +#define functionObjects_fileFieldSelection_H + +#include "fieldSelection.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class IOobjectList; + +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class fileFieldSelection Declaration +\*---------------------------------------------------------------------------*/ + +class fileFieldSelection +: + public fieldSelection +{ +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + fileFieldSelection(const fileFieldSelection&) = delete; + + +protected: + + // Protected Member Functions + + //- Add registered GeometricField types to selection + template<template<class> class PatchType, class MeshType> + void addFileGeoFields(wordHashSet& set) const; + + //- Add objects of a given type + template<class Type> + void addFromFile + ( + const IOobjectList& allFileObjects, + wordHashSet& set + ) const; + + +public: + + //- Construct from object registry + fileFieldSelection(const objectRegistry& obr); + + + //- Destructor + virtual ~fileFieldSelection(); + + + // Member Functions + + //- Update the selection + virtual bool updateSelection(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "fileFieldSelectionTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelectionTemplates.C b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelectionTemplates.C new file mode 100644 index 00000000000..f915d049971 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelectionTemplates.C @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "IOobjectList.H" +#include "GeometricField.H" +#include "fvMesh.H" +#include "DynamicList.H" + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +template<class Type> +void Foam::functionObjects::fileFieldSelection::addFromFile +( + const IOobjectList& allFileObjects, + wordHashSet& set +) const +{ + DynamicList<word> names; + + for (const wordRe& fieldName : *this) + { + names.append(allFileObjects.names(Type::typeName, fieldName)); + } + + set.insert(names); +} + + +template<template<class> class PatchType, class MeshType> +void Foam::functionObjects::fileFieldSelection::addFileGeoFields +( + wordHashSet& set +) const +{ + const fvMesh& mesh = static_cast<const fvMesh&>(obr_); + + const IOobjectList allObjects(mesh, mesh.time().timeName()); + + addFromFile<GeometricField<scalar, PatchType, MeshType>>(allObjects, set); + addFromFile<GeometricField<vector, PatchType, MeshType>>(allObjects, set); + addFromFile<GeometricField<sphericalTensor, PatchType, MeshType>> + ( + allObjects, + set + ); + addFromFile<GeometricField<symmTensor, PatchType, MeshType>> + ( + allObjects, + set + ); + addFromFile<GeometricField<tensor, PatchType, MeshType>>(allObjects, set); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.C new file mode 100644 index 00000000000..d7508642d22 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.C @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "solverFieldSelection.H" +#include "fvMesh.H" +#include "volMesh.H" +#include "fvPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::solverFieldSelection::solverFieldSelection +( + const objectRegistry& obr +) +: + volFieldSelection(obr) +{ + if (!isA<fvMesh>(obr)) + { + FatalErrorInFunction + << "Registry must be of type " << fvMesh::typeName + << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::solverFieldSelection::~solverFieldSelection() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::solverFieldSelection::updateSelection() +{ + wordHashSet oldSet; + oldSet.swap(selection_); + + wordHashSet volFields; + addRegisteredGeoFields<fvPatchField, volMesh>(volFields); + + const fvMesh& mesh = static_cast<const fvMesh&>(obr_); + + const Foam::dictionary& solverDict = mesh.solverPerformanceDict(); + + for (const word& fieldName : volFields) + { + if (solverDict.found(fieldName)) + { + selection_.insert(fieldName); + } + } + + return selection_ != oldSet; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.H b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.H new file mode 100644 index 00000000000..55d860a1995 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.H @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::volFieldSelection + +Description + Helper class to manage volume field selections + +SourceFiles + volFieldSelection.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_solverFieldSelection_H +#define functionObjects_solverFieldSelection_H + +#include "volFieldSelection.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class solverFieldSelection Declaration +\*---------------------------------------------------------------------------*/ + +class solverFieldSelection +: + public volFieldSelection +{ +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + solverFieldSelection(const solverFieldSelection&) = delete; + + +public: + + //- Construct from object registry + solverFieldSelection(const objectRegistry& obr); + + + //- Destructor + virtual ~solverFieldSelection(); + + + // Member Functions + + //- Update the selection using current contents of obr_ + virtual bool updateSelection(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.C new file mode 100644 index 00000000000..b0b61eb5243 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "volFieldSelection.H" +#include "volMesh.H" +#include "fvPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::volFieldSelection::volFieldSelection +( + const objectRegistry& obr +) +: + fieldSelection(obr) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::volFieldSelection::~volFieldSelection() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::volFieldSelection::updateSelection() +{ + wordHashSet oldSet; + + oldSet.swap(selection_); + + addRegisteredGeoFields<fvPatchField, volMesh>(selection_); + + return selection_ != oldSet; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.H b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.H new file mode 100644 index 00000000000..cad0440bd73 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.H @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::volFieldSelection + +Description + Helper class to manage volume field selections + +SourceFiles + volFieldSelection.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_volFieldSelection_H +#define functionObjects_volFieldSelection_H + +#include "fieldSelection.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class volFieldSelection Declaration +\*---------------------------------------------------------------------------*/ + +class volFieldSelection +: + public fieldSelection +{ +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + volFieldSelection(const volFieldSelection&) = delete; + + +protected: + + // Protected Member Functions + + //- Add registered GeometricField types to selection + template<template<class> class PatchType, class MeshType> + void addRegisteredGeoFields(wordHashSet& set) const; + + +public: + + //- Construct from object registry + volFieldSelection(const objectRegistry& obr); + + + //- Destructor + virtual ~volFieldSelection(); + + + // Member Functions + + //- Update the selection using current contents of obr_ + virtual bool updateSelection(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "volFieldSelectionTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/functionObjects/fieldSelection/volFieldSelectionTemplates.C b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelectionTemplates.C new file mode 100644 index 00000000000..f1e0ea195f0 --- /dev/null +++ b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelectionTemplates.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "volFields.H" + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +template<template<class> class PatchType, class MeshType> +void Foam::functionObjects::volFieldSelection::addRegisteredGeoFields +( + wordHashSet& set +) const +{ + addRegistered<GeometricField<scalar, PatchType, MeshType>>(set); + addRegistered<GeometricField<vector, PatchType, MeshType>>(set); + addRegistered<GeometricField<sphericalTensor, PatchType, MeshType>>(set); + addRegistered<GeometricField<symmTensor, PatchType, MeshType>>(set); + addRegistered<GeometricField<tensor, PatchType, MeshType>>(set); +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C index 296fb0d081a..2c4ea97f34d 100644 --- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,7 +55,7 @@ fieldCoordinateSystemTransform ) : fvMeshFunctionObject(name, runTime, dict), - fieldSet_(), + fieldSet_(mesh_), coordSys_(mesh_, dict.subDict("coordinateSystem")) { read(dict); @@ -90,23 +90,27 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::read const dictionary& dict ) { - fvMeshFunctionObject::read(dict); - - dict.lookup("fields") >> fieldSet_; + if (fvMeshFunctionObject::read(dict)) + { + fieldSet_.read(dict); + return true; + } - return true; + return false; } bool Foam::functionObjects::fieldCoordinateSystemTransform::execute() { - forAll(fieldSet_, fieldi) + fieldSet_.updateSelection(); + + for (const word& fieldName : fieldSet_.selection()) { - transform<scalar>(fieldSet_[fieldi]); - transform<vector>(fieldSet_[fieldi]); - transform<sphericalTensor>(fieldSet_[fieldi]); - transform<symmTensor>(fieldSet_[fieldi]); - transform<tensor>(fieldSet_[fieldi]); + transform<scalar>(fieldName); + transform<vector>(fieldName); + transform<sphericalTensor>(fieldName); + transform<symmTensor>(fieldName); + transform<tensor>(fieldName); } return true; @@ -115,9 +119,9 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::execute() bool Foam::functionObjects::fieldCoordinateSystemTransform::write() { - forAll(fieldSet_, fieldi) + forAllConstIters(fieldSet_, iter) { - writeObject(transformFieldName(fieldSet_[fieldi])); + writeObject(transformFieldName(iter())); } return true; diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H index f588d4f7341..dbc0446cb7f 100644 --- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H +++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H @@ -83,6 +83,7 @@ SourceFiles #include "fvMeshFunctionObject.H" #include "coordinateSystem.H" +#include "volFieldSelection.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -104,7 +105,7 @@ protected: // Protected data //- Fields to transform - wordList fieldSet_; + volFieldSelection fieldSet_; //- Co-ordinate system to transform to coordinateSystem coordSys_; diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/functionObjects/field/fieldMinMax/fieldMinMax.C index 35d68b92f0a..5d3e3f0bfdb 100644 --- a/src/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.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 | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,9 +51,22 @@ Foam::functionObjects::fieldMinMax::modeTypeNames_ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const +void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) { - writeHeader(os, "Field minima and maxima"); + if (!fieldSet_.updateSelection()) + { + return; + } + + if (writtenHeader_) + { + writeBreak(file()); + } + else + { + writeHeader(os, "Field minima and maxima"); + } + writeCommented(os, "Time"); if (location_) @@ -77,14 +90,17 @@ void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const } else { - forAll(fieldSet_, fieldi) + forAllConstIters(fieldSet_.selection(), iter) { - writeTabbed(os, "min(" + fieldSet_[fieldi] + ')'); - writeTabbed(os, "max(" + fieldSet_[fieldi] + ')'); + const word& fieldName = iter(); + writeTabbed(os, "min(" + fieldName + ')'); + writeTabbed(os, "max(" + fieldName + ')'); } } os << endl; + + writtenHeader_ = true; } @@ -101,10 +117,9 @@ Foam::functionObjects::fieldMinMax::fieldMinMax writeFile(mesh_, name, typeName, dict), location_(true), mode_(mdMag), - fieldSet_() + fieldSet_(mesh_) { read(dict); - writeFileHeader(file()); } @@ -124,7 +139,8 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict) location_ = dict.lookupOrDefault<Switch>("location", true); mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag); - dict.lookup("fields") >> fieldSet_; + + fieldSet_.read(dict); return true; } @@ -138,16 +154,18 @@ bool Foam::functionObjects::fieldMinMax::execute() bool Foam::functionObjects::fieldMinMax::write() { + writeFileHeader(file()); + if (!location_) writeTime(file()); Log << type() << " " << name() << " write:" << nl; - forAll(fieldSet_, fieldi) + for (const word& fieldName : fieldSet_.selection()) { - calcMinMaxFields<scalar>(fieldSet_[fieldi], mdCmpt); - calcMinMaxFields<vector>(fieldSet_[fieldi], mode_); - calcMinMaxFields<sphericalTensor>(fieldSet_[fieldi], mode_); - calcMinMaxFields<symmTensor>(fieldSet_[fieldi], mode_); - calcMinMaxFields<tensor>(fieldSet_[fieldi], mode_); + calcMinMaxFields<scalar>(fieldName, mdCmpt); + calcMinMaxFields<vector>(fieldName, mode_); + calcMinMaxFields<sphericalTensor>(fieldName, mode_); + calcMinMaxFields<symmTensor>(fieldName, mode_); + calcMinMaxFields<tensor>(fieldName, mode_); } if (!location_) file()<< endl; diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/functionObjects/field/fieldMinMax/fieldMinMax.H index 588dc5c7fdd..9f7cd954a89 100644 --- a/src/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -82,6 +82,7 @@ SourceFiles #include "fvMeshFunctionObject.H" #include "writeFile.H" #include "vector.H" +#include "volFieldSelection.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -124,7 +125,7 @@ protected: modeType mode_; //- Fields to assess min/max - wordList fieldSet_; + volFieldSelection fieldSet_; // Protected Member Functions @@ -147,7 +148,7 @@ protected: //- Output file header information - virtual void writeFileHeader(Ostream& os) const; + virtual void writeFileHeader(Ostream& os); //- Disallow default bitwise copy construct fieldMinMax(const fieldMinMax&) = delete; diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.H b/src/functionObjects/field/nearWallFields/nearWallFields.H index 9a2850c20a5..85c67d9b2da 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.H +++ b/src/functionObjects/field/nearWallFields/nearWallFields.H @@ -107,7 +107,7 @@ protected: // Read from dictionary - //- Fields to process + //- Fields to process (input-name output-name) List<Tuple2<word, word>> fieldSet_; //- Switch to send output to Info as well as to file diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 8ae33b507f4..bf8a4a38560 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -860,7 +860,7 @@ bool Foam::functionObjects::regionSizeDistribution::write() forAll(selected, i) { const word& fldName = scalarNames[selected[i]]; - Log << " Scalar field " << fldName << endl; + Log << " Scalar field " << fldName << endl; const scalarField& fld = obr_.lookupObject < diff --git a/src/functionObjects/utilities/residuals/residuals.C b/src/functionObjects/utilities/residuals/residuals.C index a9f41a02b1b..0cdf2c6d978 100644 --- a/src/functionObjects/utilities/residuals/residuals.C +++ b/src/functionObjects/utilities/residuals/residuals.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,15 +46,26 @@ namespace functionObjects // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // -void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) const +void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) { - writeHeader(os, "Residuals"); - writeCommented(os, "Time"); + if (!fieldSet_.updateSelection()) + { + return; + } - forAll(fieldSet_, fieldi) + if (writtenHeader_) + { + writeBreak(file()); + } + else { - const word& fieldName = fieldSet_[fieldi]; + writeHeader(os, "Residuals"); + } + + writeCommented(os, "Time"); + for (const word& fieldName : fieldSet_.selection()) + { writeFileHeader<scalar>(os, fieldName); writeFileHeader<vector>(os, fieldName); writeFileHeader<sphericalTensor>(os, fieldName); @@ -63,6 +74,8 @@ void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) const } os << endl; + + writtenHeader_ = true; } @@ -77,10 +90,9 @@ Foam::functionObjects::residuals::residuals : fvMeshFunctionObject(name, runTime, dict), writeFile(obr_, name, typeName, dict), - fieldSet_() + fieldSet_(mesh_) { read(dict); - writeFileHeader(file()); } @@ -94,13 +106,13 @@ Foam::functionObjects::residuals::~residuals() bool Foam::functionObjects::residuals::read(const dictionary& dict) { - fvMeshFunctionObject::read(dict); - - wordList allFields(dict.lookup("fields")); - wordHashSet uniqueFields(allFields); - fieldSet_ = uniqueFields.toc(); + if (fvMeshFunctionObject::read(dict)) + { + fieldSet_.read(dict); + return true; + } - return true; + return false; } @@ -114,12 +126,12 @@ bool Foam::functionObjects::residuals::write() { if (Pstream::master()) { + writeFileHeader(file()); + writeTime(file()); - forAll(fieldSet_, fieldi) + for (const word& fieldName : fieldSet_.selection()) { - const word& fieldName = fieldSet_[fieldi]; - writeResidual<scalar>(fieldName); writeResidual<vector>(fieldName); writeResidual<sphericalTensor>(fieldName); diff --git a/src/functionObjects/utilities/residuals/residuals.H b/src/functionObjects/utilities/residuals/residuals.H index 283e4738da8..02e2db2843c 100644 --- a/src/functionObjects/utilities/residuals/residuals.H +++ b/src/functionObjects/utilities/residuals/residuals.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,6 +62,7 @@ SourceFiles #include "fvMeshFunctionObject.H" #include "writeFile.H" +#include "solverFieldSelection.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -84,13 +85,13 @@ protected: // Protected data //- Fields to write residuals - wordList fieldSet_; + solverFieldSelection fieldSet_; // Protected Member Functions //- Output file header information - void writeFileHeader(Ostream& os) const; + void writeFileHeader(Ostream& os); //- Output file header information per primitive type value template<class Type> -- GitLab From ba39777818920d5b8cc5524de3dbccd215d671bd Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Wed, 8 Nov 2017 08:48:48 +0000 Subject: [PATCH 107/126] COMP: Resolved compiler warnings --- .../slidingInterface/coupleSlidingInterface.C | 6 +++--- .../slidingInterface/enrichedPatch/enrichedPatch.C | 2 +- .../slidingInterfaceAttachedAddressing.C | 10 ++++------ .../slidingInterface/slidingInterfaceProjectPoints.C | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C index 9257fa57d25..edcdbb64a02 100644 --- a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C @@ -468,7 +468,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const completed = addedFaces.found(endFace); // Add all face neighbours of face in the map - const labelList cf(std::move(addedFaces.toc())); + const labelList cf(addedFaces.toc()); addedFaces.clear(); for (const label cfi : cf) @@ -518,7 +518,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const completed = addedFaces.found(startFace); // Add all face neighbours of face in the map - const labelList cf(std::move(addedFaces.toc())); + const labelList cf(addedFaces.toc()); addedFaces.clear(); for (const label cfi : cf) @@ -580,7 +580,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const ); } - const labelList curMasterEdges(std::move(curMasterEdgesMap.toc())); + const labelList curMasterEdges(curMasterEdgesMap.toc()); curMasterEdgesMap.clear(); // For all master edges to intersect, skip the ones diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C index e4df4bc133c..184216ac657 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C @@ -47,7 +47,7 @@ void Foam::enrichedPatch::calcMeshPoints() const << abort(FatalError); } - meshPointsPtr_ = new labelList(std::move(pointMap().toc())); + meshPointsPtr_ = new labelList(pointMap().toc()); labelList& mp = *meshPointsPtr_; sort(mp); diff --git a/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C b/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C index 305db3f376d..29a26d62af2 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C +++ b/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C @@ -174,12 +174,11 @@ void Foam::slidingInterface::calcAttachedAddressing() const if (debug) { masterStickOutFacesPtr_ = - new labelList(std::move(stickOutFaceMap.sortedToc())); + new labelList(stickOutFaceMap.sortedToc()); } else { - masterStickOutFacesPtr_ = - new labelList(std::move(stickOutFaceMap.toc())); + masterStickOutFacesPtr_ = new labelList(stickOutFaceMap.toc()); } // Slave side @@ -210,12 +209,11 @@ void Foam::slidingInterface::calcAttachedAddressing() const if (debug) { slaveStickOutFacesPtr_ = - new labelList(std::move(stickOutFaceMap.sortedToc())); + new labelList(stickOutFaceMap.sortedToc()); } else { - slaveStickOutFacesPtr_ = - new labelList(std::move(stickOutFaceMap.toc())); + slaveStickOutFacesPtr_ = new labelList(stickOutFaceMap.toc()); } stickOutFaceMap.clear(); diff --git a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C index 9e52c5f1037..2969cfa1a7c 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C +++ b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C @@ -778,7 +778,7 @@ bool Foam::slidingInterface::projectPoints() const completed = addedFaces.found(endFace); // Add all face neighbours of face in the map - const labelList cf(std::move(addedFaces.toc())); + const labelList cf(addedFaces.toc()); addedFaces.clear(); for (const label cfi : cf) @@ -829,7 +829,7 @@ bool Foam::slidingInterface::projectPoints() const completed = addedFaces.found(startFace); // Add all face neighbours of face in the map - const labelList cf(std::move(addedFaces.toc())); + const labelList cf(addedFaces.toc()); addedFaces.clear(); for (const label cfi : cf) -- GitLab From 9edc0c15fe8b13d25dbb926ea123db31b246dd69 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 8 Nov 2017 14:54:57 +0100 Subject: [PATCH 108/126] ENH: add rmDir silent option for all fileOperations implementations --- .../decomposePar/decomposePar.C | 6 +++++- .../fileOperation/fileOperation.H | 7 ++++++- .../masterUncollatedFileOperation.C | 5 +++-- .../masterUncollatedFileOperation.H | 18 ++++++++++++++++-- .../uncollatedFileOperation.C | 5 +++-- .../uncollatedFileOperation.H | 6 +++++- 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 50a70387ee6..b06da4f4a72 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -404,7 +404,11 @@ int main(int argc, char *argv[]) Info<< "Removing " << nProcs << " existing processor directories" << endl; - fileHandler().rmDir(runTime.path()/word("processors")); + fileHandler().rmDir + ( + runTime.path()/word("processors"), + true // silent (may not have been collated) + ); // remove existing processor dirs // reverse order to avoid gaps if someone interrupts the process diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H index 6e776320d0a..f7044aa08e5 100644 --- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H +++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H @@ -247,7 +247,12 @@ public: virtual bool rm(const fileName&) const = 0; //- Remove a dirctory and its contents - virtual bool rmDir(const fileName&) const = 0; + // \param silent do not report missing directory + virtual bool rmDir + ( + const fileName& dir, + const bool silent = false + ) const = 0; // //- Open a shared library. Return handle to library. Print error // // message if library cannot be loaded (check = true) diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C index f436b45776e..41c949fe501 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C @@ -630,10 +630,11 @@ bool Foam::fileOperations::masterUncollatedFileOperation::rm bool Foam::fileOperations::masterUncollatedFileOperation::rmDir ( - const fileName& dir + const fileName& dir, + const bool silent ) const { - return masterOp<bool, rmDirOp>(dir, rmDirOp()); + return masterOp<bool, rmDirOp>(dir, rmDirOp(silent)); } diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H index 5061b1e5cf8..b57ced6153a 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H @@ -249,10 +249,19 @@ protected: class rmDirOp { + bool silent_; public: + rmDirOp() + : + silent_(false) + {} + rmDirOp(const bool silent) + : + silent_(silent) + {} bool operator()(const fileName& fName) const { - return Foam::rmDir(fName); + return Foam::rmDir(fName, silent_); } }; @@ -533,7 +542,12 @@ public: virtual bool rm(const fileName&) const; //- Remove a dirctory and its contents - virtual bool rmDir(const fileName&) const; + // \param silent do not report missing directory + virtual bool rmDir + ( + const fileName& dir, + const bool silent = false + ) const; // //- Open a shared library. Return handle to library. Print error // // message if library cannot be loaded (check = true) diff --git a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C index e6a509e74c2..66e51751fef 100644 --- a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C @@ -292,10 +292,11 @@ bool Foam::fileOperations::uncollatedFileOperation::rm bool Foam::fileOperations::uncollatedFileOperation::rmDir ( - const fileName& dir + const fileName& dir, + const bool silent ) const { - return Foam::rmDir(dir); + return Foam::rmDir(dir, silent); } diff --git a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H index f2d624a9c9d..8e750214e32 100644 --- a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H +++ b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H @@ -192,7 +192,11 @@ public: virtual bool rm(const fileName&) const; //- Remove a dirctory and its contents - virtual bool rmDir(const fileName&) const; + virtual bool rmDir + ( + const fileName& dir, + const bool silent = false + ) const; // //- Open a shared library. Return handle to library. Print error // // message if library cannot be loaded (check = true) -- GitLab From 8d5f28bcc000415fccd95ebd7b97d5aea62f7ba5 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 8 Nov 2017 17:43:28 +0100 Subject: [PATCH 109/126] ENH: dictionary add/set methods now return a pointer to the entry - If the entry could be directly inserted: a pointer to the inserted entry. - If a dictionary merge was required: a pointer to the dictionary that received the entry. - Return nullptr on any type of insertion failure. This change is code compatible with existing code since it only alters a bool return value to be a pointer return value. --- applications/test/dictionary2/Make/files | 3 + applications/test/dictionary2/Make/options | 1 + .../test/dictionary2/Test-dictionary2.C | 140 ++++++++++++++++++ src/OpenFOAM/db/dictionary/dictionary.C | 70 +++++---- src/OpenFOAM/db/dictionary/dictionary.H | 42 ++++-- .../db/dictionary/dictionaryTemplates.C | 8 +- .../db/dictionary/functionEntries/README | 2 +- 7 files changed, 222 insertions(+), 44 deletions(-) create mode 100644 applications/test/dictionary2/Make/files create mode 100644 applications/test/dictionary2/Make/options create mode 100644 applications/test/dictionary2/Test-dictionary2.C diff --git a/applications/test/dictionary2/Make/files b/applications/test/dictionary2/Make/files new file mode 100644 index 00000000000..397d8d53cb6 --- /dev/null +++ b/applications/test/dictionary2/Make/files @@ -0,0 +1,3 @@ +Test-dictionary2.C + +EXE = $(FOAM_USER_APPBIN)/Test-dictionary2 diff --git a/applications/test/dictionary2/Make/options b/applications/test/dictionary2/Make/options new file mode 100644 index 00000000000..41306609f20 --- /dev/null +++ b/applications/test/dictionary2/Make/options @@ -0,0 +1 @@ +EXE_INC = diff --git a/applications/test/dictionary2/Test-dictionary2.C b/applications/test/dictionary2/Test-dictionary2.C new file mode 100644 index 00000000000..9d01161e3e9 --- /dev/null +++ b/applications/test/dictionary2/Test-dictionary2.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Application + Test-dictionary2 + +Description + + Test dictionary insertion + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "IOstreams.H" +#include "IOobject.H" +#include "IFstream.H" +#include "dictionary.H" +#include "stringOps.H" + +using namespace Foam; + +void entryInfo(entry* e) +{ + if (e) + { + Info<<"added " + << e->keyword() << ": " << typeid(e).name() << nl; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noBanner(); + argList::noParallel(); + + argList args(argc, argv); + + dictionary dict1; + for (label i=0; i<5; ++i) + { + dictionary tmpdict; + + { + entry* e = dict1.add + ( + Foam::name("entry%d", i), + string("entry" + Foam::name(i)) + ); + entryInfo(e); + } + + { + entry* e = tmpdict.add + ( + Foam::name("subentry%d", i), + string("subentry" + Foam::name(i)) + ); + entryInfo(e); + } + + { + entry* e = dict1.add + ( + Foam::name("dict%d", i), + tmpdict + ); + entryInfo(e); + } + } + + // Insert new dictionary or merge into existing one + for (auto k : { "dict1", "dict10" }) + { + const word key(k); + entry* e = dict1.add(key, dictionary(), true); + + if (e && e->isDict()) + { + e->dict().add(word("sub1" + key), 10); + e->dict().add(word("sub2" + key), 20); + e->dict().add(word("sub3" + key), 30); + e->dict().add(word("sub4" + key), 40); + e->dict().add(word("sub5" + key), 50); + e->dict().add(word("sub6" + key), 60); + } + } + + + // overwrite existing + { + entry* e = dict1.set(word("dict2"), 1000); // overwrite + entryInfo(e); + } + + // merge into existing dictionary: returns pointer to existing dict + { + dictionary tmpdict; + tmpdict.add(word("something"), 3.14159); + + entry* e = dict1.add(word("dict4"), tmpdict, true); // merge + entryInfo(e); + + if (e) + Info<< nl << "=> " << *e << nl; + } + + Info<< nl << "dictionary" << nl << nl; + dict1.write(Info, false); + + Info<< "\nDone\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index d5815133b53..2a569fb8afc 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -532,11 +532,11 @@ Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const } -bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) +Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry) { if (!entryPtr) { - return false; + return nullptr; } auto iter = hashedEntries_.find(entryPtr->keyword()); @@ -549,7 +549,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) iter()->dict().merge(entryPtr->dict()); delete entryPtr; - return true; + return iter(); // pointer to existing dictionary } @@ -571,7 +571,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) ); } - return true; + return entryPtr; // now an entry in the dictionary } @@ -582,7 +582,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) parent_type::remove(entryPtr); delete entryPtr; - return false; + return nullptr; } @@ -600,71 +600,86 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) ); } - return true; + return entryPtr; // now an entry in the dictionary } IOWarningInFunction((*this)) - << "attempt to add entry "<< entryPtr->keyword() + << "attempt to add entry " << entryPtr->keyword() << " which already exists in dictionary " << name() << endl; delete entryPtr; - return false; + return nullptr; } -void Foam::dictionary::add(const entry& e, bool mergeEntry) +Foam::entry* Foam::dictionary::add(const entry& e, bool mergeEntry) { - add(e.clone(*this).ptr(), mergeEntry); + return add(e.clone(*this).ptr(), mergeEntry); } -void Foam::dictionary::add(const keyType& k, const word& v, bool overwrite) +Foam::entry* Foam::dictionary::add +( + const keyType& k, + const word& v, + bool overwrite +) { - add(new primitiveEntry(k, token(v)), overwrite); + return add(new primitiveEntry(k, token(v)), overwrite); } -void Foam::dictionary::add +Foam::entry* Foam::dictionary::add ( const keyType& k, const Foam::string& v, bool overwrite ) { - add(new primitiveEntry(k, token(v)), overwrite); + return add(new primitiveEntry(k, token(v)), overwrite); } -void Foam::dictionary::add(const keyType& k, const label v, bool overwrite) +Foam::entry* Foam::dictionary::add +( + const keyType& k, + const label v, + bool overwrite +) { - add(new primitiveEntry(k, token(v)), overwrite); + return add(new primitiveEntry(k, token(v)), overwrite); } -void Foam::dictionary::add(const keyType& k, const scalar v, bool overwrite) +Foam::entry* Foam::dictionary::add +( + const keyType& k, + const scalar v, + bool overwrite +) { - add(new primitiveEntry(k, token(v)), overwrite); + return add(new primitiveEntry(k, token(v)), overwrite); } -void Foam::dictionary::add +Foam::entry* Foam::dictionary::add ( const keyType& k, const dictionary& v, bool mergeEntry ) { - add(new dictionaryEntry(k, *this, v), mergeEntry); + return add(new dictionaryEntry(k, *this, v), mergeEntry); } -void Foam::dictionary::set(entry* entryPtr) +Foam::entry* Foam::dictionary::set(entry* entryPtr) { if (!entryPtr) { - return; + return nullptr; } // Find non-recursive with patterns @@ -675,19 +690,20 @@ void Foam::dictionary::set(entry* entryPtr) { finder.dict().clear(); } - add(entryPtr, true); + + return add(entryPtr, true); } -void Foam::dictionary::set(const entry& e) +Foam::entry* Foam::dictionary::set(const entry& e) { - set(e.clone(*this).ptr()); + return set(e.clone(*this).ptr()); } -void Foam::dictionary::set(const keyType& k, const dictionary& v) +Foam::entry* Foam::dictionary::set(const keyType& k, const dictionary& v) { - set(new dictionaryEntry(k, *this, v)); + return set(new dictionaryEntry(k, *this, v)); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 918ee9b7fe5..a4b8623c54b 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -684,32 +684,42 @@ public: //- Add a new entry. // \param mergeEntry dictionaries are interwoven and primitive // entries are overwritten - bool add(entry* entryPtr, bool mergeEntry=false); + // \return pointer to inserted entry, or place of merging + // or nullptr on failure + entry* add(entry* entryPtr, bool mergeEntry=false); //- Add an entry. // \param mergeEntry dictionaries are interwoven and primitive // entries are overwritten - void add(const entry& e, bool mergeEntry=false); + // \return pointer to inserted entry, or place of merging + // or nullptr on failure + entry* add(const entry& e, bool mergeEntry=false); //- Add a word entry. // \param overwrite force overwrite of an existing entry. - void add(const keyType& k, const word& v, bool overwrite=false); + // \return pointer to inserted entry or nullptr on failure + entry* add(const keyType& k, const word& v, bool overwrite=false); //- Add a string entry. // \param overwrite force overwrite of an existing entry. - void add(const keyType& k, const string& v, bool overwrite=false); + // \return pointer to inserted entry or nullptr on failure + entry* add(const keyType& k, const string& v, bool overwrite=false); //- Add a label entry. // \param overwrite force overwrite of an existing entry. - void add(const keyType& k, const label v, bool overwrite=false); + // \return pointer to inserted entry or nullptr on failure + entry* add(const keyType& k, const label v, bool overwrite=false); //- Add a scalar entry. // \param overwrite force overwrite of an existing entry. - void add(const keyType& k, const scalar v, bool overwrite=false); + // \return pointer to inserted entry or nullptr on failure + entry* add(const keyType& k, const scalar v, bool overwrite=false); //- Add a dictionary entry. // \param mergeEntry merge into an existing sub-dictionary - void add + // \return pointer to inserted entry, or place of merging + // or nullptr on failure + entry* add ( const keyType& k, const dictionary& d, @@ -718,21 +728,29 @@ public: //- Add a T entry // \param overwrite force overwrite of existing entry + // \return pointer to inserted entry or nullptr on failure template<class T> - void add(const keyType& k, const T& v, bool overwrite=false); + entry* add(const keyType& k, const T& v, bool overwrite=false); //- Assign a new entry, overwriting any existing entry. - void set(entry* entryPtr); + // + // \return pointer to inserted entry or nullptr on failure + entry* set(entry* entryPtr); //- Assign a new entry, overwriting any existing entry. - void set(const entry& e); + // + // \return pointer to inserted entry or nullptr on failure + entry* set(const entry& e); //- Assign a dictionary entry, overwriting any existing entry. - void set(const keyType& k, const dictionary& v); + // + // \return pointer to inserted entry or nullptr on failure + entry* set(const keyType& k, const dictionary& v); //- Assign a T entry, overwriting any existing entry. + // \return pointer to inserted entry or nullptr on failure template<class T> - void set(const keyType& k, const T& v); + entry* set(const keyType& k, const T& v); //- Remove an entry specified by keyword bool remove(const word& keyword); diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index 9e887c08f61..6857c2808e2 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -146,16 +146,16 @@ bool Foam::dictionary::readIfPresent template<class T> -void Foam::dictionary::add(const keyType& k, const T& v, bool overwrite) +Foam::entry* Foam::dictionary::add(const keyType& k, const T& v, bool overwrite) { - add(new primitiveEntry(k, v), overwrite); + return add(new primitiveEntry(k, v), overwrite); } template<class T> -void Foam::dictionary::set(const keyType& k, const T& v) +Foam::entry* Foam::dictionary::set(const keyType& k, const T& v) { - set(new primitiveEntry(k, v)); + return set(new primitiveEntry(k, v)); } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/README b/src/OpenFOAM/db/dictionary/functionEntries/README index 0dc051a5d7f..c75c21043a3 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/README +++ b/src/OpenFOAM/db/dictionary/functionEntries/README @@ -14,7 +14,7 @@ #includeIfPresent | dict/primitive | string #includeFunc | dict | word | | - #calcEntry | dict/primitive | string + #calc | dict/primitive | string #codeStream | dict/primitive | dictionary -- GitLab From c7392f7fb02d6d8544f457dbd5c50d656e501e56 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 8 Nov 2017 19:08:10 +0100 Subject: [PATCH 110/126] ENH: additional dictionary compatibility/migration methods - when dictionary keywords change between versions, the programmer can use these compatibility methods to help with migration. * csearchCompat, foundCompat, lookupEntryPtrCompat, lookupEntryCompat, lookupCompat, lookupOrDefaultCompat, readIfPresentCompat, ... They behave like their similarly named base versions, but accept an additional list of older keyword names augmented by a version number. For example, dict.readIfPresentCompat ( "key", {{"olderName", 1612}, {"veryOld", 240}}, myscalar ); where 1612=OpenFOAM-v1612, 240=OpenFOAM-v2.4.x, etc. --- .../test/dictionary2/Test-dictionary2.C | 83 ++++++++- src/OpenFOAM/Make/files | 1 + src/OpenFOAM/db/dictionary/dictionary.H | 121 +++++++++++++ src/OpenFOAM/db/dictionary/dictionaryCompat.C | 162 ++++++++++++++++++ .../db/dictionary/dictionaryTemplates.C | 77 ++++++++- 5 files changed, 433 insertions(+), 11 deletions(-) create mode 100644 src/OpenFOAM/db/dictionary/dictionaryCompat.C diff --git a/applications/test/dictionary2/Test-dictionary2.C b/applications/test/dictionary2/Test-dictionary2.C index 9d01161e3e9..2541f5cba66 100644 --- a/applications/test/dictionary2/Test-dictionary2.C +++ b/applications/test/dictionary2/Test-dictionary2.C @@ -112,7 +112,8 @@ int main(int argc, char *argv[]) // overwrite existing { - entry* e = dict1.set(word("dict2"), 1000); // overwrite + dict1.set("entry3", 1000); // overwrite + entry* e = dict1.set(word("dict3"), 1000); // overwrite entryInfo(e); } @@ -124,10 +125,86 @@ int main(int argc, char *argv[]) entry* e = dict1.add(word("dict4"), tmpdict, true); // merge entryInfo(e); - if (e) - Info<< nl << "=> " << *e << nl; + if (e) Info<< nl << "=> " << *e << nl; + + tmpdict.clear(); + tmpdict.add(word("other"), 2.718281); + + dict1.add(word("dict1"), tmpdict, true); // merge + } + + Info<< nl << "dictionary" << nl << nl; + dict1.write(Info, false); + + + { + dict1.foundCompat + ( + "newEntry", {{"entry1", 1612}, {"entry15", 1606}} + ); + dict1.foundCompat + ( + "newEntry", {{"entry15", 1612}, {"entry2", 1606}} + ); + dict1.foundCompat + ( + "newEntry", {{"entry3", 240}, {"entry2", 1606}} + ); + + // And some success + dict1.foundCompat + ( + "entry4", {{"none", 240}, {"entry2", 1606}} + ); + } + + { + label lval = readLabel + ( + dict1.lookupCompat + ( + "entry400", {{"none", 240}, {"entry3", 1606}} + ) + ); + Info<< "int value: " << lval << nl; } + + // Could have different dictionary names and different entries names etc. + // Quite ugly! + { + scalar sval = readScalar + ( + dict1.csearchCompat + ( + "newdictName", {{"dict4", 1706}, {"dict1", 1606}} + ) + .dict() + .lookupCompat + ( + "newval", {{"something", 1606}, {"other", 1612}} + ) + ); + + Info<< "scalar value: " << sval << nl; + + sval = readScalar + ( + dict1.csearchCompat + ( + "newdictName", {{"dict1", 1606}, {"dict4", 1706}} + ) + .dict() + .lookupCompat + ( + "newval", {{"something", 1606}, {"other", 1612}} + ) + ); + + Info<< "scalar value = " << sval << nl; + } + + Info<< nl << "dictionary" << nl << nl; dict1.write(Info, false); diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index cfe98bfe647..130b48e5b3e 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -203,6 +203,7 @@ dictionary = db/dictionary $(dictionary)/dictionary.C $(dictionary)/dictionaryIO.C $(dictionary)/dictionarySearch.C +$(dictionary)/dictionaryCompat.C entry = $(dictionary)/entry $(entry)/entry.C diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index a4b8623c54b..671aba903d3 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -908,6 +908,127 @@ public: dictionary* makeScopedDictPtr(const fileName& dictPath); + // Compatibility helpers + + //- Search dictionary for given keyword and any compatibility names + // Default search: non-recursive with patterns. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // Old version 1600=OpenFOAM-v3.0, 240=OpenFOAM-2.4.x, + // 170=OpenFOAM-1.7.x,... + // + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + const_searcher csearchCompat + ( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Search dictionary for given keyword and any compatibility names + // Default search: non-recursive with patterns. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + bool foundCompat + ( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Find and return an entry pointer if present, or return a nullptr, + //- using any compatibility names it needed. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + const entry* lookupEntryPtrCompat + ( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive, + bool patternMatch + ) const; + + //- Find and return an entry if present otherwise error, + //- using any compatibility names it needed. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + const entry& lookupEntryCompat + ( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive, + bool patternMatch + ) const; + + //- Find and return an entry data stream, + //- using any compatibility names it needed. + // Default search: non-recursive with patterns. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + ITstream& lookupCompat + ( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Find and return a T, or return the given default value + //- using any compatibility names it needed. + // Default search: non-recursive with patterns. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + template<class T> + T lookupOrDefaultCompat + ( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + const T& deflt, + bool recursive = false, + bool patternMatch = true + ) const; + + //- Find an entry if present, and assign to T val + //- using any compatibility names it needed. + // Default search: non-recursive with patterns. + // + // \param compat list of old compatibility keywords and the last + // OpenFOAM version for which they were used. + // \param val the value to read + // \param recursive search parent dictionaries + // \param patternMatch use regular expressions + // + // \return true if the entry was found. + template<class T> + bool readIfPresentCompat + ( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + T& val, + bool recursive = false, + bool patternMatch = true + ) const; + + // Member Operators //- Find and return an entry data stream (identical to #lookup method). diff --git a/src/OpenFOAM/db/dictionary/dictionaryCompat.C b/src/OpenFOAM/db/dictionary/dictionaryCompat.C new file mode 100644 index 00000000000..624231fd14d --- /dev/null +++ b/src/OpenFOAM/db/dictionary/dictionaryCompat.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "dictionary.H" + +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +static void warnAboutAge(const int oldVersion) +{ + if (oldVersion < 1000) + { + // Emit warning + std::cerr + << " This keyword is considered to be VERY old!\n" + << std::endl; + } +#if (OPENFOAM_PLUS > 1600) + else if (OPENFOAM_PLUS > oldVersion) + { + const int months = + ( + // YYMM -> months + (12 * (OPENFOAM_PLUS/100) + (OPENFOAM_PLUS % 100)) + - (12 * (oldVersion/100) + (oldVersion % 100)) + ); + + std::cerr + << " This keyword is deemed to be " << months + << " months old.\n" + << std::endl; + } +#endif +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::dictionary::const_searcher Foam::dictionary::csearchCompat +( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive, + bool patternMatch +) const +{ + const_searcher finder(csearch(keyword, recursive,patternMatch)); + + if (finder.found()) + { + return finder; + } + + for (const std::pair<const char*,int>& iter : compat) + { + finder = csearch(word::validate(iter.first), recursive,patternMatch); + + if (finder.found()) + { + // Emit warning + std::cerr + << "--> FOAM IOWarning :" << nl + << " Found [v" << iter.second << "] '" + << iter.first << "' instead of '" + << keyword.c_str() << "' in dictionary \"" + << name().c_str() << "\" " + << nl + << std::endl; + + warnAboutAge(iter.second); + + break; + } + } + + return finder; +} + + +bool Foam::dictionary::foundCompat +( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive, + bool patternMatch +) const +{ + return csearchCompat(keyword, compat, recursive,patternMatch).found(); +} + + +const Foam::entry* Foam::dictionary::lookupEntryPtrCompat +( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive, + bool patternMatch +) const +{ + return csearchCompat(keyword, compat, recursive,patternMatch).ptr(); +} + + +const Foam::entry& Foam::dictionary::lookupEntryCompat +( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive, + bool patternMatch +) const +{ + const const_searcher + finder(csearchCompat(keyword, compat, recursive,patternMatch)); + + if (!finder.found()) + { + FatalIOErrorInFunction + ( + *this + ) << "keyword " << keyword << " is undefined in dictionary " + << name() + << exit(FatalIOError); + } + + return finder.ref(); +} + + +Foam::ITstream& Foam::dictionary::lookupCompat +( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + bool recursive, + bool patternMatch +) const +{ + return lookupEntryCompat(keyword, compat, recursive,patternMatch).stream(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index 6857c2808e2..833647b951a 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -35,6 +35,20 @@ Foam::wordList Foam::dictionary::sortedToc(const Compare& comp) const } +template<class T> +Foam::entry* Foam::dictionary::add(const keyType& k, const T& v, bool overwrite) +{ + return add(new primitiveEntry(k, v), overwrite); +} + + +template<class T> +Foam::entry* Foam::dictionary::set(const keyType& k, const T& v) +{ + return set(new primitiveEntry(k, v)); +} + + template<class T> T Foam::dictionary::lookupType ( @@ -43,7 +57,7 @@ T Foam::dictionary::lookupType bool patternMatch ) const { - auto finder = csearch(keyword, recursive, patternMatch); + const const_searcher finder(csearch(keyword, recursive, patternMatch)); if (!finder.found()) { @@ -68,7 +82,7 @@ T Foam::dictionary::lookupOrDefault bool patternMatch ) const { - auto finder = csearch(keyword, recursive, patternMatch); + const const_searcher finder(csearch(keyword, recursive, patternMatch)); if (finder.found()) { @@ -96,7 +110,7 @@ T Foam::dictionary::lookupOrAddDefault bool patternMatch ) { - auto finder = csearch(keyword, recursive, patternMatch); + const const_searcher finder(csearch(keyword, recursive, patternMatch)); if (finder.found()) { @@ -125,7 +139,7 @@ bool Foam::dictionary::readIfPresent bool patternMatch ) const { - auto finder = csearch(keyword, recursive, patternMatch); + const const_searcher finder(csearch(keyword, recursive, patternMatch)); if (finder.found()) { @@ -146,16 +160,63 @@ bool Foam::dictionary::readIfPresent template<class T> -Foam::entry* Foam::dictionary::add(const keyType& k, const T& v, bool overwrite) +T Foam::dictionary::lookupOrDefaultCompat +( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + const T& deflt, + bool recursive, + bool patternMatch +) const { - return add(new primitiveEntry(k, v), overwrite); + const const_searcher + finder(csearchCompat(keyword, compat, recursive, patternMatch)); + + if (finder.found()) + { + return pTraits<T>(finder.ptr()->stream()); + } + + if (writeOptionalEntries) + { + IOInfoInFunction(*this) + << "Optional entry '" << keyword << "' is not present," + << " returning the default value '" << deflt << "'" + << endl; + } + + return deflt; } template<class T> -Foam::entry* Foam::dictionary::set(const keyType& k, const T& v) +bool Foam::dictionary::readIfPresentCompat +( + const word& keyword, + std::initializer_list<std::pair<const char*,int>> compat, + T& val, + bool recursive, + bool patternMatch +) const { - return set(new primitiveEntry(k, v)); + const const_searcher + finder(csearchCompat(keyword, compat, recursive, patternMatch)); + + if (finder.found()) + { + finder.ptr()->stream() >> val; + return true; + } + + if (writeOptionalEntries) + { + IOInfoInFunction(*this) + << "Optional entry '" << keyword << "' is not present," + << " the default value '" << val << "' will be used." + << endl; + } + + return false; } -- GitLab From e289c7802724dfbc622afb4cb42f010c8ec26204 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 8 Nov 2017 20:44:43 +0100 Subject: [PATCH 111/126] COMP: mismatch of inline some HashTable methods --- src/OpenFOAM/containers/HashTables/HashTable/HashTable.H | 2 +- src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 926a3f90161..85e19aed49b 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -737,7 +737,7 @@ protected: inline Iterator(bool, table_type* tbl); //- Construct by finding key in hash table - inline Iterator(table_type* tbl, const Key& key); + Iterator(table_type* tbl, const Key& key); // Protected Member Functions diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index 27ac1340065..0373ed9c7fc 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -60,7 +60,7 @@ inline bool Foam::HashTable<T, Key, Hash>::empty() const template<class T, class Key, class Hash> -bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const +inline bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const { if (size_) { -- GitLab From 59e8c397472751e62ad90ead4f59b2d7904056c1 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 9 Nov 2017 08:39:36 +0100 Subject: [PATCH 112/126] ENH: static parse methods for ITstream --- src/OpenFOAM/containers/Lists/List/List.H | 15 ++-- src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C | 84 +++++++++++++++---- src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H | 35 +++++++- src/OpenFOAM/db/dictionary/dictionary.C | 5 +- .../primitiveEntry/primitiveEntry.C | 9 +- 5 files changed, 115 insertions(+), 33 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 843272099f8..7fd057a02fa 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -236,23 +236,23 @@ public: inline void append(const UIndirectList<T>& lst); //- Transfer the contents of the argument List into this list - // and annul the argument list + //- and annul the argument list void transfer(List<T>& lst); //- Transfer the contents of the argument List into this list - // and annul the argument list + //- and annul the argument list template<int SizeMin> void transfer(DynamicList<T, SizeMin>& lst); //- Transfer the contents of the argument List into this list - // and annul the argument list + //- and annul the argument list void transfer(SortableList<T>& lst); //- Transfer contents to the Xfer container inline Xfer<List<T>> xfer(); - //- Return subscript-checked element of UList. - // Resize list if required. + //- Return subscript-checked element of UList and resizing the list + //- if required. inline T& newElmt(const label i); @@ -301,7 +301,10 @@ public: //- Read List from Istream, discarding contents of existing List friend Istream& operator>> <T> - (Istream& is, List<T>& L); + ( + Istream& is, + List<T>& L + ); }; diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C index 24258a1fa32..499bad8cb24 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C @@ -27,23 +27,72 @@ License #include "ITstream.H" #include "UIListStream.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -void Foam::ITstream::toTokenList(ISstream& is) +Foam::label Foam::ITstream::parseStream(ISstream& is, tokenList& tokens) { - tokenIndex_ = 0; + label nTok = 0; - token tok; + tokens.clear(); + tokens.setSize(64, token::undefinedToken); + token tok; while (!is.read(tok).bad() && tok.good()) { - newElmt(tokenIndex()++) = std::move(tok); + tokens.newElmt(nTok++) = std::move(tok); } - tokenList::setSize(tokenIndex()); + tokens.setSize(nTok); - setOpened(); - ITstream::rewind(); + return nTok; +} + + +Foam::tokenList Foam::ITstream::parse +( + const UList<char>& input, + streamFormat format +) +{ + UIListStream is(input, format, IOstream::currentVersion); + + tokenList tokens; + parseStream(is, tokens); + return tokens; +} + + +Foam::tokenList Foam::ITstream::parse +( + const std::string& input, + streamFormat format +) +{ + UIListStream is + ( + input.data(), + input.size(), + format, + IOstream::currentVersion + ); + + tokenList tokens; + parseStream(is, tokens); + return tokens; +} + + +Foam::tokenList Foam::ITstream::parse +( + const char* input, + streamFormat format +) +{ + UIListStream is(input, strlen(input), format, IOstream::currentVersion); + + tokenList tokens; + parseStream(is, tokens); + return tokens; } @@ -58,13 +107,14 @@ Foam::ITstream::ITstream ) : Istream(format, version), - tokenList(16, token::undefinedToken), + tokenList(), name_(name), tokenIndex_(0) { UIListStream is(input, format, version); - toTokenList(is); + parseStream(is, static_cast<tokenList&>(*this)); + ITstream::rewind(); } @@ -77,13 +127,14 @@ Foam::ITstream::ITstream ) : Istream(format, version), - tokenList(16, token::undefinedToken), + tokenList(), name_(name), tokenIndex_(0) { UIListStream is(input.data(), input.size(), format, version); - toTokenList(is); + parseStream(is, static_cast<tokenList&>(*this)); + ITstream::rewind(); } @@ -96,14 +147,14 @@ Foam::ITstream::ITstream ) : Istream(format, version), - tokenList(16, token::undefinedToken), + tokenList(), name_(name), tokenIndex_(0) { - const size_t len = strlen(input); - UIListStream is(input, len, format, version); + UIListStream is(input, strlen(input), format, version); - toTokenList(is); + parseStream(is, static_cast<tokenList&>(*this)); + ITstream::rewind(); } @@ -245,6 +296,7 @@ void Foam::ITstream::rewind() lineNumber_ = tokenList::first().lineNumber(); } + setOpened(); setGood(); } diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H index f6c96f12720..4e13175f0dd 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H @@ -25,7 +25,7 @@ Class Foam::ITstream Description - Input token stream. + An input stream of tokens. SourceFiles ITstream.C @@ -46,7 +46,6 @@ namespace Foam // Forward declaration class ISstream; - /*---------------------------------------------------------------------------*\ Class ITstream Declaration \*---------------------------------------------------------------------------*/ @@ -67,8 +66,9 @@ class ITstream // Private Member Functions - //- Convert input sequence into tokens and append to the token list - void toTokenList(ISstream& input); + //- Convert input sequence into a list of tokens. + // \return the number of tokens in the resulting list. + static label parseStream(ISstream& input, tokenList& tokens); public: @@ -164,6 +164,33 @@ public: {} + // Static Functions + + //- Create token list by parsing the input character sequence until + //- no good tokens remain. + static tokenList parse + ( + const UList<char>& input, + streamFormat format=ASCII + ); + + //- Create token list by parsing the input string until + //- no good tokens remain. + static tokenList parse + ( + const std::string& input, + streamFormat format=ASCII + ); + + //- Create token list by parsing the input character sequence until + //- no good tokens remain. + static tokenList parse + ( + const char* input, + streamFormat format=ASCII + ); + + // Member functions // Inquiry diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 2a569fb8afc..d015a464678 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -223,10 +223,7 @@ Foam::tokenList Foam::dictionary::tokens() const } // String re-parsed as a list of tokens - return static_cast<tokenList> - ( - ITstream("tokens", os.str(), os.format(), os.version()) - ); + return ITstream::parse(os.str()); } diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C index 1202375bd14..4730295740b 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C @@ -96,15 +96,18 @@ bool Foam::primitiveEntry::expandVariable return false; } - // String parsed as a list of tokens - ITstream its("env", str); - appendTokenList(std::move(static_cast<tokenList&>(its))); + // Parse string into a series of tokens + + tokenList toks(ITstream::parse(str, IOstream::ASCII)); + + appendTokenList(std::move(toks)); } else if (eptr->isDict()) { // Found dictionary entry tokenList toks(eptr->dict().tokens().xfer()); + appendTokenList(std::move(toks)); } else -- GitLab From 166f62f19d49b55cb86571bf46923f026457479c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 9 Nov 2017 11:04:34 +0100 Subject: [PATCH 113/126] STYLE: spelling, doxygen --- .../mesh/conversion/kivaToFoam/readKivaGrid.H | 4 ++-- src/OpenFOAM/db/IOstreams/token/token.C | 2 +- src/OpenFOAM/global/argList/argList.H | 4 ++-- .../uncollatedFileOperation/uncollatedFileOperation.C | 2 +- src/lagrangian/basic/Cloud/Cloud.C | 10 +++++----- ...humidityTemperatureCoupledMixedFvPatchScalarField.H | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H index 5e3afb3b3a8..57919543e57 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H +++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H @@ -363,7 +363,7 @@ if if (pFaces[LINER][0].size() != newLinerFaces.size()) { - Info<< "Transfered " << pFaces[LINER][0].size() - newLinerFaces.size() + Info<< "Transferred " << pFaces[LINER][0].size() - newLinerFaces.size() << " faces from liner region to cylinder head" << endl; pFaces[LINER][0] = newLinerFaces; } @@ -392,7 +392,7 @@ if if (pFaces[CYLINDERHEAD][0].size() != newCylinderHeadFaces.size()) { - Info<< "Transfered faces from cylinder-head region to linder" << endl; + Info<< "Transferred faces from cylinder-head region to linder" << endl; pFaces[CYLINDERHEAD][0] = newCylinderHeadFaces; } } diff --git a/src/OpenFOAM/db/IOstreams/token/token.C b/src/OpenFOAM/db/IOstreams/token/token.C index fe1f76df5ce..c082df43cc9 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.C +++ b/src/OpenFOAM/db/IOstreams/token/token.C @@ -97,7 +97,7 @@ Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is) if (data_.compoundPtr->empty()) { FatalIOErrorInFunction(is) - << "compound has already been transfered from token\n " + << "compound has already been transferred from token\n " << info() << abort(FatalIOError); } else diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 973ad7b3ef2..89ac6c63857 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -249,8 +249,8 @@ public: //- Return root path inline const fileName& rootPath() const; - //- Return distributed flag (i.e. are rootPaths different on - // different machines) + //- Return distributed flag + //- (i.e. are rootPaths different on different machines) inline bool distributed() const; //- Return case name (parallel run) or global case (serial run) diff --git a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C index 66e51751fef..9c4788b3f54 100644 --- a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C @@ -601,7 +601,7 @@ bool Foam::fileOperations::uncollatedFileOperation::read if (masterOnly && Pstream::parRun()) { // Master reads headerclassname from file. Make sure this gets - // transfered as well as contents. + // transferred as well as contents. Pstream::scatter(io.headerClassName()); Pstream::scatter(io.note()); diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index 4eba7f4cf75..5f07b4d1f22 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -176,7 +176,7 @@ void Foam::Cloud<ParticleType>::move pIter().stepFraction() = 0; } - // List of lists of particles to be transfered for all of the + // List of lists of particles to be transferred for all of the // neighbour processors List<IDLList<ParticleType>> particleTransferLists ( @@ -292,19 +292,19 @@ void Foam::Cloud<ParticleType>::move pBufs.finishedSends(allNTrans); - bool transfered = false; + bool transferred = false; for (const label n : allNTrans) { if (n) { - transfered = true; + transferred = true; break; } } - reduce(transfered, orOp<bool>()); + reduce(transferred, orOp<bool>()); - if (!transfered) + if (!transferred) { break; } diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H index 258af191cc4..f3f7fba5808 100644 --- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H @@ -217,7 +217,7 @@ private: //- Name of the radiative heat flux field const word qrName_; - //- Name of the species on which the mass transfered (default H2O) + //- Name of the species on which the mass transferred (default H2O) const word specieName_; -- GitLab From c51ee22101d2a5d682261d08c30dd36f6dd25875 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 9 Nov 2017 18:59:55 +0100 Subject: [PATCH 114/126] STYLE: fix stray use of argList option() instead of [] --- .../mesh/manipulation/splitMeshRegions/splitMeshRegions.C | 2 +- .../surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C | 2 +- src/OpenFOAM/global/argList/argList.H | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index 14692cac4c2..5326981c9bb 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -1599,7 +1599,7 @@ int main(int argc, char *argv[]) } else if (useCellZonesFile) { - const word zoneFile = args.option("cellZonesFileOnly"); + const word zoneFile(args["cellZonesFileOnly"]); Info<< "Reading split from cellZones file " << zoneFile << endl << "This requires all" << " cells to be in one and only one cellZone." << nl << endl; diff --git a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C index e7006475c78..538fb2cceee 100644 --- a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C +++ b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) if (args.optionFound("featureFile")) { - const fileName featureFileName(args.option("featureFile")); + const fileName featureFileName(args["featureFile"]); Info<< "Reading features from " << featureFileName << " ..." << endl; edgeMesh feMesh(featureFileName); diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 89ac6c63857..171bdb7ffb6 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -341,7 +341,6 @@ public: inline const string& operator[](const label index) const; //- Return the argument string associated with the named option - // \sa option() inline const string& operator[](const word& opt) const; -- GitLab From 5281dd48779aeed8c415f69b7d8b7258e2aa25a0 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 12 Nov 2017 15:25:14 +0100 Subject: [PATCH 115/126] ENH: changed return value to bool for Ostream::write(const token&) - the return value signals if this method handled this particular type of token. This minor change allows this method to be used as a succinct prefilter an output token stream. It also provides better encapsulation of what the particular output stream handles. Eg, bool ok = os.write(tok); if (!ok) // or if (!ok && os.good()) { os << tok; } instead of if (tok.type() == typeA || tok.type() == typeB || ...) { os.write(tok); } else { os << tok; } --- src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H | 5 +- .../db/IOstreams/Pstreams/UOPstream.C | 40 +++++++++------ .../db/IOstreams/Pstreams/UOPstream.H | 49 ++++++++++--------- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C | 38 +++++++++----- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H | 7 +-- .../db/IOstreams/Sstreams/prefixOSstream.C | 38 +++++++++----- .../db/IOstreams/Sstreams/prefixOSstream.H | 5 +- .../primitiveEntry/primitiveEntryIO.C | 21 +++----- 8 files changed, 119 insertions(+), 84 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index 990e0924e8c..bf0150cb244 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -96,8 +96,9 @@ public: // Write functions - //- Write next token to stream - virtual Ostream& write(const token& tok) = 0; + //- Write token to stream or otherwise handle it. + // \return false if the token type was not handled by this method + virtual bool write(const token& tok) = 0; //- Write character virtual Ostream& write(const char c) = 0; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index d9ffbd0ed90..d8e10b619cc 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -185,25 +185,33 @@ Foam::UOPstream::~UOPstream() // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -Foam::Ostream& Foam::UOPstream::write(const token& tok) +bool Foam::UOPstream::write(const token& tok) { - // Raw token output only supported for verbatim strings for now - if (tok.type() == token::tokenType::VERBATIMSTRING) - { - writeToBuffer(char(token::tokenType::VERBATIMSTRING)); - write(tok.stringToken()); - } - else if (tok.type() == token::tokenType::VARIABLE) - { - writeToBuffer(char(token::tokenType::VARIABLE)); - write(tok.stringToken()); - } - else + // Direct token handling only for some types + + switch (tok.type()) { - NotImplemented; - setBad(); + case token::tokenType::VERBATIMSTRING : + { + writeToBuffer(char(token::tokenType::VERBATIMSTRING)); + write(tok.stringToken()); + + return true; + } + + case token::tokenType::VARIABLE : + { + writeToBuffer(char(token::tokenType::VARIABLE)); + write(tok.stringToken()); + + return true; + } + + default: + break; } - return *this; + + return false; } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H index c96b33ac8cf..3287c62cd42 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H @@ -127,7 +127,7 @@ public: // Inquiry //- Return flags of output stream - ios_base::fmtflags flags() const + virtual ios_base::fmtflags flags() const { return ios_base::fmtflags(0); } @@ -146,25 +146,26 @@ public: const label communicator = 0 ); - //- Write next token to stream - Ostream& write(const token& tok); + //- Write token to stream or otherwise handle it. + // \return false if the token type was not handled by this method + virtual bool write(const token& tok); //- Write single character. Whitespace is suppressed. - Ostream& write(const char c); + virtual Ostream& write(const char c); //- Write the word-characters of a character string. // Sends as a single char, or as word. - Ostream& write(const char* str); + virtual Ostream& write(const char* str); //- Write word - Ostream& write(const word& str); + virtual Ostream& write(const word& str); //- Write string - Ostream& write(const string& str); + virtual Ostream& write(const string& str); //- Write std::string surrounded by quotes. // Optional write without quotes. - Ostream& writeQuoted + virtual Ostream& writeQuoted ( const std::string& str, const bool quoted=true @@ -174,70 +175,74 @@ public: virtual Ostream& write(const int32_t val); //- Write int64_t as a label - Ostream& write(const int64_t val); + virtual Ostream& write(const int64_t val); //- Write floatScalar - Ostream& write(const floatScalar val); + virtual Ostream& write(const floatScalar val); //- Write doubleScalar - Ostream& write(const doubleScalar val); + virtual Ostream& write(const doubleScalar val); //- Write binary block with 8-byte alignment. - Ostream& write(const char* data, const std::streamsize count); + virtual Ostream& write + ( + const char* data, + const std::streamsize count + ); //- Begin marker for low-level raw binary output. // The count should indicate the number of bytes for subsequent // writeRaw calls. - Ostream& beginRaw(const std::streamsize count); + virtual Ostream& beginRaw(const std::streamsize count); //- Low-level raw binary output. - Ostream& writeRaw + virtual Ostream& writeRaw ( const char* data, const std::streamsize count ); //- End marker for low-level raw binary output. - Ostream& endRaw() + virtual Ostream& endRaw() { return *this; } //- Add indentation characters - void indent() + virtual void indent() {} // Stream state functions //- Flush stream - void flush() + virtual void flush() {} //- Add newline and flush stream - void endl() + virtual void endl() {} //- Get width of output field - int width() const + virtual int width() const { return 0; } //- Set width of output field (and return old width) - int width(const int) + virtual int width(const int) { return 0; } //- Get precision of output field - int precision() const + virtual int precision() const { return 0; } //- Set precision of output field (and return old precision) - int precision(const int) + virtual int precision(const int) { return 0; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C index 1ace27022c1..f40f94218c8 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C @@ -30,21 +30,35 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::Ostream& Foam::OSstream::write(const token& tok) +bool Foam::OSstream::write(const token& tok) { - if (tok.type() == token::tokenType::VERBATIMSTRING) - { - write(char(token::HASH)); - write(char(token::BEGIN_BLOCK)); - writeQuoted(tok.stringToken(), false); - write(char(token::HASH)); - write(char(token::END_BLOCK)); - } - else if (tok.type() == token::tokenType::VARIABLE) + // Direct token handling only for some types + + switch (tok.type()) { - writeQuoted(tok.stringToken(), false); + case token::tokenType::VERBATIMSTRING : + { + write(char(token::HASH)); + write(char(token::BEGIN_BLOCK)); + writeQuoted(tok.stringToken(), false); + write(char(token::HASH)); + write(char(token::END_BLOCK)); + + return true; + } + + case token::tokenType::VARIABLE : + { + writeQuoted(tok.stringToken(), false); + + return true; + } + + default: + break; } - return *this; + + return false; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H index 753bad7ca55..8218a5a3d65 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,8 +104,9 @@ public: // Write functions - //- Write next token to stream - virtual Ostream& write(const token& tok); + //- Write token to stream or otherwise handle it. + // \return false if the token type was not handled by this method + virtual bool write(const token& tok); //- Write character virtual Ostream& write(const char c); diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C index fcafc89f7fa..eb96ed14144 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C @@ -65,21 +65,35 @@ void Foam::prefixOSstream::print(Ostream& os) const } -Foam::Ostream& Foam::prefixOSstream::write(const token& tok) +bool Foam::prefixOSstream::write(const token& tok) { - if (tok.type() == token::tokenType::VERBATIMSTRING) - { - write(char(token::HASH)); - write(char(token::BEGIN_BLOCK)); - writeQuoted(tok.stringToken(), false); - write(char(token::HASH)); - write(char(token::END_BLOCK)); - } - else if (tok.type() == token::tokenType::VARIABLE) + // Direct token handling only for some types + + switch (tok.type()) { - writeQuoted(tok.stringToken(), false); + case token::tokenType::VERBATIMSTRING : + { + write(char(token::HASH)); + write(char(token::BEGIN_BLOCK)); + writeQuoted(tok.stringToken(), false); + write(char(token::HASH)); + write(char(token::END_BLOCK)); + + return true; + } + + case token::tokenType::VARIABLE : + { + writeQuoted(tok.stringToken(), false); + + return true; + } + + default: + break; } - return *this; + + return false; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H index 4c9eca7b448..d67c6d916ec 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H @@ -98,8 +98,9 @@ public: // Write functions - //- Write next token to stream - virtual Ostream& write(const token& tok); + //- Write token to stream or otherwise handle it. + // \return false if the token type was not handled by this method + virtual bool write(const token& tok); //- Write character virtual Ostream& write(const char c); diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index 1d91eccf6ca..f9a6759030d 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -200,25 +200,16 @@ void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const bool addSpace = false; // Separate from previous tokens with a space for (const token& tok : *this) { - if (tok.type() == token::tokenType::VERBATIMSTRING) - { - // Bypass token output operator to avoid losing verbatimness. - // Handled in the Ostreams themselves - - if (addSpace) os << token::SPACE; + if (addSpace) os << token::SPACE; - os.write(tok); + // Try to output token directly, with special handling in Ostreams. - addSpace = true; // Separate from following tokens - } - else + if (!os.write(tok)) { - if (addSpace) os << token::SPACE; - - os << tok; - - addSpace = true; // Separate from following tokens + os << tok; // Revert to normal '<<' output operator } + + addSpace = true; // Separate from following tokens } if (!contentsOnly) -- GitLab From 4f1e4aa59e9bea003ca4c67d08786ce0ad864e68 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 12 Nov 2017 16:57:37 +0100 Subject: [PATCH 116/126] ENH: add token type for stream flags (ASCII/BINARY) --- .../db/IOstreams/Pstreams/UOPstream.C | 7 ++ src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C | 6 ++ .../db/IOstreams/Sstreams/prefixOSstream.C | 6 ++ src/OpenFOAM/db/IOstreams/token/token.H | 46 ++++++--- src/OpenFOAM/db/IOstreams/token/tokenI.H | 93 +++++++++++++------ src/OpenFOAM/db/IOstreams/token/tokenIO.C | 9 ++ 6 files changed, 124 insertions(+), 43 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index d8e10b619cc..b5c63d0c576 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -191,6 +191,13 @@ bool Foam::UOPstream::write(const token& tok) switch (tok.type()) { + case token::tokenType::FLAG : + { + // silently consume the flag + + return true; + } + case token::tokenType::VERBATIMSTRING : { writeToBuffer(char(token::tokenType::VERBATIMSTRING)); diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C index f40f94218c8..2027b2d28a2 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C @@ -36,6 +36,12 @@ bool Foam::OSstream::write(const token& tok) switch (tok.type()) { + case token::tokenType::FLAG : + { + // silently consume the flag + return true; + } + case token::tokenType::VERBATIMSTRING : { write(char(token::HASH)); diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C index eb96ed14144..640bc8555d9 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C @@ -71,6 +71,12 @@ bool Foam::prefixOSstream::write(const token& tok) switch (tok.type()) { + case token::tokenType::FLAG : + { + // silently consume the flag + return true; + } + case token::tokenType::VERBATIMSTRING : { write(char(token::HASH)); diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H index 90897917c3f..868019ba3af 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.H +++ b/src/OpenFOAM/db/IOstreams/token/token.H @@ -79,6 +79,7 @@ public: UNDEFINED, //!< An undefined token-type // Fundamental types + FLAG, //!< stream flag (1-byte bitmask) PUNCTUATION, //!< single character punctuation LABEL, //!< label (integer) type FLOAT_SCALAR, //!< float (single-precision) type @@ -97,6 +98,15 @@ public: }; + //- Stream or output control flags (1-byte width) + enum flagType + { + NO_FLAG = 0, //!< No flags + ASCII = 1, //!< ASCII-mode stream + BINARY = 2, //!< BINARY-mode stream + }; + + //- Standard punctuation tokens (a character) enum punctuationToken { @@ -137,16 +147,6 @@ public: bool empty_; - - // Private Member Functions - - //- Disallow default bitwise copy construct - compound(const compound&) = delete; - - //- Disallow default bitwise assignment - void operator=(const compound&) = delete; - - public: //- Runtime type information @@ -171,6 +171,9 @@ public: empty_(false) {} + //- No default copy construct + compound(const compound&) = delete; + // Selectors @@ -202,9 +205,13 @@ public: virtual void write(Ostream& os) const = 0; - // IOstream Operators + // Operators + + //- No default assign operator + compound& operator=(const compound&) = delete; - friend Ostream& operator<<(Ostream&, const compound&); + //- Output operator + friend Ostream& operator<<(Ostream& os, const compound& ct); }; @@ -250,6 +257,7 @@ private: int64_t int64Val; int32_t int32Val; + int flagVal; // bitmask - stored as int, not enum punctuationToken punctuationVal; label labelVal; floatScalar floatVal; @@ -350,7 +358,12 @@ public: inline ~token(); - // Static member functions + // Static Member Functions + + //- Create a token with stream flags, no sanity check + // + // \param bitmask the flags to set + inline static token flag(int bitmask); //- True if the character is a punctuation separator (eg, in ISstream). // Since it could also start a number, SUBTRACT is not included as @@ -395,6 +408,9 @@ public: //- True if token is ERROR inline bool error() const; + //- True if token is FLAG + inline bool isFlag() const; + //- True if token is PUNCTUATION inline bool isPunctuation() const; @@ -431,6 +447,10 @@ public: // Access + //- Return flag bitmask + // Report FatalIOError and return NO_FLAG if token is not FLAG + inline int flagToken() const; + //- Return punctuation character. // Report FatalIOError and return \b \\0 if token is not PUNCTUATION inline punctuationToken pToken() const; diff --git a/src/OpenFOAM/db/IOstreams/token/tokenI.H b/src/OpenFOAM/db/IOstreams/token/tokenI.H index c391298652a..f6868ec1523 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenI.H +++ b/src/OpenFOAM/db/IOstreams/token/tokenI.H @@ -25,6 +25,48 @@ License #include <algorithm> +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +inline Foam::token Foam::token::flag(int bitmask) +{ + token tok; + tok.type_ = tokenType::FLAG; + tok.data_.flagVal = bitmask; + + return tok; +} + + +inline bool Foam::token::isseparator(int c) +{ + switch (c) + { + case token::END_STATEMENT : + case token::BEGIN_LIST : + case token::END_LIST : + case token::BEGIN_SQR : + case token::END_SQR : + case token::BEGIN_BLOCK : + case token::END_BLOCK : + case token::COLON : + case token::COMMA : + case token::ASSIGN : + case token::ADD : + // Excluded token::SUBTRACT since it could start a number + case token::MULTIPLY : + case token::DIVIDE : + { + return true; + } + + default: + break; + } + + return false; +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // inline void Foam::token::setUndefined() @@ -322,51 +364,39 @@ inline bool Foam::token::error() const } -inline bool Foam::token::isPunctuation() const +inline bool Foam::token::isFlag() const { - return (type_ == tokenType::PUNCTUATION); + return (type_ == tokenType::FLAG); } -inline Foam::token::punctuationToken Foam::token::pToken() const +inline int Foam::token::flagToken() const { - if (type_ == tokenType::PUNCTUATION) + if (type_ == tokenType::FLAG) { - return data_.punctuationVal; + return data_.flagVal; } - parseError("punctuation character"); - return NULL_TOKEN; + parseError("flag bitmask"); + return NO_FLAG; } -inline bool Foam::token::isseparator(int c) +inline bool Foam::token::isPunctuation() const { - switch (c) - { - case token::END_STATEMENT : - case token::BEGIN_LIST : - case token::END_LIST : - case token::BEGIN_SQR : - case token::END_SQR : - case token::BEGIN_BLOCK : - case token::END_BLOCK : - case token::COLON : - case token::COMMA : - case token::ASSIGN : - case token::ADD : - // Excluded token::SUBTRACT since it could start a number - case token::MULTIPLY : - case token::DIVIDE : - { - return true; - } + return (type_ == tokenType::PUNCTUATION); +} - default: - break; + +inline Foam::token::punctuationToken Foam::token::pToken() const +{ + if (type_ == tokenType::PUNCTUATION) + { + return data_.punctuationVal; } - return false; + parseError("punctuation character"); + return punctuationToken::NULL_TOKEN; } @@ -712,6 +742,9 @@ inline bool Foam::token::operator==(const token& tok) const case tokenType::UNDEFINED: return true; + case tokenType::FLAG: + return data_.flagVal == tok.data_.flagVal; + case tokenType::PUNCTUATION: return data_.punctuationVal == tok.data_.punctuationVal; diff --git a/src/OpenFOAM/db/IOstreams/token/tokenIO.C b/src/OpenFOAM/db/IOstreams/token/tokenIO.C index c32935d9074..cbd4af1ac17 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenIO.C +++ b/src/OpenFOAM/db/IOstreams/token/tokenIO.C @@ -43,6 +43,10 @@ static OS& printTokenInfo(OS& os, const token& tok) os << "undefined token"; break; + case token::tokenType::FLAG: + os << "flag '" << int(tok.flagToken()) << '\''; + break; + case token::tokenType::PUNCTUATION: os << "punctuation '" << tok.pToken() << '\''; break; @@ -117,6 +121,7 @@ Foam::word Foam::token::name() const switch (type_) { case token::tokenType::UNDEFINED: return "undefined"; + case token::tokenType::FLAG: return "flag"; case token::tokenType::PUNCTUATION: return "punctuation"; case token::tokenType::LABEL: return "label"; case token::tokenType::FLOAT_SCALAR: return "float"; @@ -155,6 +160,10 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& tok) << "Undefined token" << endl; break; + case token::tokenType::FLAG: + // Swallow the flag + break; + case token::tokenType::PUNCTUATION: os << tok.data_.punctuationVal; break; -- GitLab From 24d8c891d7786ccd7b7dec1222099318d6c97c46 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 13 Nov 2017 07:46:17 +0100 Subject: [PATCH 117/126] ENH: add bin/tools/foamCreateModuleInclude - support when creating modules for OpenFOAM. Original source from Ivan Spisso (CINECA) modified by OpenCFD --- bin/tools/foamCreateModuleInclude | 364 ++++++++++++++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100755 bin/tools/foamCreateModuleInclude diff --git a/bin/tools/foamCreateModuleInclude b/bin/tools/foamCreateModuleInclude new file mode 100755 index 00000000000..83877b495a6 --- /dev/null +++ b/bin/tools/foamCreateModuleInclude @@ -0,0 +1,364 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2017 CINECA +#------------------------------------------------------------------------------ +# 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/>. +# +# Script +# foamCreateModuleInclude +# +# Description +# Script to create module settings. +# This is still incomplete, but can be a useful basis when using a module +# system. +#------------------------------------------------------------------------------ +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE + +usage: ${0##*/} [OPTION] projectDir +options: + -output=file The output name (default: ModuleInclude.tcl) + -preload=file Specify (module) file to preload. Can use multiple times + -tmpdir=file The tmp directory to use. + -help print the usage + +Create module settings for inclusion in a top-level openfoam module. + +USAGE + exit 1 +} + +# Report error and exit +die() +{ + exec 1>&2 + echo + echo "Error encountered:" + while [ "$#" -ge 1 ]; do echo " $1"; shift; done + echo + echo "See '${0##*/} -help' for usage" + echo + exit 1 +} + +#------------------------------------------------------------------------------ + +unset optBackend optDebug preload projectDir +unset moduleOutput moduleTmpDir + +# Parse some options +while [ "$#" -gt 0 ] +do + case "$1" in + '') + # Ignore empty args + ;; + -h | -help) + usage + ;; + -debug) + optDebug=true + ;; + -preload=*) + preload="$preload${preload:+ }${1#*=}" + ;; + --recursive-backend--) + optBackend=true + ;; + --output=*) + moduleOutput="${1#*=}" + ;; + --tmpdir=*) + moduleTmpDir="${1#*=}" + ;; + -*) + die "unknown option: $1" + ;; + *) + break + ;; + esac + shift +done + +[ "$#" -eq 1 ] || die "missing projectDir, or too many arguments" +projectDir="${1%/}" + +#------------------------------------------------------------------------------ + +# Filter accepts system paths only +syspath() { + local path + + set -- $(echo "${1}" | tr ':' '\n' ) + for i in $@ + do + case $i in + /bin | /usr/bin | /usr/lib*) + path="${path}${path:+:}$i";; + esac + done + echo "$path" +} + + +# Frontend: do all basic sanity checks in the front-end only +if [ -z "$optBackend" ] +then + # Check that it appears to be an OpenFOAM installation + [ -d "$projectDir" -a -f "$projectDir/etc/bashrc" ] || \ + die "Incorrect projectDir? $projectDir" + + # Check preloads + for file in $preloads + do + [ -f "$file" ] || echo "No such file to preload: $file" 1>&2 + done + + # Call itself with clean environment. + # Tag the start/end of the original PATH, LD_LIBRARY_PATH + exec env -i \ + HOME=$HOME \ + USER=$USER \ + PATH=":MOD_PREPEND:$(syspath $PATH):MOD_APPEND:" \ + LD_LIBRARY_PATH=":MOD_PREPEND:$(syspath $LD_LIBRARY_PATH):MOD_APPEND:" \ + $0 \ + --recursive-backend-- \ + "${optDebug:+-debug}" \ + "${output:+-output=$moduleOutput}" \ + "${preloads:+-preload=$preloads}" \ + "${moduleTmpDir:+-tmpdir=$moduleTmpDir}" \ + $projectDir + + exitCode=$? # exec failed? + + echo "exec somehow failed?" 1>&2 + exit $exitCode +fi + +#------------------------------------------------------------------------------ +# Backend + +: ${moduleOutput:=ModuleInclude.tcl} +: ${moduleTmpDir:=${TMPDIR:-/tmp}} + +# Preload any/all modules +for file in $preloads +do + [ -f "$file" ] && . "$file" '' +done + +# Temporary files +tmpFiles="$moduleTmpDir/modules-$USER.$$" +if [ -n "$optDebug" ] +then + echo "Preserving intermediate files: $tmpFiles.*" 1>&2 +else + trap 'rm -f $tmpFiles.* 2>/dev/null; exit 0' EXIT TERM INT +fi + + +# Snapshot of aliases - sorted +printAlias() +{ + alias | sort -f +} + + +# Snapshot of environment - without functions +# Sorted as non-OpenFOAM, WM_*, FOAM_* +printEnv() +{ + # Non FOAM_*, WM_* settings + echo "# non-OpenFOAM" + env | sed -n -e '\@^FOAM_@d' -e '\@^WM_@d' -e '\@^[^ {}]@p' \ + | sort -f + + # WM_* settings + echo "# OpenFOAM" + env | sed -n -e '\@^WM_@p' \ + | sort -f + + # FOAM_* settings + echo "# OpenFOAM" + env | sed -n -e '\@^FOAM_@p' \ + | sort -f +} + +# +# Initial snapshot of the environment (without functions) +# +printEnv > $tmpFiles.env.pre.log +printAlias > $tmpFiles.alias.pre.log + +# OpenFOAM settings +. $projectDir/etc/bashrc '' + +echo "Using openfoam: $WM_PROJECT_DIR" 1>&2 +echo "==> $moduleOutput" 1>&2 + +# Remove some cruft +unset FOAM_JOB_DIR FOAM_RUN FOAM_SETTINGS FOAM_INST_DIR +unset WM_PROJECT_USER_DIR WM_THIRD_PARTY_DIR +unset SCOTCH_VERSION + + +# Also remove user directories as being unreliable + +foamOldDirs="$CEI_HOME $BOOST_ARCH_PATH $CGAL_ARCH_PATH $FFTW_ARCH_PATH $MPI_ARCH_PATH $SCOTCH_ARCH_PATH \ +$FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN $WM_PROJECT_SITE \ +$FOAM_USER_APPBIN $FOAM_USER_LIBBIN" +foamClean=$WM_PROJECT_DIR/bin/foamCleanPath + +if [ -x "$foamClean" ] +then + cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" + cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \ + && LD_LIBRARY_PATH="$cleaned" + + # May not have/need any third party at all + if [ -n "$FOAM_EXT_LIBBIN" -a ! -d "$FOAM_EXT_LIBBIN" ] + then + cleaned=$($foamClean "$LD_LIBRARY_PATH" "$FOAM_EXT_LIBBIN") \ + && LD_LIBRARY_PATH="$cleaned" + + unset FOAM_EXT_LIBBIN + fi +fi +unset CEI_HOME +unset ENSIGHT9_INPUT ENSIGHT9_READER +unset ENSIGHT10_INPUT ENSIGHT10_READER + +# Always consider site to be bogus. If needed, should be done elsewhere. +unset FOAM_SITE_APPBIN FOAM_SITE_LIBBIN WM_PROJECT_SITE + +# Remove non-essential aliases +unalias wmDP 2>/dev/null +unalias wmInt32 2>/dev/null +unalias wmInt64 2>/dev/null +unalias wmSP 2>/dev/null +unalias wmSchedOff 2>/dev/null +unalias wmSchedOn 2>/dev/null +unalias wmSet 2>/dev/null +unalias wmUnset 2>/dev/null +unalias app 2>/dev/null +unalias foamSite 2>/dev/null +unalias lib 2>/dev/null +unalias run 2>/dev/null +unalias sol 2>/dev/null +unalias src 2>/dev/null +unalias tut 2>/dev/null +unalias util 2>/dev/null + +#------------------------------------------------ + +# Generalize environment. +# This needs rethinking since it largely duplicates logic from the etc/config.sh/settings +rewriteEnv() +{ + sed \ + -e 's@^\(FOAM_USER_APPBIN=\).*@\1$env(HOME)/OpenFOAM/$env(USER)-$env(WM_PROJECT_VERSION)/platforms/$env(WM_OPTIONS)/bin@' \ + -e 's@^\(FOAM_USER_LIBBIN=\).*@\1$env(HOME)/OpenFOAM/$env(USER)-$env(WM_PROJECT_VERSION)/platforms/$env(WM_OPTIONS)/lib@' \ + ; +} + +# +# Updated snapshot of the environment (without functions) +# +printEnv | rewriteEnv > $tmpFiles.env.post.log +printAlias > $tmpFiles.alias.post.log + + +# Create a diff of the environment and aliases +diff $tmpFiles.env.pre.log $tmpFiles.env.post.log > $tmpFiles.env.diff.log +diff $tmpFiles.alias.pre.log $tmpFiles.alias.post.log > $tmpFiles.alias.diff.log + +echo "# -------------------" > $moduleOutput + +# -------------------------------------------------- +# Environment other than PATH, LD_LIBRARY_PATH +echo "# Environment" >> $moduleOutput +grep '> ' $tmpFiles.env.diff.log | \ +sed \ + -e '/^> *PATH=/d' \ + -e '/^> *LD_LIBRARY_PATH=/d' \ + -e 's/^>/setenv /' \ + -e 's/=/ "/' -e 's/$/\"/' >> $moduleOutput + + +# -------------------------------------------------- +# Changes in PATH - without junk and system directories +echo "# PATH" >> $moduleOutput + +sed -ne 's/^< *PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.path.pre.log +sed -ne 's/^> *PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.path.post.log + +grep -vxFf $tmpFiles.path.pre.log $tmpFiles.path.post.log | \ +sed \ + -e '\@^/bin$@d' \ + -e '\@^/usr/bin$@d' \ + -e '\@^/usr/local/bin$@d' \ + -e '\@^[.]$@d' \ + -e '\@^$@d' \ + > $tmpFiles.path.diff.log + +sed \ + -e 's/^/append-path PATH "/' \ + -e 's/$/\"/' \ + $tmpFiles.path.diff.log >> $moduleOutput +# -------------------------------------------------- + +# -------------------------------------------------- +# Changes in LD_LIBRARY_PATH - without junk and system directories +echo "# LD_LIBRARY_PATH" >> $moduleOutput + +sed -ne 's/^< *LD_LIBRARY_PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.ldpath.pre.log +sed -ne 's/^> *LD_LIBRARY_PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.ldpath.post.log + +grep -vxFf $tmpFiles.ldpath.pre.log $tmpFiles.ldpath.post.log | \ +sed \ + -e '\@^/lib.*$@d' \ + -e '\@^/usr/lib.*$@d' \ + -e '\@^/usr/local/lib.*$@d' \ + -e '\@^[.]$@d' \ + -e '\@^$@d' \ + > $tmpFiles.ldpath.diff.log + +sed \ + -e 's/^/append-path LD_LIBRARY_PATH "/' \ + -e 's/$/\"/' \ + $tmpFiles.ldpath.diff.log >> $moduleOutput + + +# ------------------- +# aliases +# Some diff give "> alias". Others give ">", needed extended regular expressions '-r' + +echo "# aliases" >> $moduleOutput +cat $tmpFiles.alias.diff.log | \ + sed -r -n -e 's/^> (alias)?/set-alias /p' | \ + sed -e "s/='/ \"/" -e "s/'/\"/g" >> $moduleOutput + +echo "# -------------------" >> $moduleOutput + +# ----------------------------------------------------------------------------- -- GitLab From 8f444b71646f39edfef6c51e791b07bf9e34845c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 13 Nov 2017 09:21:11 +0100 Subject: [PATCH 118/126] ENH: support change of Pstream buffer format via flag modifier - allows changing the format of the sending OPstream at an arbitrary point in the transmission. The information is passed through the buffer and the receiving IPstream changes its format accordingly. This allows a temporary toggling of ASCII/BINARY mid-stream. --- .../db/IOstreams/Pstreams/UIPstream.C | 59 +++++++++++++++++-- .../db/IOstreams/Pstreams/UOPstream.C | 3 +- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index 1ed965b7580..76f97060938 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -29,6 +29,24 @@ License #include "token.H" #include <cctype> +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +namespace Foam +{ +// Adjust stream format based on the flagMask +inline static void processFlags(Istream& is, int flagMask) +{ + if ((flagMask & token::ASCII)) + { + is.format(IOstream::ASCII); + } + else if ((flagMask & token::BINARY)) + { + is.format(IOstream::BINARY); + } +} +} + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -121,19 +139,48 @@ Foam::UIPstream::~UIPstream() Foam::Istream& Foam::UIPstream::read(token& t) { // Return the put back token if it exists + // - with additional handling for special stream flags if (Istream::getBack(t)) { - return *this; + if (t.isFlag()) + { + processFlags(*this, t.flagToken()); + } + else + { + return *this; + } } - char c; + // Read character, return on error + // - with additional handling for special stream flags - // Return on error - if (!read(c)) + char c; + do { - t.setBad(); - return *this; + if (!read(c)) + { + t.setBad(); // Error + return *this; + } + + if (c == token::FLAG) + { + char flagVal; + + if (read(flagVal)) + { + processFlags(*this, flagVal); + } + else + { + t.setBad(); // Error + return *this; + } + } } + while (c == token::FLAG); + // Set the line number of this token to the current stream line number t.lineNumber() = lineNumber(); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index b5c63d0c576..6b5a46ed6f2 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -193,7 +193,8 @@ bool Foam::UOPstream::write(const token& tok) { case token::tokenType::FLAG : { - // silently consume the flag + writeToBuffer(char(token::tokenType::FLAG)); + writeToBuffer(char(tok.flagToken())); return true; } -- GitLab From 7924f24b4ab4f3000d53710a407fdd60c6a0f827 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 8 Nov 2017 09:09:41 +0000 Subject: [PATCH 119/126] STYLE: overLaplacianFoam: removed unused entries --- .../heatTransfer/constant/dynamicMeshDict | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict index 9f766ac2725..c09be9266f5 100644 --- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict +++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict @@ -25,9 +25,4 @@ displacementLaplacianCoeffs dynamicFvMesh dynamicOversetFvMesh; -dynamicOversetFvMeshCoeffs -{ -// layerRelax 0.3; -} - // ************************************************************************* // -- GitLab From 1d925c736cef4f37919c428cace7e97878eb5347 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 8 Nov 2017 14:20:47 +0000 Subject: [PATCH 120/126] STYLE: searchableSurfaces: typo in comment --- .../searchableSurfacesQueries/searchableSurfacesQueries.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H index 404bb857759..bf863e96cf4 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H +++ b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H @@ -138,7 +138,7 @@ public: //- Find nearest points that are on all supplied surfaces // (nearest point if single surface; nearest intersection by - // steepst descent if on multiple surfaces). Returns current + // steepest descent if on multiple surfaces). Returns current // best guess). Wip. static void findNearest ( -- GitLab From 5a6b59d8b0447e52982e9042713fe2be5ea92b53 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 13 Nov 2017 08:57:43 +0000 Subject: [PATCH 121/126] ENH: snappyHexMesh: added missing entry --- .../utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 08eac7ef835..3cc156d30c3 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -459,7 +459,9 @@ snapControls //- When splitting the minimum area ratio of faces. If face split // causes ratio of area less than this do not split. Default is 0.3 //minAreaRatio 0.3; - + //- Attract points only to the surface they originate from. Default + // false. This can improve snapping of intersecting surfaces. + // strictRegionSnap true; } // Settings for the layer addition. -- GitLab From 14d4484faeb78e7af7031769ec8eb460c5bae62a Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 13 Nov 2017 10:37:38 +0100 Subject: [PATCH 122/126] STYLE: single-string findStrings deprecated in favour of stringOps::match - reduces ambiguity between matching a list of strings and a single string. --- .../foamToTecplot360/foamToTecplot360.C | 4 ++-- .../dataConversion/foamToVTK/foamToVTK.C | 4 ++-- .../primitives/strings/lists/stringListOps.H | 9 ++------- .../primitives/strings/stringOps/stringOps.H | 8 ++++++++ src/OpenFOAM/primitives/strings/wordRes/wordResI.H | 1 - src/conversion/ccm/reader/ccmSolutionTable.H | 12 ++++++------ src/conversion/common/tables/boundaryRegion.C | 4 ++-- src/conversion/common/tables/cellTable.C | 6 +++--- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C index 98f14db9182..f5b74224638 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C @@ -79,7 +79,7 @@ Usage #include "tensorIOField.H" #include "passiveParticleCloud.H" #include "faceSet.H" -#include "stringListOps.H" +#include "stringOps.H" #include "wordReList.H" #include "meshSubsetHelper.H" @@ -137,7 +137,7 @@ labelList getSelectedPatches Info<< " discarding empty/processor patch " << patchi << " " << pp.name() << endl; } - else if (findStrings(excludePatches, pp.name())) + else if (stringOps::match(excludePatches, pp.name())) { Info<< " excluding patch " << patchi << " " << pp.name() << endl; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index e84e12f118c..eb6b3b6dddc 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -154,7 +154,7 @@ Note #include "faceZoneMesh.H" #include "Cloud.H" #include "passiveParticle.H" -#include "stringListOps.H" +#include "stringOps.H" #include "meshSubsetHelper.H" #include "readFields.H" @@ -1172,7 +1172,7 @@ int main(int argc, char *argv[]) { const polyPatch& pp = patches[patchi]; - if (findStrings(excludePatches, pp.name())) + if (stringOps::match(excludePatches, pp.name())) { // Skip excluded patch continue; diff --git a/src/OpenFOAM/primitives/strings/lists/stringListOps.H b/src/OpenFOAM/primitives/strings/lists/stringListOps.H index 0ea3266d3ea..b87f1bd59c2 100644 --- a/src/OpenFOAM/primitives/strings/lists/stringListOps.H +++ b/src/OpenFOAM/primitives/strings/lists/stringListOps.H @@ -44,19 +44,14 @@ SourceFiles namespace Foam { - // Single-string matches: - - //- Return true if text matches one of the regular expressions - // The primary purpose of this function is to automatically convert - // a wordReList to a wordRes for matching. + //- Single-string match for one of the regular expressions + // \deprecated use stringOps::match instead (deprecated NOV-2017) inline bool findStrings(const wordRes& matcher, const std::string& text) { return matcher(text); } - // Multi-string matches: - //- Extract list indices // The unary match predicate has the following signature: // \code diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H index 3ae8bf4f4f3..7146891d37b 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H @@ -42,6 +42,7 @@ SourceFiles #include "dictionary.H" #include "HashTable.H" #include "stringOpsSort.H" +#include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,6 +62,13 @@ namespace stringOps // Correctly handles nullptr. std::string::size_type count(const char* str, const char c); + //- Return true if text matches one of the regular expressions. + // Simply forwards a wordReList to a wordRes for the matching. + inline bool match(const wordReList& patterns, const std::string& text) + { + return wordRes(patterns).match(text); + } + //- Expand occurences of variables according to the mapping // Expansion includes: diff --git a/src/OpenFOAM/primitives/strings/wordRes/wordResI.H b/src/OpenFOAM/primitives/strings/wordRes/wordResI.H index 600c228340d..504c0642b48 100644 --- a/src/OpenFOAM/primitives/strings/wordRes/wordResI.H +++ b/src/OpenFOAM/primitives/strings/wordRes/wordResI.H @@ -23,7 +23,6 @@ License \*---------------------------------------------------------------------------*/ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::wordRes::wordRes diff --git a/src/conversion/ccm/reader/ccmSolutionTable.H b/src/conversion/ccm/reader/ccmSolutionTable.H index cf954872e53..a2d740c8a0e 100644 --- a/src/conversion/ccm/reader/ccmSolutionTable.H +++ b/src/conversion/ccm/reader/ccmSolutionTable.H @@ -30,7 +30,7 @@ Description #include "SLList.H" #include "Ostream.H" -#include "stringListOps.H" +#include "stringOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -109,21 +109,21 @@ public: { List<word> matched(SLList<T>::size()); - label matchI = 0; + label matchi = 0; forAllConstIters(*this, iter) { const word& name = iter().name(); if ( - findStrings(whiteLst, name) - && !findStrings(blackLst, name) + stringOps::match(whiteLst, name) + && !stringOps::match(blackLst, name) ) { - matched[matchI++] = name; + matched[matchi++] = name; } } - matched.setSize(matchI); + matched.setSize(matchi); return matched; } diff --git a/src/conversion/common/tables/boundaryRegion.C b/src/conversion/common/tables/boundaryRegion.C index 12930ef06f3..a6ff68b1e0e 100644 --- a/src/conversion/common/tables/boundaryRegion.C +++ b/src/conversion/common/tables/boundaryRegion.C @@ -26,7 +26,7 @@ License #include "boundaryRegion.H" #include "IOMap.H" #include "OFstream.H" -#include "stringListOps.H" +#include "stringOps.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -109,7 +109,7 @@ Foam::Map<Foam::word> Foam::boundaryRegion::names "boundaryRegion_" + Foam::name(iter.key()) ); - if (findStrings(patterns, lookupName)) + if (stringOps::match(patterns, lookupName)) { lookup.insert(iter.key(), lookupName); } diff --git a/src/conversion/common/tables/cellTable.C b/src/conversion/common/tables/cellTable.C index 5d9e137caba..6478f499120 100644 --- a/src/conversion/common/tables/cellTable.C +++ b/src/conversion/common/tables/cellTable.C @@ -27,7 +27,7 @@ License #include "IOMap.H" #include "OFstream.H" #include "wordList.H" -#include "stringListOps.H" +#include "stringOps.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -179,7 +179,7 @@ Foam::Map<Foam::word> Foam::cellTable::names "cellTable_" + Foam::name(iter.key()) ); - if (findStrings(patterns, lookupName)) + if (stringOps::match(patterns, lookupName)) { lookup.insert(iter.key(), lookupName); } @@ -523,7 +523,7 @@ void Foam::cellTable::combine(const dictionary& mapDict, labelList& tableIds) Map<word> matches; forAllConstIter(Map<word>, origNames, namesIter) { - if (findStrings(patterns, namesIter())) + if (stringOps::match(patterns, namesIter())) { matches.insert(namesIter.key(), namesIter()); } -- GitLab From 817b9a14ba55d6248b0038c52e93d34ab28c14ad Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 13 Nov 2017 11:06:26 +0100 Subject: [PATCH 123/126] BUG: missing space in ensight (surface format) case file (closes #637) - occurred when variable name exceeded the 15-char alignment format and the name run into the previous field. --- .../writers/ensight/ensightSurfaceWriterTemplates.C | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C index 6db990686d1..c87d6f19cd9 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C @@ -99,9 +99,13 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated << "model: 1 " << osGeom.name().name() << nl << nl << "VARIABLE" << nl - << ensightPTraits<Type>::typeName << " per " - << word(isNodeValues ? "node:" : "element:") - << setw(3) << 1 + << ensightPTraits<Type>::typeName + << + ( + isNodeValues + ? " per node: 1 " // time-set 1 + : " per element: 1 " // time-set 1 + ) << setw(15) << varName << " " << surfName.c_str() << ".********." << varName << nl << nl -- GitLab From 0ca0a6264b1b44cd337752bb0c0cef1c50105c01 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 13 Nov 2017 11:23:17 +0100 Subject: [PATCH 124/126] STYLE: use readLabel/readScalar (string) instead of via IStringStream --- .../conversion/ideasUnvToFoam/ideasUnvToFoam.C | 16 +++++++++------- .../ensight/ensightSurfaceWriterTemplates.C | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 7e09194c379..398351e3f80 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -68,9 +68,11 @@ namespace Foam return Hash<face>::operator()(t, 0); } } + const string SEPARATOR(" -1"); -bool isSeparator(const string& line) + +bool isSeparator(const std::string& line) { return line.substr(0, 6) == SEPARATOR; } @@ -100,7 +102,7 @@ label readTag(IFstream& is) } while (tag == SEPARATOR); - return readLabel(IStringStream(tag)()); + return readLabel(tag); } @@ -144,14 +146,14 @@ void skipSection(IFstream& is) } -scalar readUnvScalar(const string& unvString) +scalar readUnvScalar(const std::string& unvString) { string s(unvString); s.replaceAll("d", "E"); s.replaceAll("D", "E"); - return readScalar(IStringStream(s)()); + return readScalar(s); } @@ -170,13 +172,13 @@ void readUnits string line; is.getLine(line); - label l = readLabel(IStringStream(line.substr(0, 10))()); + label l = readLabel(line.substr(0, 10)); Info<< "l:" << l << endl; string units(line.substr(10, 20)); Info<< "units:" << units << endl; - label unitType = readLabel(IStringStream(line.substr(30, 10))()); + label unitType = readLabel(line.substr(30, 10)); Info<< "unitType:" << unitType << endl; // Read lengthscales @@ -215,7 +217,7 @@ void readPoints string line; is.getLine(line); - label pointi = readLabel(IStringStream(line.substr(0, 10))()); + label pointi = readLabel(line.substr(0, 10)); if (pointi == -1) { diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C index c87d6f19cd9..84fdfb1f3f7 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C @@ -70,7 +70,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated } // const scalar timeValue = Foam::name(this->mesh().time().timeValue()); - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); OFstream osCase(baseDir/surfName + ".case"); ensightGeoFile osGeom @@ -179,7 +179,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated // surfName already validated const fileName meshFile(baseDir/surfName + ".000000.mesh"); - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); label timeIndex = 0; // Do case file @@ -194,7 +194,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated if (is.good() && dict.read(is)) { dict.lookup("times") >> times; - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); label index = findLower(times, timeValue); timeIndex = index+1; } -- GitLab From 6eaa143825ed4e54c6b94206d28befce9dd1dc71 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 13 Nov 2017 11:44:19 +0000 Subject: [PATCH 125/126] BUG: foamListTimes: reinstated. Fixes #638. --- .../miscellaneous/foamListTimes/Make/files | 3 + .../miscellaneous/foamListTimes/Make/options | 2 + .../foamListTimes/foamListTimes.C | 174 ++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 applications/utilities/miscellaneous/foamListTimes/Make/files create mode 100644 applications/utilities/miscellaneous/foamListTimes/Make/options create mode 100644 applications/utilities/miscellaneous/foamListTimes/foamListTimes.C diff --git a/applications/utilities/miscellaneous/foamListTimes/Make/files b/applications/utilities/miscellaneous/foamListTimes/Make/files new file mode 100644 index 00000000000..fe66ad82248 --- /dev/null +++ b/applications/utilities/miscellaneous/foamListTimes/Make/files @@ -0,0 +1,3 @@ +foamListTimes.C + +EXE = $(FOAM_APPBIN)/foamListTimes diff --git a/applications/utilities/miscellaneous/foamListTimes/Make/options b/applications/utilities/miscellaneous/foamListTimes/Make/options new file mode 100644 index 00000000000..18e6fe47afa --- /dev/null +++ b/applications/utilities/miscellaneous/foamListTimes/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C new file mode 100644 index 00000000000..5aa7389d764 --- /dev/null +++ b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C @@ -0,0 +1,174 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +------------------------------------------------------------------------------- +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/>. + +Application + foamListTimes + +Group + grpPostProcessingUtilities + +Description + List times using timeSelector. + To simplify parsing of the output, the normal banner information + is suppressed. + +Usage + \b foamListTimes [OPTION] + + Options: + - \par -rm + Remove selected time directories + + - \par -processor + List times from processor0/ directory + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "profiling.H" +#include "timeSelector.H" +#include "Time.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote("List times using timeSelector"); + + timeSelector::addOptions(true, true); + argList::noBanner(); + argList::noParallel(); + argList::noJobInfo(); + argList::addBoolOption + ( + "processor", + "list times from processor0/ directory" + ); + argList::addBoolOption + ( + "rm", + "remove selected time directories" + ); + profiling::disable(); // Disable profiling (and its output) + + #include "setRootCase.H" + + label nProcs = 0; + + // Create the processor databases + PtrList<Time> databases(1); + + if (args.optionFound("processor")) + { + // Determine the processor count directly + while (isDir(args.path()/(word("processor") + name(nProcs)))) + { + ++nProcs; + } + + if (!nProcs) + { + FatalErrorInFunction + << "No processor* directories found" + << exit(FatalError); + } + + // Create the processor databases + databases.setSize(nProcs); + + forAll(databases, proci) + { + databases.set + ( + proci, + new Time + ( + Time::controlDictName, + args.rootPath(), + args.caseName()/fileName(word("processor") + name(proci)) + ) + ); + } + } + else + { + databases.set + ( + 0, + new Time + ( + Time::controlDictName, + args.rootPath(), + args.caseName() + ) + ); + } + + // Use the times list from the master processor + // and select a subset based on the command-line options + instantList timeDirs = timeSelector::select + ( + databases[0].times(), + args + ); + + if (args.optionFound("rm")) + { + if (args.optionFound("processor")) + { + for (label proci=0; proci<nProcs; proci++) + { + fileName procPath + ( + args.path()/(word("processor") + name(proci)) + ); + + forAll(timeDirs, timeI) + { + rmDir(procPath/timeDirs[timeI].name()); + } + } + } + else + { + forAll(timeDirs, timeI) + { + rmDir(args.path()/timeDirs[timeI].name()); + } + } + } + else + { + forAll(timeDirs, timeI) + { + Info<< timeDirs[timeI].name() << endl; + } + } + + return 0; +} + + +// ************************************************************************* // -- GitLab From 0bb53ab6f3203a2d2426da17f534ee5f725ac4ff Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 15 Nov 2017 12:34:39 +0000 Subject: [PATCH 126/126] BUG: ptscotch: truncate decomposition back to correct number of cells. Fixes #642. --- src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C index 95b8647ee4a..0f6d6a05560 100644 --- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C +++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C @@ -770,9 +770,9 @@ Foam::label Foam::ptscotchDecomp::decompose feenableexcept(oldExcepts); #endif + // See above note to have size 1. Undo. + finalDecomp.setSize(xadjSize-1); - - //finalDecomp.setSize(xadjSize-1); //check //( // SCOTCH_dgraphPart -- GitLab