controlSwitches: - Improved handling of the control switch description

- Added a few switch descriptions.
This commit is contained in:
Martin Beaudoin 2015-05-10 09:18:46 -04:00
parent 23f4d5cb81
commit bd947865f2
14 changed files with 94 additions and 45 deletions

View file

@ -260,7 +260,8 @@ const Foam::debug::optimisationSwitch
Foam::Pstream::defaultCommsType Foam::Pstream::defaultCommsType
( (
"commsType", "commsType",
"blocking" "blocking",
"blocking, nonBlocking, scheduled"
); );
// ************************************************************************* // // ************************************************************************* //

View file

@ -133,24 +133,24 @@ public: \
//- Define the debug information, lookup as @a Name //- Define the debug information, lookup as @a Name
#define defineDebugSwitchWithName(Type, Name, DebugSwitch) \ #define defineDebugSwitchWithName(Type, Name, DebugSwitch, SwitchDescr) \
::Foam::debug::debugSwitch \ ::Foam::debug::debugSwitch \
Type::debug(std::string(Name), DebugSwitch) Type::debug(std::string(Name), DebugSwitch, SwitchDescr)
//- Define the debug information //- Define the debug information
#define defineDebugSwitch(Type, DebugSwitch) \ #define defineDebugSwitch(Type, DebugSwitch, SwitchDescr) \
defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch); defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch, SwitchDescr);
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
//- Define the debug information for templates, lookup as @a Name //- Define the debug information for templates, lookup as @a Name
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \ # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
defineDebugSwitchWithName(Type, Name, DebugSwitch); defineDebugSwitchWithName(Type, Name, DebugSwitch, "");
#else #else
//- Define the debug information for templates, lookup as @a Name //- Define the debug information for templates, lookup as @a Name
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \ # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
template<> \ template<> \
defineDebugSwitchWithName(Type, Name, DebugSwitch); defineDebugSwitchWithName(Type, Name, DebugSwitch, "");
#endif #endif
//- Define the debug information for templates //- Define the debug information for templates
@ -172,7 +172,12 @@ public: \
//- Define the typeName and debug information //- Define the typeName and debug information
#define defineTypeNameAndDebug(Type, DebugSwitch) \ #define defineTypeNameAndDebug(Type, DebugSwitch) \
defineTypeName(Type); \ 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 the typeName and debug information, lookup as @a Name
#define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \ #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \

View file

@ -61,13 +61,15 @@ public:
constantsSwitch constantsSwitch
( (
const std::string& switchName, const std::string& switchName,
const Foam::scalar& switchValue const Foam::scalar& switchValue,
const std::string& switchDescription = ""
) )
: :
controlSwitches<Foam::scalar> controlSwitches<Foam::scalar>
( (
switchName, switchName,
debug::constantsFromDict(switchName.c_str(), switchValue), debug::constantsFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::DIMENSIONEDCONSTANTS, debug::DIMENSIONEDCONSTANTS,
&constantsSwitchValues_ &constantsSwitchValues_
) )

View file

