Handling of controlSwitches. Modifications for handling commsType which is basically an enum.

This commit is contained in:
Martin Beaudoin 2014-07-09 14:08:02 -04:00
parent b21d148a4f
commit 02e9364872
18 changed files with 431 additions and 127 deletions

View file

@ -173,7 +173,7 @@ void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs()
scalarField nbrIntFld = nbrField.patchInternalField(); scalarField nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), // what to send distMap.subMap(), // what to send
@ -185,7 +185,7 @@ void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs()
scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs();
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), // what to send distMap.subMap(), // what to send

View file

@ -77,7 +77,7 @@ void directMappedFixedValueFvPatchField<Type>::mapField()
} }
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), distMap.subMap(),
@ -112,7 +112,7 @@ void directMappedFixedValueFvPatchField<Type>::mapField()
newValues_ = nbrField.boundaryField()[nbrPatchID]; newValues_ = nbrField.boundaryField()[nbrPatchID];
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), distMap.subMap(),
@ -144,7 +144,7 @@ void directMappedFixedValueFvPatchField<Type>::mapField()
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), distMap.subMap(),

View file

@ -198,7 +198,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), distMap.subMap(),
@ -209,7 +209,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), distMap.subMap(),
@ -231,7 +231,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), distMap.subMap(),
@ -243,7 +243,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), distMap.subMap(),

View file

@ -120,6 +120,13 @@ public:
return names[e]; return names[e];
} }
//- Return the name of the given enumeration element
// where e is specified as a int
const char* operator[](const int e) const
{
return names[e];
}
// Friend operators // Friend operators

View file

@ -244,9 +244,16 @@ Foam::Pstream::nProcsSimpleSum
); );
// Default commsType // Default commsType
Foam::Pstream::commsTypes Foam::Pstream::defaultCommsType Foam::Pstream::commsTypes Foam::Pstream::defaultCommsType_
( (
commsTypeNames.read(debug::optimisationSwitches().lookup("commsType")) commsTypeNames.read(debug::optimisationSwitches().lookup("commsType"))
); );
const Foam::debug::optimisationSwitch
Foam::Pstream::defaultCommsType
(
"commsType",
"blocking"
);
// ************************************************************************* // // ************************************************************************* //

View file

@ -232,8 +232,9 @@ public:
static const Foam::debug::optimisationSwitch nProcsSimpleSum; static const Foam::debug::optimisationSwitch nProcsSimpleSum;
//- Default commsType //- Default commsType
static commsTypes defaultCommsType; static commsTypes defaultCommsType_;
static const Foam::debug::optimisationSwitch defaultCommsType;
// Constructors // Constructors

View file

@ -293,7 +293,10 @@ evaluate()
{ {
forAll(*this, patchi) forAll(*this, patchi)
{ {
this->operator[](patchi).initEvaluate(Pstream::defaultCommsType); this->operator[](patchi).initEvaluate
(
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
);
} }
// Block for any outstanding requests // Block for any outstanding requests
@ -305,7 +308,10 @@ evaluate()
forAll(*this, patchi) forAll(*this, patchi)
{ {
this->operator[](patchi).evaluate(Pstream::defaultCommsType); this->operator[](patchi).evaluate
(
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
);
} }
} }
else if (Pstream::defaultCommsType == Pstream::scheduled) else if (Pstream::defaultCommsType == Pstream::scheduled)
@ -331,7 +337,7 @@ evaluate()
{ {
FatalErrorIn("GeometricBoundaryField::evaluate()") FatalErrorIn("GeometricBoundaryField::evaluate()")
<< "Unsuported communications type " << "Unsuported communications type "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType()]
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -360,7 +366,7 @@ evaluateCoupled()
{ {
this->operator[](patchi).initEvaluate this->operator[](patchi).initEvaluate
( (
Pstream::defaultCommsType static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
); );
} }
} }
@ -376,7 +382,10 @@ evaluateCoupled()
{ {
if (this->operator[](patchi).coupled()) if (this->operator[](patchi).coupled())
{ {
this->operator[](patchi).evaluate(Pstream::defaultCommsType); this->operator[](patchi).evaluate
(
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
);
} }
} }
} }
@ -415,7 +424,7 @@ evaluateCoupled()
{ {
FatalErrorIn("GeometricBoundaryField::evaluateCoupled()") FatalErrorIn("GeometricBoundaryField::evaluateCoupled()")
<< "Unsuported communications type " << "Unsuported communications type "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType()]
<< exit(FatalError); << exit(FatalError);
} }
} }

