STYLE: use auto and cfind to simplify selector usage (issue #512)

This commit is contained in:
Mark Olesen
2017-07-03 10:36:03 +02:00
parent a09815fae2
commit bc1f2fa97e
246 changed files with 1109 additions and 1481 deletions

View File

@ -33,20 +33,19 @@ Foam::autoPtr<Foam::blendingMethod> Foam::blendingMethod::New
const wordList& phaseNames
)
{
word blendingMethodType(dict.lookup("type"));
const word methodName(dict.lookup("type"));
Info<< "Selecting " << dict.dictName() << " blending method: "
<< blendingMethodType << endl;
<< methodName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(blendingMethodType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(methodName);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown blendingMethodType type "
<< blendingMethodType << endl << endl
<< "Valid blendingMethod types are : " << endl
<< "Unknown blendingMethod type "
<< methodName << nl << nl
<< "Valid blendingMethod types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}

View File

@ -51,15 +51,14 @@ Foam::diameterModels::IATEsource::New
const dictionary& dict
)
{
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(type);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(type);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown IATE source type "
<< type << nl << nl
<< "Valid IATE source types : " << endl
<< "Valid IATE source types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}

View File

@ -33,32 +33,28 @@ Foam::autoPtr<Foam::diameterModel> Foam::diameterModel::New
const phaseModel& phase
)
{
word diameterModelType
(
dict.lookup("diameterModel")
);
const word modelType(dict.lookup("diameterModel"));
Info << "Selecting diameterModel for phase "
<< phase.name()
<< ": "
<< diameterModelType << endl;
<< modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(diameterModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown diameterModelType type "
<< diameterModelType << endl << endl
<< "Valid diameterModel types are : " << endl
<< "Unknown diameterModel type "
<< modelType << nl << nl
<< "Valid diameterModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()
(
dict.optionalSubDict(diameterModelType + "Coeffs"),
dict.optionalSubDict(modelType + "Coeffs"),
phase
);
}