@ -41,7 +41,8 @@ namespace debug
template<class Type> template<class Type>
Foam::debug::controlSwitches<Type>::controlSwitches() Foam::debug::controlSwitches<Type>::controlSwitches()
: :
switchValue_(Type(0)) switchValue_(Type(0)),
switchDescription_("")
{ {
} }
@ -57,13 +58,15 @@ Foam::debug::controlSwitches<T>::controlSwitches
( (
const std::string& switchName, const std::string& switchName,
const T& switchValue, const T& switchValue,
const std::string& switchDescription,
globalControlDictSwitchSet switchSet, globalControlDictSwitchSet switchSet,
std::map<std::string, std::list<controlSwitches<T> *> >** switchValuesTable std::map<std::string, std::list<controlSwitches<T> *> >** switchValuesTable
) )
: :
switchSet_(switchSet), switchSet_(switchSet),
switchName_(switchName), switchName_(switchName),
switchValue_(switchValue) switchValue_(switchValue),
switchDescription_(switchDescription)
{ {
// Register the switch in its list // Register the switch in its list
if (*switchValuesTable == NULL) if (*switchValuesTable == NULL)
@ -92,7 +95,8 @@ template<class T>
Foam::debug::controlSwitches<T>::controlSwitches(const Foam::debug::controlSwitches<T>& csw) Foam::debug::controlSwitches<T>::controlSwitches(const Foam::debug::controlSwitches<T>& csw)
: :
switchName_(csw.switchName_), switchName_(csw.switchName_),
switchValue_(csw.switchValue_) switchValue_(csw.switchValue_),
switchDescription_(csw.switchDescription_)
{} {}
@ -134,6 +138,7 @@ void Foam::debug::controlSwitches<T>::operator=(const Foam::debug::controlSwitch
else else
{ {
switchValue_ = rhs.switchValue_; switchValue_ = rhs.switchValue_;
switchDescription_ = rhs.switchDescription_;
} }
} }
@ -208,11 +213,32 @@ void printControlSwitches
std::cout << value() << ";"; 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<Foam::debug::controlSwitches<T> *>::iterator itL;
for (itL = swList.begin(); itL != swList.end(); itL++)
{ {
std::cout << " // " << swDescr; Foam::debug::controlSwitches<T>& 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; std::cout << std::endl;
} }

View file

@ -90,12 +90,12 @@ class controlSwitches
//- Switch name //- Switch name
std::string switchName_; std::string switchName_;
//- Switch Description
std::string switchDescription_;
//- Switch value //- Switch value
T switchValue_; T switchValue_;
//- Switch Description
std::string switchDescription_;
//- Handle to runTime switches list //- Handle to runTime switches list
std::map<std::string, std::list<controlSwitches<T> *> >* switchValuesTable_ ; std::map<std::string, std::list<controlSwitches<T> *> >* switchValuesTable_ ;
@ -115,6 +115,7 @@ public:
( (
const std::string& switchName, const std::string& switchName,
const T& switchValue, const T& switchValue,
const std::string& switchDescription,
globalControlDictSwitchSet switchSet, globalControlDictSwitchSet switchSet,
std::map<std::string, std::list<controlSwitches<T> *> >** switchesValues std::map<std::string, std::list<controlSwitches<T> *> >** switchesValues
); );

View file

@ -60,13 +60,15 @@ public:
debugSwitch debugSwitch
( (
const std::string& switchName, const std::string& switchName,
const int& switchValue const int& switchValue,
const std::string& switchDescription = ""
) )
: :
controlSwitches<int> controlSwitches<int>
( (
switchName, switchName,
debug::debugSwitchFromDict(switchName.c_str(), switchValue), debug::debugSwitchFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::DEBUGSWITCHES, debug::DEBUGSWITCHES,
&debugSwitchValues_ &debugSwitchValues_
) )

View file

@ -59,13 +59,15 @@ public:
infoSwitch infoSwitch
( (
const std::string& switchName, const std::string& switchName,
const int& switchValue const int& switchValue,
const std::string& switchDescription = ""
) )
: :
controlSwitches<int> controlSwitches<int>
( (
switchName, switchName,
debug::infoSwitchFromDict(switchName.c_str(), switchValue), debug::infoSwitchFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::INFOSWITCHES, debug::INFOSWITCHES,
&infoSwitchValues_ &infoSwitchValues_
) )

View file

@ -60,13 +60,15 @@ public:
optimisationSwitch optimisationSwitch
( (
const std::string& switchName, const std::string& switchName,
const int& switchValue const int& switchValue,
const std::string& switchDescription = ""
) )
: :
controlSwitches<int> controlSwitches<int>
( (
switchName, switchName,
debug::optimisationSwitchFromDict(switchName.c_str(), switchValue), debug::optimisationSwitchFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::OPTIMISATIONSWITCHES, debug::OPTIMISATIONSWITCHES,
&optimisationSwitchValues_ &optimisationSwitchValues_
) )
@ -77,13 +79,15 @@ public:
optimisationSwitch optimisationSwitch
( (
const std::string& switchName, const std::string& switchName,
const std::string& switchValue const std::string& switchValue,
const std::string& switchDescription = ""
) )
: :
controlSwitches<int> controlSwitches<int>
( (
switchName, switchName,
debug::optimisationSwitchFromDict(switchName, switchValue), debug::optimisationSwitchFromDict(switchName, switchValue),
switchDescription,
debug::OPTIMISATIONSWITCHES, debug::OPTIMISATIONSWITCHES,
&optimisationSwitchValues_ &optimisationSwitchValues_
) )
@ -103,17 +107,6 @@ public:
{ {
return controlSwitches<int>::operator==(rhs); return controlSwitches<int>::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<Pstream::commsTypes>(operator()());
}
#endif
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -60,13 +60,15 @@ public:
tolerancesSwitch tolerancesSwitch
( (
const std::string& switchName, const std::string& switchName,
const Foam::scalar& switchValue const Foam::scalar& switchValue,
const std::string& switchDescription = ""
) )
: :
controlSwitches<Foam::scalar> controlSwitches<Foam::scalar>
( (
switchName, switchName,
debug::tolerancesFromDict(switchName.c_str(), switchValue), debug::tolerancesFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::TOLERANCES, debug::TOLERANCES,
&tolerancesSwitchValues_ &tolerancesSwitchValues_
) )

View file

@ -48,7 +48,8 @@ const Foam::debug::tolerancesSwitch
GGIInterpolation<MasterPatch, SlavePatch>::faceBoundBoxExtendSpanFraction_ GGIInterpolation<MasterPatch, SlavePatch>::faceBoundBoxExtendSpanFraction_
( (
"GGIFaceBoundBoxExtendSpanFraction", "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<class MasterPatch, class SlavePatch> template<class MasterPatch, class SlavePatch>
@ -56,7 +57,8 @@ const Foam::debug::optimisationSwitch
GGIInterpolation<MasterPatch, SlavePatch>::octreeSearchMinNLevel_ GGIInterpolation<MasterPatch, SlavePatch>::octreeSearchMinNLevel_
( (
"GGIOctreeSearchMinNLevel", "GGIOctreeSearchMinNLevel",
3 3,
"GGI neighbouring facets octree-based search: minNlevel parameter for octree"
); );
template<class MasterPatch, class SlavePatch> template<class MasterPatch, class SlavePatch>
@ -64,7 +66,8 @@ const Foam::debug::optimisationSwitch
GGIInterpolation<MasterPatch, SlavePatch>::octreeSearchMaxLeafRatio_ GGIInterpolation<MasterPatch, SlavePatch>::octreeSearchMaxLeafRatio_
( (
"GGIOctreeSearchMaxLeafRatio", "GGIOctreeSearchMaxLeafRatio",
3 3,
"GGI neighbouring facets octree-based search: maxLeafRatio parameter for octree"
); );
template<class MasterPatch, class SlavePatch> template<class MasterPatch, class SlavePatch>
@ -72,7 +75,8 @@ const Foam::debug::optimisationSwitch
GGIInterpolation<MasterPatch, SlavePatch>::octreeSearchMaxShapeRatio_ GGIInterpolation<MasterPatch, SlavePatch>::octreeSearchMaxShapeRatio_
( (
"GGIOctreeSearchMaxShapeRatio", "GGIOctreeSearchMaxShapeRatio",
1 1,
"GGI neighbouring facets octree-based search: maxShapeRatio parameter for octree"
); );

View file

@ -51,7 +51,8 @@ const Foam::debug::tolerancesSwitch
GGIInterpolation<MasterPatch, SlavePatch>::areaErrorTol_ GGIInterpolation<MasterPatch, SlavePatch>::areaErrorTol_
( (
"GGIAreaErrorTol", "GGIAreaErrorTol",
1.0e-8 1.0e-8,
"Minimum GGI face to face intersection area. The smallest accepted GGI weighting factor."
); );
template<class MasterPatch, class SlavePatch> template<class MasterPatch, class SlavePatch>
@ -59,7 +60,8 @@ const Foam::debug::tolerancesSwitch
GGIInterpolation<MasterPatch, SlavePatch>::featureCosTol_ GGIInterpolation<MasterPatch, SlavePatch>::featureCosTol_
( (
"GGIFeatureCosTol", "GGIFeatureCosTol",
0.8 0.8,
"Minimum cosine value between 2 GGI patch neighbouring facet normals."
); );
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View file

@ -43,7 +43,12 @@ Contributor
namespace Foam 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, word);
addToRunTimeSelectionTable(polyPatch, ggiPolyPatch, dictionary); addToRunTimeSelectionTable(polyPatch, ggiPolyPatch, dictionary);

View file

@ -33,7 +33,8 @@ const Foam::debug::constantsSwitch
Foam::radiation::sigmaSB_ Foam::radiation::sigmaSB_
( (
"sigmaSB", "sigmaSB",
5.670E-08 5.670E-08,
"Stefan-Boltzmann constant [J/(K4 m2 s)]"
); );
const Foam::dimensionedScalar Foam::radiation::sigmaSB const Foam::dimensionedScalar Foam::radiation::sigmaSB

View file

@ -37,7 +37,8 @@ const Foam::debug::constantsSwitch
Foam::specie::RR Foam::specie::RR
( (
"R", "R",
8314.51 8314.51,
"Universal gas constant [J/(kmol K)]"
); );
@ -46,7 +47,8 @@ const Foam::debug::constantsSwitch
Foam::specie::Pstd Foam::specie::Pstd
( (
"Pstd", "Pstd",
1.0e5 1.0e5,
"Standard pressure [Pa]"
); );
//- Standard temperature (default in [K]) //- Standard temperature (default in [K])
@ -54,7 +56,8 @@ const Foam::debug::constantsSwitch
Foam::specie::Tstd Foam::specie::Tstd
( (
"Tstd", "Tstd",
298.15 298.15,
"Standard temperature [K]"
); );
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //