STYLE: use auto + cfind for constructor tables

This commit is contained in:
Mark Olesen
2018-07-19 15:55:08 +02:00
parent cdcbcf4c78
commit 34a7ea5da7
10 changed files with 28 additions and 33 deletions

View File

@ -49,10 +49,9 @@ Foam::autoPtr<Foam::engineTime> Foam::engineTime::New
Info<< "Selecting engine type " << engineType << endl; Info<< "Selecting engine type " << engineType << endl;
dictionaryConstructorTable::iterator cstrIter = auto cstrIter = dictionaryConstructorTablePtr_->cfind(engineType);
dictionaryConstructorTablePtr_->find(engineType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown engine type " << "Unknown engine type "

View File

@ -103,8 +103,8 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::NewCalculatedType
const faPatchField<Type2>& pf const faPatchField<Type2>& pf
) )
{ {
typename patchConstructorTable::iterator patchTypeCstrIter = auto patchTypeCstrIter =
patchConstructorTablePtr_->find(pf.patch().type()); patchConstructorTablePtr_->cfind(pf.patch().type());
if (patchTypeCstrIter.found()) if (patchTypeCstrIter.found())
{ {

View File

@ -83,7 +83,7 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
{ {
if (!disallowGenericFaPatchField) if (!disallowGenericFaPatchField)
{ {
cstrIter = dictionaryConstructorTablePtr_->find("generic"); cstrIter = dictionaryConstructorTablePtr_->cfind("generic");
} }
if (!cstrIter.found()) if (!cstrIter.found())

View File

@ -103,8 +103,8 @@ Foam::faePatchField<Type>::NewCalculatedType
const faePatchField<Type2>& pf const faePatchField<Type2>& pf
) )
{ {
typename patchConstructorTable::iterator patchTypeCstrIter = auto patchTypeCstrIter =
patchConstructorTablePtr_->find(pf.patch().type()); patchConstructorTablePtr_->cfind(pf.patch().type());
if (patchTypeCstrIter.found()) if (patchTypeCstrIter.found())
{ {

View File

@ -83,7 +83,7 @@ Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
{ {
if (!disallowGenericFaePatchField) if (!disallowGenericFaePatchField)
{ {
cstrIter = dictionaryConstructorTablePtr_->find("generic"); cstrIter = dictionaryConstructorTablePtr_->cfind("generic");
} }
if (!cstrIter.found()) if (!cstrIter.found())
@ -136,8 +136,7 @@ Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
<< exit(FatalError); << exit(FatalError);
} }
typename patchMapperConstructorTable::iterator auto patchTypeCstrIter = patchMapperConstructorTablePtr_->cfind(p.type());
patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
if (patchTypeCstrIter.found()) if (patchTypeCstrIter.found())
{ {

View File

@ -68,10 +68,9 @@ tmp<lnGradScheme<Type>> lnGradScheme<Type>::New
const word schemeName(schemeData); const word schemeName(schemeData);
typename MeshConstructorTable::iterator constructorIter = auto cstrIter = MeshConstructorTablePtr_->cfind(schemeName);
MeshConstructorTablePtr_->find(schemeName);
if (!constructorIter.found()) if (!cstrIter.found())
{ {
FatalIOErrorInFunction(schemeData) FatalIOErrorInFunction(schemeData)
<< "Unknown discretisation scheme " << "Unknown discretisation scheme "
@ -81,7 +80,7 @@ tmp<lnGradScheme<Type>> lnGradScheme<Type>::New
<< exit(FatalIOError); << exit(FatalIOError);
} }
return constructorIter()(mesh, schemeData); return cstrIter()(mesh, schemeData);
} }

View File

@ -60,10 +60,9 @@ Foam::edgeInterpolationScheme<Type>::New
const word schemeName(schemeData); const word schemeName(schemeData);
typename MeshConstructorTable::iterator constructorIter = auto cstrIter = MeshConstructorTablePtr_->cfind(schemeName);
MeshConstructorTablePtr_->find(schemeName);
if (!constructorIter.found()) if (!cstrIter.found())
{ {
FatalIOErrorInFunction(schemeData) FatalIOErrorInFunction(schemeData)
<< "Unknown discretisation scheme " << "Unknown discretisation scheme "
@ -73,7 +72,7 @@ Foam::edgeInterpolationScheme<Type>::New
<< exit(FatalIOError); << exit(FatalIOError);
} }
return constructorIter()(mesh, schemeData); return cstrIter()(mesh, schemeData);
} }
@ -105,10 +104,9 @@ Foam::edgeInterpolationScheme<Type>::New
const word schemeName(schemeData); const word schemeName(schemeData);
typename MeshFluxConstructorTable::iterator constructorIter = auto cstrIter = MeshFluxConstructorTablePtr_->cfind(schemeName);
MeshFluxConstructorTablePtr_->find(schemeName);
if (!constructorIter.found()) if (!cstrIter.found())
{ {
FatalIOErrorInFunction(schemeData) FatalIOErrorInFunction(schemeData)
<< "Unknown discretisation scheme " << "Unknown discretisation scheme "
@ -118,7 +116,7 @@ Foam::edgeInterpolationScheme<Type>::New
<< exit(FatalIOError); << exit(FatalIOError);
} }
return constructorIter()(mesh, faceFlux, schemeData); return cstrIter()(mesh, faceFlux, schemeData);
} }

View File

@ -158,9 +158,9 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
label groupi = condition.groupID(); label groupi = condition.groupID();
Map<label>::const_iterator conditionIter = groupMap_.find(groupi); auto conditionIter = groupMap_.cfind(groupi);
if (conditionIter == groupMap_.end()) if (!conditionIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "group " << groupi << " not found in map" << "group " << groupi << " not found in map"

View File

@ -68,11 +68,11 @@ Foam::autoPtr<Foam::cellCellStencil> Foam::cellCellStencil::New
InfoInFunction << "Constructing cellCellStencil" << endl; InfoInFunction << "Constructing cellCellStencil" << endl;
} }
const word stencilType(dict.lookup("method")); const word stencilType(dict.get<word>("method"));
auto cstrIter = meshConstructorTablePtr_->cfind(stencilType); auto cstrIter = meshConstructorTablePtr_->cfind(stencilType);
if (cstrIter == meshConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown cellCellStencil type " << "Unknown cellCellStencil type "

View File

@ -45,14 +45,14 @@ autoPtr<transferModel> transferModel::New
{ {
Info<< " " << modelType << endl; Info<< " " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter = auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown transferModel type " << modelType << "Unknown transferModel type "
<< nl << nl << "Valid transferModel types are:" << nl << modelType << nl << nl
<< "Valid transferModel types are:" << nl
<< dictionaryConstructorTablePtr_->toc() << dictionaryConstructorTablePtr_->toc()
<< exit(FatalError); << exit(FatalError);
} }