Commit bc1f2fa9 authored by Mark Olesen's avatar Mark Olesen
Browse files

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

parent a09815fa
......@@ -40,15 +40,14 @@ Foam::autoPtr<Foam::PDRDragModel> Foam::PDRDragModel::New
Info<< "Selecting flame-wrinkling model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown PDRDragModel type "
<< modelType << nl << nl
<< "Valid PDRDragModels are : " << endl
<< "Valid PDRDragModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -39,15 +39,14 @@ Foam::autoPtr<Foam::XiEqModel> Foam::XiEqModel::New
Info<< "Selecting flame-wrinkling model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown XiEqModel type "
<< modelType << nl << nl
<< "Valid XiEqModels are : " << endl
<< "Valid XiEqModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -39,15 +39,14 @@ Foam::autoPtr<Foam::XiGModel> Foam::XiGModel::New
Info<< "Selecting flame-wrinkling model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown XiGModel type "
<< modelType << nl << nl
<< "Valid XiGModels are : " << endl
<< "Valid XiGModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -42,15 +42,14 @@ Foam::autoPtr<Foam::XiModel> Foam::XiModel::New
Info<< "Selecting flame-wrinkling model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown XiModel type "
<< modelType << nl << nl
<< "Valid XiModels are : " << endl
<< "Valid XiModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -41,15 +41,14 @@ Foam::autoPtr<Foam::mixtureViscosityModel> Foam::mixtureViscosityModel::New
Info<< "Selecting incompressible transport model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown mixtureViscosityModel type "
<< modelType << nl << nl
<< "Valid mixtureViscosityModels are : " << endl
<< "Valid mixtureViscosityModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -104,19 +104,18 @@ Foam::autoPtr<Foam::relativeVelocityModel> Foam::relativeVelocityModel::New
const incompressibleTwoPhaseInteractingMixture& mixture
)
{
word modelType(dict.lookup(typeName));
const word modelType(dict.lookup(typeName));
Info<< "Selecting relative velocity model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown time scale model type " << modelType
<< ", constructor not in hash table" << nl << nl
<< " Valid time scale model types are:" << nl
<< "Unknown time scale model type "
<< modelType << nl << nl
<< "Valid time scale model types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< abort(FatalError);
}
......@@ -141,13 +140,13 @@ Foam::relativeVelocityModel::~relativeVelocityModel()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
tmp<volScalarField> Foam::relativeVelocityModel::rho() const
Foam::tmp<Foam::volScalarField> Foam::relativeVelocityModel::rho() const
{
return alphac_*rhoc_ + alphad_*rhod_;
}
tmp<volSymmTensorField> Foam::relativeVelocityModel::tauDm() const
Foam::tmp<Foam::volSymmTensorField> Foam::relativeVelocityModel::tauDm() const
{
volScalarField betac(alphac_*rhoc_);
volScalarField betad(alphad_*rhod_);
......
......@@ -48,7 +48,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New
)
);
word temperaturePhaseChangeTwoPhaseMixtureTypeName
const word modelType
(
phaseChangePropertiesDict.lookup
(
......@@ -56,19 +56,16 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New
)
);
Info<< "Selecting phaseChange model "
<< temperaturePhaseChangeTwoPhaseMixtureTypeName << endl;
Info<< "Selecting phaseChange model " << modelType << endl;
componentsConstructorTable::iterator cstrIter =
componentsConstructorTablePtr_
->find(temperaturePhaseChangeTwoPhaseMixtureTypeName);
auto cstrIter = componentsConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown temperaturePhaseChangeTwoPhaseMixture type "
<< temperaturePhaseChangeTwoPhaseMixtureTypeName << endl << endl
<< "Valid temperaturePhaseChangeTwoPhaseMixtures are : " << endl
<< modelType << nl << nl
<< "Valid temperaturePhaseChangeTwoPhaseMixture types :" << endl
<< componentsConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -48,24 +48,21 @@ Foam::phaseChangeTwoPhaseMixture::New
)
);
word phaseChangeTwoPhaseMixtureTypeName
const word modelType
(
transportPropertiesDict.lookup("phaseChangeTwoPhaseMixture")
);
Info<< "Selecting phaseChange model "
<< phaseChangeTwoPhaseMixtureTypeName << endl;
Info<< "Selecting phaseChange model " << modelType << endl;
componentsConstructorTable::iterator cstrIter =
componentsConstructorTablePtr_
->find(phaseChangeTwoPhaseMixtureTypeName);
auto cstrIter = componentsConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown phaseChangeTwoPhaseMixture type "
<< phaseChangeTwoPhaseMixtureTypeName << endl << endl
<< "Valid phaseChangeTwoPhaseMixtures are : " << endl
<< modelType << nl << nl
<< "Valid phaseChangeTwoPhaseMixture types :" << endl
<< componentsConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -34,22 +34,21 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
const phaseModel& phase2
)
{
word dragModelType(interfaceDict.lookup("type"));
const word modelType(interfaceDict.lookup("type"));
Info << "Selecting dragModel for phase "
<< phase1.name()
<< ": "
<< dragModelType << endl;
<< modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(dragModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown dragModelType type "
<< dragModelType << endl << endl
<< "Valid dragModel types are : " << endl
<< "Unknown dragModel type "
<< modelType << nl << nl
<< "Valid dragModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -35,7 +35,7 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
const phaseModel& phase2
)
{
word heatTransferModelType
const word modelType
(
interfaceDict.lookup("heatTransferModel" + phase1.name())
);
......@@ -43,17 +43,16 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
Info<< "Selecting heatTransferModel for phase "
<< phase1.name()
<< ": "
<< heatTransferModelType << endl;
<< modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(heatTransferModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown heatTransferModelType type "
<< heatTransferModelType << endl << endl
<< "Valid heatTransferModel types are : " << endl
<< "Unknown heatTransferModel type "
<< modelType << nl << nl
<< "Valid heatTransferModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -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
);
}
......
......@@ -36,7 +36,7 @@ Foam::interfaceCompositionModel::New
const phasePair& pair
)
{
word interfaceCompositionModelType
const word modelType
(
word(dict.lookup("type"))
+ "<"
......@@ -47,17 +47,16 @@ Foam::interfaceCompositionModel::New
);
Info<< "Selecting interfaceCompositionModel for "
<< pair << ": " << interfaceCompositionModelType << endl;
<< pair << ": " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(interfaceCompositionModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown interfaceCompositionModelType type "
<< interfaceCompositionModelType << endl << endl
<< "Valid interfaceCompositionModel types are : " << endl
<< "Unknown interfaceCompositionModel type "
<< modelType << nl << nl
<< "Valid interfaceCompositionModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -34,20 +34,19 @@ Foam::autoPtr<Foam::massTransferModel> Foam::massTransferModel::New
const phasePair& pair
)
{
word massTransferModelType(dict.lookup("type"));
const word modelType(dict.lookup("type"));
Info<< "Selecting massTransferModel for "
<< pair << ": " << massTransferModelType << endl;
<< pair << ": " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(massTransferModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown massTransferModelType type "
<< massTransferModelType << endl << endl
<< "Valid massTransferModel types are : " << endl
<< "Unknown massTransferModel type "
<< modelType << nl << nl
<< "Valid massTransferModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -32,20 +32,18 @@ Foam::autoPtr<Foam::saturationModel> Foam::saturationModel::New
const dictionary& dict
)
{
word saturationModelType(dict.lookup("type"));
const word modelType(dict.lookup("type"));
Info<< "Selecting saturationModel: "
<< saturationModelType << endl;
Info<< "Selecting saturationModel: " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(saturationModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown saturationModelType type "
<< saturationModelType << endl << endl
<< "Valid saturationModel types are : " << endl
<< "Unknown saturationModel type "
<< modelType << nl << nl
<< "Valid saturationModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -35,20 +35,19 @@ Foam::surfaceTensionModel::New
const phasePair& pair
)
{
word surfaceTensionModelType(dict.lookup("type"));
const word modelType(dict.lookup("type"));
Info<< "Selecting surfaceTensionModel for "
<< pair << ": " << surfaceTensionModelType << endl;
<< pair << ": " << modelType << endl;
multiphaseConstructorTable::iterator cstrIter =
multiphaseConstructorTablePtr_->find(surfaceTensionModelType);
auto cstrIter = multiphaseConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown surfaceTensionModelType type "
<< surfaceTensionModelType << endl << endl
<< "Valid surfaceTensionModel types are : " << endl
<< "Unknown surfaceTensionModel type "
<< modelType << nl << nl
<< "Valid surfaceTensionModel types :" << endl
<< multiphaseConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -35,20 +35,19 @@ Foam::aspectRatioModel::New
const phasePair& pair
)
{
word aspectRatioModelType(dict.lookup("type"));
const word modelType(dict.lookup("type"));
Info<< "Selecting aspectRatioModel for "
<< pair << ": " << aspectRatioModelType << endl;
<< pair << ": " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(aspectRatioModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown aspectRatioModelType type "
<< aspectRatioModelType << endl << endl
<< "Valid aspectRatioModel types are : " << endl
<< "Unknown aspectRatioModel type "
<< modelType << nl << nl
<< "Valid aspectRatioModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -34,20 +34,19 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
const phasePair& pair
)
{
word dragModelType(dict.lookup("type"));
const word modelType(dict.lookup("type"));
Info<< "Selecting dragModel for "
<< pair << ": " << dragModelType << endl;
<< pair << ": " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(dragModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown dragModelType type "
<< dragModelType << endl << endl
<< "Valid dragModel types are : " << endl
<< "Unknown dragModel type "
<< modelType << nl << nl
<< "Valid dragModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -34,20 +34,19 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
const phasePair& pair
)
{
word heatTransferModelType(dict.lookup("type"));
const word modelType(dict.lookup("type"));
Info<< "Selecting heatTransferModel for "
<< pair << ": " << heatTransferModelType << endl;
<< pair << ": " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(heatTransferModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown heatTransferModelType type "
<< heatTransferModelType << endl << endl
<< "Valid heatTransferModel types are : " << endl
<< "Unknown heatTransferModel type "
<< modelType << nl << nl
<< "Valid heatTransferModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -34,20 +34,19 @@ Foam::autoPtr<Foam::liftModel> Foam::liftModel::New
const phasePair& pair
)
{
word liftModelType(dict.lookup("type"));
const word modelType(dict.lookup("type"));
Info<< "Selecting liftModel for "
<< pair << ": " << liftModelType << endl;
<< pair << ": " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(liftModelType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown liftModelType type "
<< liftModelType << endl << endl
<< "Valid liftModel types are : " << endl
<< "Unknown liftModel type "
<< modelType << nl << nl
<< "Valid liftModel types :" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
......
......@@ -35,20 +35,19 @@ Foam::swarmCorrection::New
const phasePair& pair
)
{
word swarmCorrectionType(dict.lookup("type"));
const word correctionType(dict.lookup("type"));
Info<< "Selecting swarmCorrection for "