From a70045f38baebadd83694b9701b730d6e3502ebc Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Apr 2011 12:35:23 +0100 Subject: [PATCH 01/62] BUG: Allrun: uses bash construct --- .../boundaryFoam/boundaryWallFunctionsProfile/Allrun | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun index 99209508d7..d30f1362fc 100755 --- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun +++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash cd ${0%/*} || exit 1 # run from this directory # Source tutorial run functions From c3c9d7da5271cd98462c03b86a411211e8047aa2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Apr 2011 15:21:24 +0100 Subject: [PATCH 02/62] STYLE: scotchDecomp: updated default strategy string in header --- .../decompose/scotchDecomp/scotchDecomp.C | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/parallel/decompose/scotchDecomp/scotchDecomp.C b/src/parallel/decompose/scotchDecomp/scotchDecomp.C index 7efb29d40c..17ff685d49 100644 --- a/src/parallel/decompose/scotchDecomp/scotchDecomp.C +++ b/src/parallel/decompose/scotchDecomp/scotchDecomp.C @@ -65,7 +65,7 @@ License The current default mapping strategy in Scotch can be seen by using the "-vs" option of program gmap. It is, to date: - b + r { job=t, map=t, @@ -76,11 +76,17 @@ License { asc=b { - bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005}, - org=f{move=80,pass=-1,bal=0.005}, + bnd= + ( + d{pass=40,dif=1,rem=1} + | + ) + f{move=80,pass=-1,bal=0.002491}, + org=f{move=80,pass=-1,bal=0.002491}, width=3 }, - low=h{pass=10}f{move=80,pass=-1,bal=0.0005}, + low=h{pass=10} + f{move=80,pass=-1,bal=0.002491}, type=h, vert=80, rat=0.8 @@ -89,11 +95,17 @@ License { asc=b { - bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005}, - org=f{move=80,pass=-1,bal=0.005}, + bnd= + ( + d{pass=40,dif=1,rem=1} + | + ) + f{move=80,pass=-1,bal=0.002491}, + org=f{move=80,pass=-1,bal=0.002491}, width=3 }, - low=h{pass=10}f{move=80,pass=-1,bal=0.0005}, + low=h{pass=10} + f{move=80,pass=-1,bal=0.002491}, type=h, vert=80, rat=0.8 @@ -102,6 +114,9 @@ License } + Note: instead of gmap run gpart -vs + where can be obtained by running with 'writeGraph=true' + \*---------------------------------------------------------------------------*/ #include "scotchDecomp.H" From e7400dba6c1d6697d2ce3a2aeebe2484ea16e102 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Apr 2011 15:59:54 +0100 Subject: [PATCH 03/62] ENH: dynamicCodeContext: moved include to after sha1 calculation since adds processor dependency --- .../dynamicCode/dynamicCodeContext.C | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C index 81c1a50ceb..93d6ebbdd7 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C @@ -46,7 +46,6 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict) const entry& codeEntry = dict.lookupEntry("code", false, false); code_ = stringOps::trim(codeEntry.stream()); stringOps::inplaceExpand(code_, dict); - addLineDirective(code_, codeEntry.startLineNumber(), dict.name()); } // note: removes any leading/trailing whitespace @@ -64,7 +63,6 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict) { include_ = stringOps::trim(includePtr->stream()); stringOps::inplaceExpand(include_, dict); - addLineDirective(include_, includePtr->startLineNumber(), dict.name()); } // optional @@ -92,6 +90,28 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict) OSHA1stream os; os << include_ << options_ << libs_ << localCode_ << code_; sha1_ = os.digest(); + + + + // Add line number after calculating sha1 since includes processorDDD + // in path which differs between processors. + + { + const entry& codeEntry = dict.lookupEntry("code", false, false); + addLineDirective(code_, codeEntry.startLineNumber(), dict.name()); + } + if (includePtr) + { + addLineDirective(include_, includePtr->startLineNumber(), dict.name()); + } + if (optionsPtr) + { + addLineDirective(options_, optionsPtr->startLineNumber(), dict.name()); + } + if (libsPtr) + { + addLineDirective(libs_, libsPtr->startLineNumber(), dict.name()); + } } From 314372d5077505390787a8d38c42620fe93696cd Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Apr 2011 16:04:55 +0100 Subject: [PATCH 04/62] ENH: polyTopoChange: better debug info --- .../polyTopoChange/polyTopoChange.C | 95 +++++++++++++++++-- .../polyTopoChange/polyTopoChange.H | 6 ++ 2 files changed, 93 insertions(+), 8 deletions(-) diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 9d8e9ba2ca..e07eef5575 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -302,6 +302,35 @@ void Foam::polyTopoChange::getMergeSets } +bool Foam::polyTopoChange::hasValidPoints(const face& f) const +{ + forAll(f, fp) + { + if (f[fp] < 0 || f[fp] >= points_.size()) + { + return false; + } + } + return true; +} + + +Foam::pointField Foam::polyTopoChange::facePoints(const face& f) const +{ + pointField points(f.size()); + forAll(f, fp) + { + if (f[fp] < 0 && f[fp] >= points_.size()) + { + FatalErrorIn("polyTopoChange::facePoints(const face&) const") + << "Problem." << abort(FatalError); + } + points[fp] = points_[f[fp]]; + } + return points; +} + + void Foam::polyTopoChange::checkFace ( const face& f, @@ -329,7 +358,14 @@ void Foam::polyTopoChange::checkFace << "f:" << f << " faceI(-1 if added face):" << faceI << " own:" << own << " nei:" << nei - << " patchI:" << patchI << abort(FatalError); + << " patchI:" << patchI << nl; + if (hasValidPoints(f)) + { + FatalError + << "points (removed points marked with " + << vector::max << ") " << facePoints(f); + } + FatalError << abort(FatalError); } } else @@ -344,7 +380,14 @@ void Foam::polyTopoChange::checkFace << "f:" << f << " faceI(-1 if added face):" << faceI << " own:" << own << " nei:" << nei - << " patchI:" << patchI << abort(FatalError); + << " patchI:" << patchI << nl; + if (hasValidPoints(f)) + { + FatalError + << "points (removed points marked with " + << vector::max << ") : " << facePoints(f); + } + FatalError << abort(FatalError); } if (nei <= own) @@ -358,7 +401,14 @@ void Foam::polyTopoChange::checkFace << "f:" << f << " faceI(-1 if added face):" << faceI << " own:" << own << " nei:" << nei - << " patchI:" << patchI << abort(FatalError); + << " patchI:" << patchI << nl; + if (hasValidPoints(f)) + { + FatalError + << "points (removed points marked with " + << vector::max << ") : " << facePoints(f); + } + FatalError << abort(FatalError); } } @@ -373,7 +423,14 @@ void Foam::polyTopoChange::checkFace << "f:" << f << " faceI(-1 if added face):" << faceI << " own:" << own << " nei:" << nei - << " patchI:" << patchI << abort(FatalError); + << " patchI:" << patchI << nl; + if (hasValidPoints(f)) + { + FatalError + << "points (removed points marked with " + << vector::max << ") : " << facePoints(f); + } + FatalError << abort(FatalError); } if (faceI >= 0 && faceI < faces_.size() && faceRemoved(faceI)) { @@ -386,7 +443,14 @@ void Foam::polyTopoChange::checkFace << "f:" << f << " faceI(-1 if added face):" << faceI << " own:" << own << " nei:" << nei - << " patchI:" << patchI << abort(FatalError); + << " patchI:" << patchI << nl; + if (hasValidPoints(f)) + { + FatalError + << "points (removed points marked with " + << vector::max << ") : " << facePoints(f); + } + FatalError << abort(FatalError); } forAll(f, fp) { @@ -401,7 +465,14 @@ void Foam::polyTopoChange::checkFace << "f:" << f << " faceI(-1 if added face):" << faceI << " own:" << own << " nei:" << nei - << " patchI:" << patchI << abort(FatalError); + << " patchI:" << patchI << nl; + if (hasValidPoints(f)) + { + FatalError + << "points (removed points marked with " + << vector::max << ") : " << facePoints(f); + } + FatalError << abort(FatalError); } } } @@ -729,8 +800,16 @@ void Foam::polyTopoChange::getFaceOrder << " neighbour " << faceNeighbour_[faceI] << " region " << region_[faceI] << endl << "This is usually caused by not specifying a patch for" - << " a boundary face." - << abort(FatalError); + << " a boundary face." << nl + << "Switch on the polyTopoChange::debug flag to catch" + << " this error earlier." << nl; + if (hasValidPoints(faces_[faceI])) + { + FatalError + << "points (removed points marked with " + << vector::max << ") " << facePoints(faces_[faceI]); + } + FatalError << abort(FatalError); } } } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H index 1e5ae305ff..452550cd3c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -239,6 +239,12 @@ class polyTopoChange List& cellsFromCells ); + //- Are all face vertices valid + bool hasValidPoints(const face&) const; + + //- Return face points + pointField facePoints(const face& f) const; + //- Check inputs to modFace or addFace void checkFace ( From bf443b6e026466f6f2e8dbc9b213919c32178b90 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Apr 2011 16:11:10 +0100 Subject: [PATCH 05/62] ENH: combineFaces: added additional check on manifoldness --- .../polyTopoChange/polyTopoChange/combineFaces.C | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C index 0d5d6ef768..e22b15956c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C @@ -109,6 +109,12 @@ bool Foam::combineFaces::validFace return false; } + bool isNonManifold = bigFace.checkPointManifold(false, NULL); + if (isNonManifold) + { + return false; + } + // Check for convexness face f(getOutsideFace(bigFace)); @@ -984,6 +990,7 @@ void Foam::combineFaces::setUnrefinement zoneFlip // face flip in zone ) ); + restoredFaces.insert(masterFaceI, masterFaceI); // Add the previously removed faces for (label i = 1; i < faces.size(); i++) @@ -991,7 +998,7 @@ void Foam::combineFaces::setUnrefinement //Pout<< "Restoring removed face with vertices " << faces[i] // << endl; - meshMod.setAction + label faceI = meshMod.setAction ( polyAddFace ( @@ -1007,6 +1014,7 @@ void Foam::combineFaces::setUnrefinement zoneFlip // zoneFlip ) ); + restoredFaces.insert(faceI, masterFaceI); } // Clear out restored set From 84329ea4a0092c37544a90ec228992baba58ae3c Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 13 Apr 2011 16:17:39 +0100 Subject: [PATCH 06/62] STYLE: minor code formatting --- src/OSspecific/POSIX/regExp.H | 85 ++++++++++--------- .../primitives/strings/wordRe/wordRe.H | 76 ++++++++++------- 2 files changed, 88 insertions(+), 73 deletions(-) diff --git a/src/OSspecific/POSIX/regExp.H b/src/OSspecific/POSIX/regExp.H index 9106264ac8..067dfc54af 100644 --- a/src/OSspecific/POSIX/regExp.H +++ b/src/OSspecific/POSIX/regExp.H @@ -62,6 +62,7 @@ class regExp //- Precompiled regular expression mutable regex_t* preg_; + // Private Member Functions //- Disallow default bitwise copy construct @@ -72,6 +73,8 @@ class regExp public: + // Static Member Functions + //- Is character a regular expression meta-character? // any character: '.' \n // quantifiers: '*', '+', '?' \n @@ -102,66 +105,69 @@ public: //- Construct from std::string (or string), optionally ignoring case regExp(const std::string&, const bool ignoreCase=false); + //- Destructor ~regExp(); // Member functions - //- Access + // Access - //- Return true if a precompiled expression does not exist - inline bool empty() const - { - return !preg_; - } + //- Return true if a precompiled expression does not exist + inline bool empty() const + { + return !preg_; + } - //- Does a precompiled expression exist? - inline bool exists() const - { - return preg_ ? true : false; - } + //- Does a precompiled expression exist? + inline bool exists() const + { + return preg_ ? true : false; + } - //- Return the number of (groups) - inline int ngroups() const - { - return preg_ ? preg_->re_nsub : 0; - } + //- Return the number of (groups) + inline int ngroups() const + { + return preg_ ? preg_->re_nsub : 0; + } - //- Editing + // Editing - //- Compile pattern into a regular expression, optionally ignoring case - void set(const char*, const bool ignoreCase=false) const; + //- Compile pattern into a regular expression, optionally ignoring + // case + void set(const char*, const bool ignoreCase=false) const; - //- Compile pattern into a regular expression, optionally ignoring case - void set(const std::string&, const bool ignoreCase=false) const; + //- Compile pattern into a regular expression, optionally ignoring + // case + void set(const std::string&, const bool ignoreCase=false) const; - //- Release precompiled expression. - // Returns true if precompiled expression existed before clear - bool clear() const; + //- Release precompiled expression. + // Returns true if precompiled expression existed before clear + bool clear() const; - //- Searching + // Searching - //- Find position within string. - // Returns the index where it begins or string::npos if not found - std::string::size_type find(const std::string& str) const; + //- Find position within string. + // Returns the index where it begins or string::npos if not found + std::string::size_type find(const std::string& str) const; - //- Return true if it matches the entire string - // The begin-of-line (^) and end-of-line ($) anchors are implicit - bool match(const std::string&) const; + //- Return true if it matches the entire string + // The begin-of-line (^) and end-of-line ($) anchors are implicit + bool match(const std::string&) const; - //- Return true if it matches and sets the sub-groups matched - // The begin-of-line (^) and end-of-line ($) anchors are implicit - bool match(const string&, List& groups) const; + //- Return true if it matches and sets the sub-groups matched + // The begin-of-line (^) and end-of-line ($) anchors are implicit + bool match(const string&, List& groups) const; - //- Return true if the regex was found within string - bool search(const std::string& str) const - { - return std::string::npos != find(str); - } + //- Return true if the regex was found within string + bool search(const std::string& str) const + { + return std::string::npos != find(str); + } // Member Operators @@ -173,7 +179,6 @@ public: //- Assign and compile pattern from string // Always case sensitive void operator=(const std::string&); - }; diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H index 566f42af6c..8fd3eabc63 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -110,6 +110,7 @@ public: //- Test string for regular expression meta characters static inline bool isPattern(const string&); + // Constructors //- Construct null @@ -123,66 +124,75 @@ public: //- Construct as copy of character array // Optionally specify how it should be treated. - inline wordRe(const char*, const compOption=LITERAL); + inline wordRe(const char*, const compOption = LITERAL); //- Construct as copy of string. // Optionally specify how it should be treated. - inline wordRe(const string&, const compOption=LITERAL); + inline wordRe(const string&, const compOption = LITERAL); //- Construct as copy of std::string // Optionally specify how it should be treated. - inline wordRe(const std::string&, const compOption=LITERAL); + inline wordRe(const std::string&, const compOption = LITERAL); //- Construct from Istream // Words are treated as literals, strings with an auto-test wordRe(Istream&); + // Member functions - //- Access + // Access - //- Should be treated as a match rather than a literal string? - inline bool isPattern() const; + //- Should be treated as a match rather than a literal string? + inline bool isPattern() const; - //- Infrastructure - //- Compile the regular expression - inline bool compile() const; + // Infrastructure - //- Possibly compile the regular expression, with greater control - inline bool compile(const compOption) const; + //- Compile the regular expression + inline bool compile() const; - //- Recompile an existing regular expression - inline bool recompile() const; + //- Possibly compile the regular expression, with greater control + inline bool compile(const compOption) const; - //- Frees precompiled regular expression, making wordRe a literal. - // Optionally strips invalid word characters - inline void uncompile(const bool doStripInvalid=false) const; + //- Recompile an existing regular expression + inline bool recompile() const; - //- Editing + //- Frees precompiled regular expression, making wordRe a literal. + // Optionally strips invalid word characters + inline void uncompile(const bool doStripInvalid = false) const; - //- Copy string, auto-test for regular expression or other options - inline void set(const std::string&, const compOption=DETECT); - //- Copy string, auto-test for regular expression or other options - inline void set(const char*, const compOption=DETECT); + // Editing - //- Clear string and precompiled regular expression - inline void clear(); + //- Copy string, auto-test for regular expression or other options + inline void set(const std::string&, const compOption = DETECT); - //- Searching + //- Copy string, auto-test for regular expression or other options + inline void set(const char*, const compOption = DETECT); - //- Smart match as regular expression or as a string - // Optionally force a literal match only - inline bool match(const std::string&, bool literalMatch=false) const; + //- Clear string and precompiled regular expression + inline void clear(); - //- Miscellaneous - //- Return a string with quoted meta-characters - inline string quotemeta() const; + // Searching - //- Output some basic info - Ostream& info(Ostream&) const; + //- Smart match as regular expression or as a string + // Optionally force a literal match only + inline bool match + ( + const std::string&, + bool literalMatch = false + ) const; + + + // Miscellaneous + + //- Return a string with quoted meta-characters + inline string quotemeta() const; + + //- Output some basic info + Ostream& info(Ostream&) const; // Member operators From a653f2d02765726896591cd55a71dfc490fa9dff Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Apr 2011 17:11:36 +0100 Subject: [PATCH 07/62] BUG: wordRe: assignment from keyType not handled --- .../primitives/strings/wordRe/wordRe.H | 11 ++++++-- .../primitives/strings/wordRe/wordReI.H | 25 ++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H index 566f42af6c..bcb7dad5b1 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,6 +52,7 @@ SourceFiles #include "word.H" #include "regExp.H" +#include "keyType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,7 +61,6 @@ namespace Foam // Forward declaration of friend functions and operators class wordRe; - class Istream; class Ostream; @@ -118,6 +118,9 @@ public: //- Construct as copy inline wordRe(const wordRe&); + //- Construct from keyType + inline wordRe(const keyType&, const compOption=LITERAL); + //- Construct as copy of word inline wordRe(const word&); @@ -196,6 +199,10 @@ public: //- Copy word, never a regular expression inline const wordRe& operator=(const word&); + //- Copy keyType, auto-test for regular expression + // Always case sensitive + inline const wordRe& operator=(const keyType&); + //- Copy string, auto-test for regular expression // Always case sensitive inline const wordRe& operator=(const string&); diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H index 713c003064..fcbd1c3845 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,6 +65,18 @@ inline Foam::wordRe::wordRe(const word& str) {} +inline Foam::wordRe::wordRe(const keyType& str, const compOption opt) +: + word(str, false), + re_() +{ + if (str.isPattern()) + { + compile(opt); + } +} + + inline Foam::wordRe::wordRe(const char* str, const compOption opt) : word(str, false), @@ -236,6 +248,17 @@ inline const Foam::wordRe& Foam::wordRe::operator=(const word& str) } +inline const Foam::wordRe& Foam::wordRe::operator=(const keyType& str) +{ + string::operator=(str); + if (str.isPattern()) + { + compile(); + } + return *this; +} + + inline const Foam::wordRe& Foam::wordRe::operator=(const string& str) { string::operator=(str); From 8fde4f3b712092726749dec00e69fb99f75379a5 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 13 Apr 2011 17:13:35 +0100 Subject: [PATCH 08/62] ENH: Added pimpleControl class to offer better control for PIMPLE loops --- src/finiteVolume/Make/files | 1 + .../general/pimpleControl/pimpleControl.C | 191 ++++++++++++++++++ .../general/pimpleControl/pimpleControl.H | 141 +++++++++++++ .../general/pimpleControl/pimpleControlI.H | 82 ++++++++ 4 files changed, 415 insertions(+) create mode 100644 src/finiteVolume/cfdTools/general/pimpleControl/pimpleControl.C create mode 100644 src/finiteVolume/cfdTools/general/pimpleControl/pimpleControl.H create mode 100644 src/finiteVolume/cfdTools/general/pimpleControl/pimpleControlI.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 0ff3e598d9..f8aac2551b 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -352,6 +352,7 @@ general = cfdTools/general $(general)/findRefCell/findRefCell.C $(general)/adjustPhi/adjustPhi.C $(general)/bound/bound.C +$(general)/pimpleControl/pimpleControl.C porousMedia = $(general)/porousMedia $(porousMedia)/porousZone.C diff --git a/src/finiteVolume/cfdTools/general/pimpleControl/pimpleControl.C b/src/finiteVolume/cfdTools/general/pimpleControl/pimpleControl.C new file mode 100644 index 0000000000..77ae648eac --- /dev/null +++ b/src/finiteVolume/cfdTools/general/pimpleControl/pimpleControl.C @@ -0,0 +1,191 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "pimpleControl.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(pimpleControl, 0); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::label Foam::pimpleControl::applyToField(const word& fieldName) const +{ + forAll(residualControl_, i) + { + if (residualControl_[i].name.match(fieldName)) + { + return i; + } + } + + return -1; +} + + +bool Foam::pimpleControl::criteriaSatisfied() +{ + if ((corr_ == 0) || residualControl_.empty() || finalIter()) + { + return false; + } + + bool firstIter = corr_ == 1; + + bool achieved = true; + const dictionary& solverDict = mesh_.solverPerformanceDict(); + + forAllConstIter(dictionary, solverDict, iter) + { + const word& variableName = iter().keyword(); + label fieldI = applyToField(variableName); + if (fieldI != -1) + { + const List sp(iter().stream()); + const scalar residual = sp.last().initialResidual(); + + if (firstIter) + { + residualControl_[fieldI].initialResidual = + sp.first().initialResidual(); + } + + bool absCheck = residual < residualControl_[fieldI].absTol; + + bool relCheck = false; + + scalar relative = 0.0; + if (!firstIter) + { + scalar iniRes = + residualControl_[fieldI].initialResidual + + ROOTVSMALL; + + relative = residual/iniRes; + + relCheck = relative < residualControl_[fieldI].relTol; + } + + achieved = achieved && (absCheck || relCheck); + + if (debug) + { + Info<< "PIMPLE loop statistics:" << endl; + + Info<< " " << variableName << " iter " << corr_ + << ": ini res = " + << residualControl_[fieldI].initialResidual + << ", abs tol = " << residual + << " (" << residualControl_[fieldI].absTol << ")" + << ", rel tol = " << relative + << " (" << residualControl_[fieldI].relTol << ")" + << endl; + } + } + } + + return achieved; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pimpleControl::pimpleControl(fvMesh& mesh) +: + mesh_(mesh), + nCorr_(0), + corr_(0), + residualControl_() +{ + read(); + + if (residualControl_.size() > 0) + { + Info<< "PIMPLE: max iterations = " << nCorr_ << endl; + forAll(residualControl_, i) + { + Info<< " field " << residualControl_[i].name << token::TAB + << ": relTol " << residualControl_[i].relTol + << ", absTol " << residualControl_[i].absTol + << nl; + } + Info<< endl; + } + else + { + Info<< "No PIMPLE residual control data found. " + << "Calculations will employ a fixed number of corrector loops" + << nl << endl; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::pimpleControl::~pimpleControl() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::pimpleControl::read() +{ + const dictionary& dict = mesh_.solutionDict().subDict("PIMPLE"); + nCorr_ = dict.lookupOrDefault