From bd947865f2881af1c52b458aa6b6b1b1844ce254 Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Sun, 10 May 2015 09:18:46 -0400 Subject: [PATCH] controlSwitches: - Improved handling of the control switch description - Added a few switch descriptions. --- src/foam/db/IOstreams/Pstreams/Pstream.C | 3 +- src/foam/db/typeInfo/className.H | 19 ++++++---- .../global/controlSwitches/constantsSwitch.H | 4 +- .../global/controlSwitches/controlSwitches.C | 38 ++++++++++++++++--- .../global/controlSwitches/controlSwitches.H | 7 ++-- src/foam/global/controlSwitches/debugSwitch.H | 4 +- src/foam/global/controlSwitches/infoSwitch.H | 4 +- .../controlSwitches/optimisationSwitch.H | 19 +++------- .../global/controlSwitches/tolerancesSwitch.H | 4 +- .../GGIInterpolationQuickRejectTests.C | 12 ++++-- .../GGIInterpolationWeights.C | 6 ++- .../polyPatches/constraint/ggi/ggiPolyPatch.C | 7 +++- .../radiationConstants/radiationConstants.C | 3 +- .../specie/specie/specie.C | 9 +++-- 14 files changed, 94 insertions(+), 45 deletions(-) diff --git a/src/foam/db/IOstreams/Pstreams/Pstream.C b/src/foam/db/IOstreams/Pstreams/Pstream.C index 70c7ca0d6..da22fbd6b 100644 --- a/src/foam/db/IOstreams/Pstreams/Pstream.C +++ b/src/foam/db/IOstreams/Pstreams/Pstream.C @@ -260,7 +260,8 @@ const Foam::debug::optimisationSwitch Foam::Pstream::defaultCommsType ( "commsType", - "blocking" + "blocking", + "blocking, nonBlocking, scheduled" ); // ************************************************************************* // diff --git a/src/foam/db/typeInfo/className.H b/src/foam/db/typeInfo/className.H index ff61a0e3f..aa1332c8a 100644 --- a/src/foam/db/typeInfo/className.H +++ b/src/foam/db/typeInfo/className.H @@ -133,24 +133,24 @@ public: \ //- Define the debug information, lookup as @a Name -#define defineDebugSwitchWithName(Type, Name, DebugSwitch) \ +#define defineDebugSwitchWithName(Type, Name, DebugSwitch, SwitchDescr) \ ::Foam::debug::debugSwitch \ - Type::debug(std::string(Name), DebugSwitch) + Type::debug(std::string(Name), DebugSwitch, SwitchDescr) //- Define the debug information -#define defineDebugSwitch(Type, DebugSwitch) \ - defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch); +#define defineDebugSwitch(Type, DebugSwitch, SwitchDescr) \ + defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch, SwitchDescr); #ifdef __INTEL_COMPILER //- Define the debug information for templates, lookup as @a Name # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \ - defineDebugSwitchWithName(Type, Name, DebugSwitch); + defineDebugSwitchWithName(Type, Name, DebugSwitch, ""); #else //- Define the debug information for templates, lookup as @a Name # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \ template<> \ - defineDebugSwitchWithName(Type, Name, DebugSwitch); + defineDebugSwitchWithName(Type, Name, DebugSwitch, ""); #endif //- Define the debug information for templates @@ -172,7 +172,12 @@ public: \ //- Define the typeName and debug information #define defineTypeNameAndDebug(Type, DebugSwitch) \ defineTypeName(Type); \ - defineDebugSwitch(Type, DebugSwitch) + defineDebugSwitch(Type, DebugSwitch, "") + +//- Define the typeName and debug information + description +#define defineTypeNameAndDebugWithDescription(Type, DebugSwitch, SwitchDescr) \ + defineTypeName(Type); \ + defineDebugSwitch(Type, DebugSwitch, SwitchDescr) //- Define the typeName and debug information, lookup as @a Name #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \ diff --git a/src/foam/global/controlSwitches/constantsSwitch.H b/src/foam/global/controlSwitches/constantsSwitch.H index 149adfb4f..9e4848151 100644 --- a/src/foam/global/controlSwitches/constantsSwitch.H +++ b/src/foam/global/controlSwitches/constantsSwitch.H @@ -61,13 +61,15 @@ public: constantsSwitch ( const std::string& switchName, - const Foam::scalar& switchValue + const Foam::scalar& switchValue, + const std::string& switchDescription = "" ) : controlSwitches ( switchName, debug::constantsFromDict(switchName.c_str(), switchValue), + switchDescription, debug::DIMENSIONEDCONSTANTS, &constantsSwitchValues_ ) diff --git a/src/foam/global/controlSwitches/controlSwitches.C b/src/foam/global/controlSwitches/controlSwitches.C index 589efa365..b908ea249 100644 --- a/src/foam/global/controlSwitches/controlSwitches.C +++ b/src/foam/global/controlSwitches/controlSwitches.C @@ -41,7 +41,8 @@ namespace debug template Foam::debug::controlSwitches::controlSwitches() : - switchValue_(Type(0)) + switchValue_(Type(0)), + switchDescription_("") { } @@ -57,13 +58,15 @@ Foam::debug::controlSwitches::controlSwitches ( const std::string& switchName, const T& switchValue, + const std::string& switchDescription, globalControlDictSwitchSet switchSet, std::map *> >** switchValuesTable ) : switchSet_(switchSet), switchName_(switchName), - switchValue_(switchValue) + switchValue_(switchValue), + switchDescription_(switchDescription) { // Register the switch in its list if (*switchValuesTable == NULL) @@ -92,7 +95,8 @@ template Foam::debug::controlSwitches::controlSwitches(const Foam::debug::controlSwitches& csw) : switchName_(csw.switchName_), - switchValue_(csw.switchValue_) + switchValue_(csw.switchValue_), + switchDescription_(csw.switchDescription_) {} @@ -134,6 +138,7 @@ void Foam::debug::controlSwitches::operator=(const Foam::debug::controlSwitch else { switchValue_ = rhs.switchValue_; + switchDescription_ = rhs.switchDescription_; } } @@ -208,11 +213,32 @@ void printControlSwitches std::cout << value() << ";"; } - std::string swDescr = value.switchDescription(); + // Now, for the switch description, since numerous switches might + // be defined with identical names, but different descriptions + // eg: ggi debugSwitch, we will concatenate all the non-empty + // switches descriptions for a given switch - if( !swDescr.empty() ) + std::string switchDescription(""); + + typename std::list *>::iterator itL; + for (itL = swList.begin(); itL != swList.end(); itL++) { - std::cout << " // " << swDescr; + Foam::debug::controlSwitches& sw = *(*itL); + std::string thisSwitchDescr = sw.switchDescription(); + + if + ( + !thisSwitchDescr.empty() && + switchDescription.find(thisSwitchDescr) == std::string::npos + ) + { + switchDescription += thisSwitchDescr + ". "; + } + } + + if (!switchDescription.empty()) + { + std::cout << "\t// " << switchDescription; } std::cout << std::endl; } diff --git a/src/foam/global/controlSwitches/controlSwitches.H b/src/foam/global/controlSwitches/controlSwitches.H index 5c6c3bbf1..7708ded51 100644 --- a/src/foam/global/controlSwitches/controlSwitches.H +++ b/src/foam/global/controlSwitches/controlSwitches.H @@ -90,12 +90,12 @@ class controlSwitches //- Switch name std::string switchName_; - //- Switch Description - std::string switchDescription_; - //- Switch value T switchValue_; + //- Switch Description + std::string switchDescription_; + //- Handle to runTime switches list std::map *> >* switchValuesTable_ ; @@ -115,6 +115,7 @@ public: ( const std::string& switchName, const T& switchValue, + const std::string& switchDescription, globalControlDictSwitchSet switchSet, std::map *> >** switchesValues ); diff --git a/src/foam/global/controlSwitches/debugSwitch.H b/src/foam/global/controlSwitches/debugSwitch.H index dcb9223a3..1a22027bc 100644 --- a/src/foam/global/controlSwitches/debugSwitch.H +++ b/src/foam/global/controlSwitches/debugSwitch.H @@ -60,13 +60,15 @@ public: debugSwitch ( const std::string& switchName, - const int& switchValue + const int& switchValue, + const std::string& switchDescription = "" ) : controlSwitches ( switchName, debug::debugSwitchFromDict(switchName.c_str(), switchValue), + switchDescription, debug::DEBUGSWITCHES, &debugSwitchValues_ ) diff --git a/src/foam/global/controlSwitches/infoSwitch.H b/src/foam/global/controlSwitches/infoSwitch.H index 5856a7bb6..bf7b66713 100644 --- a/src/foam/global/controlSwitches/infoSwitch.H +++ b/src/foam/global/controlSwitches/infoSwitch.H @@ -59,13 +59,15 @@ public: infoSwitch ( const std::string& switchName, - const int& switchValue + const int& switchValue, + const std::string& switchDescription = "" ) : controlSwitches ( switchName, debug::infoSwitchFromDict(switchName.c_str(), switchValue), + switchDescription, debug::INFOSWITCHES, &infoSwitchValues_ ) diff --git a/src/foam/global/controlSwitches/optimisationSwitch.H b/src/foam/global/controlSwitches/optimisationSwitch.H index 97a7da5a7..ceac00b52 100644 --- a/src/foam/global/controlSwitches/optimisationSwitch.H +++ b/src/foam/global/controlSwitches/optimisationSwitch.H @@ -60,13 +60,15 @@ public: optimisationSwitch ( const std::string& switchName, - const int& switchValue + const int& switchValue, + const std::string& switchDescription = "" ) : controlSwitches ( switchName, debug::optimisationSwitchFromDict(switchName.c_str(), switchValue), + switchDescription, debug::OPTIMISATIONSWITCHES, &optimisationSwitchValues_ ) @@ -77,13 +79,15 @@ public: optimisationSwitch ( const std::string& switchName, - const std::string& switchValue + const std::string& switchValue, + const std::string& switchDescription = "" ) : controlSwitches ( switchName, debug::optimisationSwitchFromDict(switchName, switchValue), + switchDescription, debug::OPTIMISATIONSWITCHES, &optimisationSwitchValues_ ) @@ -103,17 +107,6 @@ public: { return controlSwitches::operator==(rhs); } - -#if 0 - // Cannot use a conversion operator for Pstream::commsTypes - // since including Pstream.H generates compilation errors. - // MB 06/2014 - operator Pstream::commsTypes () const - { - return static_cast(operator()()); - } -#endif - }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/foam/global/controlSwitches/tolerancesSwitch.H b/src/foam/global/controlSwitches/tolerancesSwitch.H index 49fc13cb2..b07fc8df3 100644 --- a/src/foam/global/controlSwitches/tolerancesSwitch.H +++ b/src/foam/global/controlSwitches/tolerancesSwitch.H @@ -60,13 +60,15 @@ public: tolerancesSwitch ( const std::string& switchName, - const Foam::scalar& switchValue + const Foam::scalar& switchValue, + const std::string& switchDescription = "" ) : controlSwitches ( switchName, debug::tolerancesFromDict(switchName.c_str(), switchValue), + switchDescription, debug::TOLERANCES, &tolerancesSwitchValues_ ) diff --git a/src/foam/interpolations/GGIInterpolation/GGIInterpolationQuickRejectTests.C b/src/foam/interpolations/GGIInterpolation/GGIInterpolationQuickRejectTests.C index d6ce813c2..bd1ac7216 100644 --- a/src/foam/interpolations/GGIInterpolation/GGIInterpolationQuickRejectTests.C +++ b/src/foam/interpolations/GGIInterpolation/GGIInterpolationQuickRejectTests.C @@ -48,7 +48,8 @@ const Foam::debug::tolerancesSwitch GGIInterpolation::faceBoundBoxExtendSpanFraction_ ( "GGIFaceBoundBoxExtendSpanFraction", - 1.0e-2 + 1.0e-2, + "GGI faces bounding box expansion factor. Add robustness for quick-search algo. Keep it to a few percent." ); template @@ -56,7 +57,8 @@ const Foam::debug::optimisationSwitch GGIInterpolation::octreeSearchMinNLevel_ ( "GGIOctreeSearchMinNLevel", - 3 + 3, + "GGI neighbouring facets octree-based search: minNlevel parameter for octree" ); template @@ -64,7 +66,8 @@ const Foam::debug::optimisationSwitch GGIInterpolation::octreeSearchMaxLeafRatio_ ( "GGIOctreeSearchMaxLeafRatio", - 3 + 3, + "GGI neighbouring facets octree-based search: maxLeafRatio parameter for octree" ); template @@ -72,7 +75,8 @@ const Foam::debug::optimisationSwitch GGIInterpolation::octreeSearchMaxShapeRatio_ ( "GGIOctreeSearchMaxShapeRatio", - 1 + 1, + "GGI neighbouring facets octree-based search: maxShapeRatio parameter for octree" ); diff --git a/src/foam/interpolations/GGIInterpolation/GGIInterpolationWeights.C b/src/foam/interpolations/GGIInterpolation/GGIInterpolationWeights.C index de8cf4de4..e6a5822e7 100644 --- a/src/foam/interpolations/GGIInterpolation/GGIInterpolationWeights.C +++ b/src/foam/interpolations/GGIInterpolation/GGIInterpolationWeights.C @@ -51,7 +51,8 @@ const Foam::debug::tolerancesSwitch GGIInterpolation::areaErrorTol_ ( "GGIAreaErrorTol", - 1.0e-8 + 1.0e-8, + "Minimum GGI face to face intersection area. The smallest accepted GGI weighting factor." ); template @@ -59,7 +60,8 @@ const Foam::debug::tolerancesSwitch GGIInterpolation::featureCosTol_ ( "GGIFeatureCosTol", - 0.8 + 0.8, + "Minimum cosine value between 2 GGI patch neighbouring facet normals." ); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.C b/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.C index 53f2a847e..1cf9e4630 100644 --- a/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.C +++ b/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.C @@ -43,7 +43,12 @@ Contributor namespace Foam { - defineTypeNameAndDebug(ggiPolyPatch, 0); + defineTypeNameAndDebugWithDescription + ( + ggiPolyPatch, + 0, + "If value > 1, write uncovered GGI patch facets to VTK file" + ); addToRunTimeSelectionTable(polyPatch, ggiPolyPatch, word); addToRunTimeSelectionTable(polyPatch, ggiPolyPatch, dictionary); diff --git a/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.C b/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.C index 1ba74aa0f..a3eb16559 100644 --- a/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.C +++ b/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.C @@ -33,7 +33,8 @@ const Foam::debug::constantsSwitch Foam::radiation::sigmaSB_ ( "sigmaSB", - 5.670E-08 + 5.670E-08, + "Stefan-Boltzmann constant [J/(K4 m2 s)]" ); const Foam::dimensionedScalar Foam::radiation::sigmaSB diff --git a/src/thermophysicalModels/specie/specie/specie.C b/src/thermophysicalModels/specie/specie/specie.C index 4617019c4..fdce717fa 100644 --- a/src/thermophysicalModels/specie/specie/specie.C +++ b/src/thermophysicalModels/specie/specie/specie.C @@ -37,7 +37,8 @@ const Foam::debug::constantsSwitch Foam::specie::RR ( "R", - 8314.51 + 8314.51, + "Universal gas constant [J/(kmol K)]" ); @@ -46,7 +47,8 @@ const Foam::debug::constantsSwitch Foam::specie::Pstd ( "Pstd", - 1.0e5 + 1.0e5, + "Standard pressure [Pa]" ); //- Standard temperature (default in [K]) @@ -54,7 +56,8 @@ const Foam::debug::constantsSwitch Foam::specie::Tstd ( "Tstd", - 298.15 + 298.15, + "Standard temperature [K]" ); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //