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;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(engineType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(engineType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown engine type "

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,10 +60,9 @@ Foam::edgeInterpolationScheme<Type>::New
const word schemeName(schemeData);
typename MeshConstructorTable::iterator constructorIter =
MeshConstructorTablePtr_->find(schemeName);
auto cstrIter = MeshConstructorTablePtr_->cfind(schemeName);
if (!constructorIter.found())
if (!cstrIter.found())
{
FatalIOErrorInFunction(schemeData)
<< "Unknown discretisation scheme "
@ -73,7 +72,7 @@ Foam::edgeInterpolationScheme<Type>::New
<< exit(FatalIOError);
}
return constructorIter()(mesh, schemeData);
return cstrIter()(mesh, schemeData);
}
@ -105,10 +104,9 @@ Foam::edgeInterpolationScheme<Type>::New
const word schemeName(schemeData);
typename MeshFluxConstructorTable::iterator constructorIter =
MeshFluxConstructorTablePtr_->find(schemeName);
auto cstrIter = MeshFluxConstructorTablePtr_->cfind(schemeName);
if (!constructorIter.found())
if (!cstrIter.found())
{
FatalIOErrorInFunction(schemeData)
<< "Unknown discretisation scheme "
@ -118,7 +116,7 @@ Foam::edgeInterpolationScheme<Type>::New
<< 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();
Map<label>::const_iterator conditionIter = groupMap_.find(groupi);
auto conditionIter = groupMap_.cfind(groupi);
if (conditionIter == groupMap_.end())
if (!conditionIter.found())
{
FatalErrorInFunction
<< "group " << groupi << " not found in map"

View File

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

View File

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