View file

@ -586,7 +586,7 @@ Foam::argList::argList
<< " floatTransfer : " << Pstream::floatTransfer << nl << " floatTransfer : " << Pstream::floatTransfer << nl
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum() << nl << " nProcsSimpleSum : " << Pstream::nProcsSimpleSum() << nl
<< " commsType : " << " commsType : "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType()]
<< endl; << endl;
} }
} }

View file

@ -90,6 +90,9 @@ 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_;
@ -145,7 +148,7 @@ public:
const T operator&(const T&); const T operator&(const T&);
// == operator // == operator
bool operator==(const T&); bool operator==(const T&) const;
// >= operator // >= operator
bool operator>=(const T&); bool operator>=(const T&);
@ -161,6 +164,17 @@ public:
{ {
return switchValue_; return switchValue_;
} }
// Return switch name
std::string switchName()
{
return switchName_;
}
// Return switch description
std::string switchDescription()
{
return switchDescription_;
}
}; };

View file

@ -25,9 +25,6 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T> template<class T>
@ -43,7 +40,7 @@ inline const T Foam::debug::controlSwitches<T>::operator&(const T& rhs)
} }
template<class T> template<class T>
inline bool Foam::debug::controlSwitches<T>::operator==(const T& rhs) inline bool Foam::debug::controlSwitches<T>::operator==(const T& rhs) const
{ {
return switchValue_ == rhs; return switchValue_ == rhs;
} }
@ -66,13 +63,6 @@ inline bool Foam::debug::controlSwitches<T>::operator<(const T& rhs)
return switchValue_ < rhs; return switchValue_ < rhs;
} }
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -72,6 +72,23 @@ public:
) )
{} {}
// This constructor is essentially for 'commsType'
optimisationSwitch
(
const std::string& switchName,
const std::string& switchValue
)
:
controlSwitches<int>
(
switchName,
debug::optimisationSwitchFromDict(switchName, switchValue),
debug::OPTIMISATIONSWITCHES,
&optimisationSwitchValues_
)
{}
virtual ~optimisationSwitch() virtual ~optimisationSwitch()
{ {
} }
@ -82,6 +99,20 @@ public:
controlSwitches<int>::operator=(rhs); controlSwitches<int>::operator=(rhs);
} }
bool operator==(const int& rhs) const
{
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

@ -192,7 +192,11 @@ int Foam::debug::infoSwitchFromDict(const char* name, const int defaultValue)
} }
int Foam::debug::optimisationSwitchFromDict(const char* name, const int defaultValue) int Foam::debug::optimisationSwitchFromDict
(
const char* name,
const int defaultValue
)
{ {
return optimisationSwitches().lookupOrAddDefault return optimisationSwitches().lookupOrAddDefault
( (
@ -201,7 +205,38 @@ int Foam::debug::optimisationSwitchFromDict(const char* name, const int defaultV
} }
double Foam::debug::tolerancesFromDict(const char* name, const double defaultValue) // This is essentially for reading 'commsType'
int Foam::debug::optimisationSwitchFromDict
(
const Foam::string name,
const Foam::word defaultValueStr
)
{
int retValue = 0;
if (name == "commsType")
{
Foam::string valueStr = optimisationSwitches().lookupOrAddDefault
(
name, defaultValueStr, false, false
);
retValue = Pstream::commsTypeNames[valueStr];
}
else
{
// Need a warning here...
}
return retValue;
}
double Foam::debug::tolerancesFromDict
(
const char* name,
const double defaultValue
)
{ {
return tolerances().lookupOrAddDefault return tolerances().lookupOrAddDefault
( (
@ -209,7 +244,11 @@ double Foam::debug::tolerancesFromDict(const char* name, const double defaultVal
); );
} }
double Foam::debug::constantsFromDict(const char* name, const double defaultValue) double Foam::debug::constantsFromDict
(
const char* name,
const double defaultValue
)
{ {
return tolerances().lookupOrAddDefault return tolerances().lookupOrAddDefault
( (
@ -217,7 +256,11 @@ double Foam::debug::constantsFromDict(const char* name, const double defaultValu
); );
} }
void Foam::debug::updateCentralDictVars(Foam::debug::globalControlDictSwitchSet globalControlDictSwitchSetName, Foam::string keyValues) void Foam::debug::updateCentralDictVars
(
Foam::debug::globalControlDictSwitchSet globalControlDictSwitchSetName,
Foam::string keyValues
)
{ {
Foam::word token; Foam::word token;
@ -241,50 +284,82 @@ void Foam::debug::updateCentralDictVars(Foam::debug::globalControlDictSwitchSet
{ {
if (debugSwitchValues_) if (debugSwitchValues_)
{ {
ListDebugControlSwitches& runTimeDebugSwitchValues = *debugSwitchValues_; ListDebugControlSwitches& debugSwitchValues =
*debugSwitchValues_;
label oldDebugValue; label oldDebugValue;
label newDebugValue; label newDebugValue;
isskv >> newDebugValue; isskv >> newDebugValue;
if(Foam::debug::debugSwitches().readIfPresent(key, oldDebugValue)) if (Foam::debug::debugSwitches().readIfPresent
(
key,
oldDebugValue
)
)
{ {
Info << endl Info << endl
<< "Warning: Modification of DebugSwitch: " << key << endl << "Warning: Modification of DebugSwitch: "
<< key << endl
<< " Old value: " << oldDebugValue << endl << " Old value: " << oldDebugValue << endl
<< " New value: " << newDebugValue << endl << " New value: " << newDebugValue << endl
<< endl; << endl;
Foam::debug::debugSwitches().set(key, newDebugValue); Foam::debug::debugSwitches().set
(
key,
newDebugValue
);
std::list<controlSwitches<int> *> curList = runTimeDebugSwitchValues[key]; std::list<controlSwitches<int> *> curList =
debugSwitchValues[key];
// Modify all entries for this key // Modify all entries for this key
forAllIter(std::list<controlSwitches<int> *>, curList, iterI) forAllIter
(
std::list<controlSwitches<int> *>,
curList,
iterI
)
{
*(*iterI) = newDebugValue; *(*iterI) = newDebugValue;
}
} }
else else
{ {
// Usage of non-existent DebugSwitches: best to abort right away // Usage of non-existent DebugSwitches: best to
SortableList<Foam::word> sortedValidKeys(runTimeDebugSwitchValues.size()); // abort right away
SortableList<Foam::word> sortedValidKeys
(
debugSwitchValues.size()
);
int i=0; int i=0;
forAllIter(ListDebugControlSwitches, runTimeDebugSwitchValues, iterI) forAllIter
(
ListDebugControlSwitches,
debugSwitchValues,
iterI
)
{ {
sortedValidKeys[i++] = iterI->first; sortedValidKeys[i++] = iterI->first;
} }
sortedValidKeys.sort(); sortedValidKeys.sort();
FatalError FatalError
<< "Usage of non-existent DebugSwitches: " << key << "Usage of non-existent DebugSwitches name: "
<< key
<< endl << endl << endl << endl
<< "Valid entries for this application are: " << sortedValidKeys << "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError); << exit(FatalError);
} }
} }
else else
{ {
FatalError FatalError
<< "No DebugSwitches values are available for this application." << "No DebugSwitches values are available for "
<< "this application."
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -293,50 +368,78 @@ void Foam::debug::updateCentralDictVars(Foam::debug::globalControlDictSwitchSet
{ {
if (infoSwitchValues_) if (infoSwitchValues_)
{ {
ListInfoControlSwitches& runTimeInfoSwitchValues = *infoSwitchValues_; ListInfoControlSwitches& infoSwitchValues =
*infoSwitchValues_;
label oldInfoValue; label oldInfoValue;
label newInfoValue; label newInfoValue;
isskv >> newInfoValue; isskv >> newInfoValue;
if(Foam::debug::infoSwitches().readIfPresent(key, oldInfoValue)) if (Foam::debug::infoSwitches().readIfPresent
(
key,
oldInfoValue
)
)
{ {
Info << endl Info << endl
<< "Warning: Modification of InfoSwitch: " << key << endl << "Warning: Modification of InfoSwitch: "
<< key << endl
<< " Old value: " << oldInfoValue << endl << " Old value: " << oldInfoValue << endl
<< " New value: " << newInfoValue << endl << " New value: " << newInfoValue << endl
<< endl; << endl;
Foam::debug::infoSwitches().set(key, newInfoValue); Foam::debug::infoSwitches().set(key, newInfoValue);
std::list<controlSwitches<int> *> curList = runTimeInfoSwitchValues[key]; std::list<controlSwitches<int> *> curList =
infoSwitchValues[key];
// Modify all entries for this key // Modify all entries for this key
forAllIter(std::list<controlSwitches<int> *>, curList, iterI) forAllIter
(
std::list<controlSwitches<int> *>,
curList,
iterI
)
{
*(*iterI) = newInfoValue; *(*iterI) = newInfoValue;
}
} }
else else
{ {
// Usage of non-existent InfoSwitches: best to abort right away // Usage of non-existent InfoSwitches: best to
SortableList<Foam::word> sortedValidKeys(runTimeInfoSwitchValues.size()); // abort right away
SortableList<Foam::word> sortedValidKeys
(
infoSwitchValues.size()
);
int i=0; int i=0;
forAllIter(ListInfoControlSwitches, runTimeInfoSwitchValues, iterI) forAllIter
(
ListInfoControlSwitches,
infoSwitchValues,
iterI
)
{ {
sortedValidKeys[i++] = iterI->first; sortedValidKeys[i++] = iterI->first;
} }
sortedValidKeys.sort(); sortedValidKeys.sort();
FatalError FatalError
<< "Usage of non-existent InfoSwitches: " << key << "Usage of non-existent InfoSwitches name: "
<< key
<< endl << endl << endl << endl
<< "Valid entries for this application are: " << sortedValidKeys << "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError); << exit(FatalError);
} }
} }
else else
{ {
FatalError FatalError
<< "No InfoSwitches values are available for this application." << "No InfoSwitches values are available for "
<< "this application."
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -345,50 +448,122 @@ void Foam::debug::updateCentralDictVars(Foam::debug::globalControlDictSwitchSet
{ {
if (optimisationSwitchValues_) if (optimisationSwitchValues_)
{ {
ListOptimisationControlSwitches& runTimeOptimisationSwitchValues = *optimisationSwitchValues_; ListOptimisationControlSwitches&
label oldOptimisationValue; optimisationSwitchValues = *optimisationSwitchValues_;
label newOptimisationValue;
isskv >> newOptimisationValue;
if(Foam::debug::optimisationSwitches().readIfPresent(key, oldOptimisationValue)) label newOptimisationValue;
label oldOptimisationValue;
word newOptimisationValueStr;
word oldOptimisationValueStr;
bool keyIsPresent(false);
// We need to check if the switch 'commsType' is being
// overriden. This switch is coded as an enum, but will
// be specified using a string like "blocking",
// "scheduled, etc. Some additional logic is needed.
if (key == "commsType")
{
// Handle a string value, then convert to enum
isskv >> newOptimisationValueStr;
newOptimisationValue =
Pstream::commsTypeNames[newOptimisationValueStr];
keyIsPresent =
Foam::debug::optimisationSwitches().readIfPresent
(
key,
oldOptimisationValueStr
);
}
else
{
// Handling label values
isskv >> newOptimisationValue;
keyIsPresent =
Foam::debug::optimisationSwitches().readIfPresent
(
key,
oldOptimisationValue
);
std::ostringstream newOptimisationValueOstream;
newOptimisationValueOstream << newOptimisationValue;
newOptimisationValueStr =
newOptimisationValueOstream.str();
std::ostringstream oldOptimisationValueOstream;
oldOptimisationValueOstream << oldOptimisationValue;
oldOptimisationValueStr =
oldOptimisationValueOstream.str();
}
if(keyIsPresent)
{ {
Info << endl Info << endl
<< "Warning: Modification of OptimisationSwitch value: " << key << endl << "Warning: Modification of "
<< " Old value: " << oldOptimisationValue << endl << "OptimisationSwitch: "
<< " New value: " << newOptimisationValue << endl << key << endl
<< " Old value: "
<< oldOptimisationValueStr << endl
<< " New value: "
<< newOptimisationValueStr << endl
<< endl; << endl;
Foam::debug::optimisationSwitches().set(key, newOptimisationValue); Foam::debug::optimisationSwitches().set
(
key,
newOptimisationValue
);
std::list<controlSwitches<int> *> curList = runTimeOptimisationSwitchValues[key]; std::list<controlSwitches<int> *> curList =
optimisationSwitchValues[key];
std::cout << "curList.size(): " << curList.size() << std::endl;
// Modify all entries for this key // Modify all entries for this key
forAllIter(std::list<controlSwitches<int> *>, curList, iterI) forAllIter
(
std::list<controlSwitches<int> *>,
curList,
iterI
)
{
*(*iterI) = newOptimisationValue; *(*iterI) = newOptimisationValue;
}
} }
else else
{ {
// Usage of non-existent OptimisationSwitches: best to abort right away // Usage of non-existent OptimisationSwitches: best to
SortableList<Foam::word> sortedValidKeys(runTimeOptimisationSwitchValues.size()); // abort right away
SortableList<Foam::word> sortedValidKeys
(
optimisationSwitchValues.size()
);
int i=0; int i=0;
forAllIter(ListOptimisationControlSwitches, runTimeOptimisationSwitchValues, iterI) forAllIter
(
ListOptimisationControlSwitches,
optimisationSwitchValues,
iterI
)
{ {
sortedValidKeys[i++] = iterI->first; sortedValidKeys[i++] = iterI->first;
} }
sortedValidKeys.sort(); sortedValidKeys.sort();
FatalError FatalError
<< "Usage of non-existent OptimisationSwitches value: " << key << "Usage of non-existent "
<< " OptimisationSwitches name: " << key
<< endl << endl << endl << endl
<< "Valid entries for this application are: " << sortedValidKeys << "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError); << exit(FatalError);
} }
} }
else else
{ {
FatalError FatalError
<< "No OptimisationSwitches values are available for this application." << "No OptimisationSwitches values are available "
<< "for this application."
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -397,50 +572,84 @@ void Foam::debug::updateCentralDictVars(Foam::debug::globalControlDictSwitchSet
{ {
if (tolerancesSwitchValues_) if (tolerancesSwitchValues_)
{ {
ListTolerancesControlSwitches& runTimeTolerancesSwitchValues = *tolerancesSwitchValues_; ListTolerancesControlSwitches& tolerancesSwitchValues =
*tolerancesSwitchValues_;
scalar oldTolerancesValue; scalar oldTolerancesValue;
scalar newTolerancesValue; scalar newTolerancesValue;
isskv >> newTolerancesValue; isskv >> newTolerancesValue;
if(Foam::debug::tolerances().readIfPresent(key, oldTolerancesValue)) if (Foam::debug::tolerances().readIfPresent
(
key,
oldTolerancesValue
)
)
{ {
Info << endl Info << endl
<< "Warning: Modification of Tolerance value: " << key << endl << "Warning: Modification of Tolerance: "
<< " Old value: " << oldTolerancesValue << endl << key << endl
<< " New value: " << newTolerancesValue << endl << " Old value: "
<< oldTolerancesValue << endl
<< " New value: "
<< newTolerancesValue << endl
<< endl; << endl;
Foam::debug::tolerances().set(key, newTolerancesValue); Foam::debug::tolerances().set
(
key,
newTolerancesValue
);
std::list<controlSwitches<scalar> *> curList = runTimeTolerancesSwitchValues[key]; std::list<controlSwitches<scalar> *> curList =
tolerancesSwitchValues[key];
// Modify all entries for this key // Modify all entries for this key
forAllIter(std::list<controlSwitches<scalar> *>, curList, iterI) forAllIter
(
std::list<controlSwitches<scalar> *>,
curList,
iterI
)
{
*(*iterI) = newTolerancesValue; *(*iterI) = newTolerancesValue;
}
} }
else else
{ {
// Usage of non-existent Tolerances: best to abort right away // Usage of non-existent Tolerances: best to
SortableList<Foam::word> sortedValidKeys(runTimeTolerancesSwitchValues.size()); // abort right away
SortableList<Foam::word> sortedValidKeys
(
tolerancesSwitchValues.size()
);
int i=0; int i=0;
forAllIter(ListTolerancesControlSwitches, runTimeTolerancesSwitchValues, iterI) forAllIter
{ (
sortedValidKeys[i++] = iterI->first; ListTolerancesControlSwitches,
} tolerancesSwitchValues,
iterI
)
{
sortedValidKeys[i++] = iterI->first;
}
sortedValidKeys.sort(); sortedValidKeys.sort();
FatalError FatalError
<< "Usage of non-existent Tolerances value: " << key << "Usage of non-existent Tolerances name: "
<< key
<< endl << endl << endl << endl
<< "Valid entries for this application are: " << sortedValidKeys << "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError); << exit(FatalError);
} }
} }
else else
{ {
FatalError FatalError
<< "No Tolerances values are available for this application." << "No Tolerances values are available for "
<< "this application."
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -449,50 +658,85 @@ void Foam::debug::updateCentralDictVars(Foam::debug::globalControlDictSwitchSet
{ {
if (constantsSwitchValues_) if (constantsSwitchValues_)
{ {
ListConstantsControlSwitches& runTimeConstantsSwitchValues = *constantsSwitchValues_; ListConstantsControlSwitches& constantsSwitchValues =
*constantsSwitchValues_;
scalar oldDimensionedConstantsValue; scalar oldDimensionedConstantsValue;
scalar newDimensionedConstantsValue; scalar newDimensionedConstantsValue;
isskv >> newDimensionedConstantsValue; isskv >> newDimensionedConstantsValue;
if(Foam::dimensionedConstants().readIfPresent(key, oldDimensionedConstantsValue)) if (Foam::dimensionedConstants().readIfPresent
(
key,
oldDimensionedConstantsValue
)
)
{ {
Info << endl Info << endl
<< "Warning: Modification of DimensionedConstant: " << key << endl << "Warning: Modification of DimensionedConstant: "
<< " Old value: " << oldDimensionedConstantsValue << endl << key << endl
<< " New value: " << newDimensionedConstantsValue << endl << " Old value: "
<< oldDimensionedConstantsValue << endl
<< " New value: "
<< newDimensionedConstantsValue << endl
<< endl; << endl;
Foam::dimensionedConstants().set(key, newDimensionedConstantsValue); Foam::dimensionedConstants().set
(
key,
newDimensionedConstantsValue
);
std::list<controlSwitches<scalar> *> curList = runTimeConstantsSwitchValues[key]; std::list<controlSwitches<scalar> *> curList =
constantsSwitchValues[key];
// Modify all entries for this key // Modify all entries for this key
forAllIter(std::list<controlSwitches<scalar> *>, curList, iterI) forAllIter
(
std::list<controlSwitches<scalar> *>,
curList,
iterI
)
{
*(*iterI) = newDimensionedConstantsValue; *(*iterI) = newDimensionedConstantsValue;
}
} }
else else
{ {
// Usage of non-existent DimensionedConstants: best to abort right away // Usage of non-existent DimensionedConstants: best to
SortableList<Foam::word> sortedValidKeys(runTimeConstantsSwitchValues.size()); // abort right away
SortableList<Foam::word> sortedValidKeys
(
constantsSwitchValues.size()
);
int i=0; int i=0;
forAllIter(ListConstantsControlSwitches, runTimeConstantsSwitchValues, iterI) forAllIter
(
ListConstantsControlSwitches,
constantsSwitchValues,
iterI
)
{ {
sortedValidKeys[i++] = iterI->first; sortedValidKeys[i++] = iterI->first;
} }
sortedValidKeys.sort(); sortedValidKeys.sort();
FatalError FatalError
<< "Usage of non-existent DimensionedConstants: " << key << "Usage of non-existent "
<< "DimensionedConstants name: "
<< key
<< endl << endl << endl << endl
<< "Valid entries for this application are: " << sortedValidKeys << "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError); << exit(FatalError);
} }
} }
else else
{ {
FatalError FatalError
<< "No DimensionedConstants values are available for this application." << "No DimensionedConstants values are available "
<< "for this application."
<< exit(FatalError); << exit(FatalError);
} }
} }

View file

@ -85,6 +85,7 @@ namespace debug
//- Lookup optimisation switch or add default value. //- Lookup optimisation switch or add default value.
int optimisationSwitchFromDict(const char* name, const int defaultValue = 0); int optimisationSwitchFromDict(const char* name, const int defaultValue = 0);
int optimisationSwitchFromDict(const Foam::string name, const Foam::word defaultValue);
//- Lookup tolerances switch or add default value. //- Lookup tolerances switch or add default value.
double tolerancesFromDict(const char* name, const double defaultValue = 0); double tolerancesFromDict(const char* name, const double defaultValue = 0);

View file

@ -55,7 +55,7 @@ void Foam::BlockLduMatrix<Type>::initInterfaces
result, result,
*this, *this,
interfaceCoeffs[interfaceI], interfaceCoeffs[interfaceI],
Pstream::defaultCommsType, static_cast<const Pstream::commsTypes>(Pstream::defaultCommsType()),
switchToLhs switchToLhs
); );
} }
@ -92,7 +92,7 @@ void Foam::BlockLduMatrix<Type>::initInterfaces
{ {
FatalErrorIn("BlockLduMatrix<Type>::initMatrixInterfaces") FatalErrorIn("BlockLduMatrix<Type>::initMatrixInterfaces")
<< "Unsuported communications type " << "Unsuported communications type "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType()]
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -130,7 +130,7 @@ void Foam::BlockLduMatrix<Type>::updateInterfaces
result, result,
*this, *this,
interfaceCoeffs[interfaceI], interfaceCoeffs[interfaceI],
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
switchToLhs switchToLhs
); );
} }
@ -201,7 +201,7 @@ void Foam::BlockLduMatrix<Type>::updateInterfaces
{ {
FatalErrorIn("BlockLduMatrix<Type>::updateInterfaces") FatalErrorIn("BlockLduMatrix<Type>::updateInterfaces")
<< "Unsuported communications type " << "Unsuported communications type "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType()]
<< exit(FatalError); << exit(FatalError);
} }
} }

View file

@ -39,8 +39,8 @@ void Foam::lduMatrix::initMatrixInterfaces
{ {
if if
( (
Pstream::defaultCommsType == Pstream::blocking Pstream::defaultCommsType() == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking || Pstream::defaultCommsType() == Pstream::nonBlocking
) )
{ {
forAll (interfaces, interfaceI) forAll (interfaces, interfaceI)
@ -54,13 +54,13 @@ void Foam::lduMatrix::initMatrixInterfaces
*this, *this,
coupleCoeffs[interfaceI], coupleCoeffs[interfaceI],
cmpt, cmpt,
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
switchToLhs switchToLhs
); );
} }
} }
} }
else if (Pstream::defaultCommsType == Pstream::scheduled) else if (Pstream::defaultCommsType() == Pstream::scheduled)
{ {
const lduSchedule& patchSchedule = this->patchSchedule(); const lduSchedule& patchSchedule = this->patchSchedule();
@ -92,7 +92,7 @@ void Foam::lduMatrix::initMatrixInterfaces
{ {
FatalErrorIn("lduMatrix::initMatrixInterfaces") FatalErrorIn("lduMatrix::initMatrixInterfaces")
<< "Unsuported communications type " << "Unsuported communications type "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType()]
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -110,12 +110,12 @@ void Foam::lduMatrix::updateMatrixInterfaces
{ {
if if
( (
Pstream::defaultCommsType == Pstream::blocking Pstream::defaultCommsType() == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking || Pstream::defaultCommsType() == Pstream::nonBlocking
) )
{ {
// Block until all sends/receives have been finished // Block until all sends/receives have been finished
if (Pstream::defaultCommsType == Pstream::nonBlocking) if (Pstream::defaultCommsType() == Pstream::nonBlocking)
{ {
IPstream::waitRequests(); IPstream::waitRequests();
OPstream::waitRequests(); OPstream::waitRequests();
@ -132,13 +132,13 @@ void Foam::lduMatrix::updateMatrixInterfaces
*this, *this,
coupleCoeffs[interfaceI], coupleCoeffs[interfaceI],
cmpt, cmpt,
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
switchToLhs switchToLhs
); );
} }
} }
} }
else if (Pstream::defaultCommsType == Pstream::scheduled) else if (Pstream::defaultCommsType() == Pstream::scheduled)
{ {
const lduSchedule& patchSchedule = this->patchSchedule(); const lduSchedule& patchSchedule = this->patchSchedule();
@ -206,7 +206,7 @@ void Foam::lduMatrix::updateMatrixInterfaces
{ {
FatalErrorIn("lduMatrix::updateMatrixInterfaces") FatalErrorIn("lduMatrix::updateMatrixInterfaces")
<< "Unsuported communications type " << "Unsuported communications type "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType()]
<< exit(FatalError); << exit(FatalError);
} }
} }

View file

@ -127,7 +127,7 @@ void tetFemMatrix<Type>::check()
*this, *this,
coupledBouCoeffs[interfaceI], coupledBouCoeffs[interfaceI],
0, 0,
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
false // Do not switch to lhs false // Do not switch to lhs
); );
} }
@ -145,7 +145,7 @@ void tetFemMatrix<Type>::check()
*this, *this,
coupledBouCoeffs[interfaceI], coupledBouCoeffs[interfaceI],
0, 0,
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
false // Do not switch to lhs false // Do not switch to lhs
); );
} }

View file

@ -274,7 +274,7 @@ void Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs()
scalarField nbrIntFld = nbrField.patchInternalField(); scalarField nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), // what to send distMap.subMap(), // what to send
@ -286,7 +286,7 @@ void Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs()
scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs();
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), // what to send distMap.subMap(), // what to send
@ -307,7 +307,7 @@ void Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs()
// Distribute back and assign to neighbour // Distribute back and assign to neighbour
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
nbrField.size(), nbrField.size(),
distMap.constructMap(), // reverse : what to send distMap.constructMap(), // reverse : what to send

View file

@ -233,7 +233,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
scalarField nbrIntFld = nbrField.patchInternalField(); scalarField nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), // what to send distMap.subMap(), // what to send
@ -245,7 +245,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs();
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::defaultCommsType, static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
distMap.schedule(), distMap.schedule(),
distMap.constructSize(), distMap.constructSize(),
distMap.subMap(), // what to send distMap.subMap(), // what to send