mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: for-range, forAllIters() ... in thermophysicalModels/
- reduced clutter when iterating over containers
This commit is contained in:
committed by
Andrew Heather
parent
5f42b5df9f
commit
6cbe89720d
@ -269,7 +269,7 @@ Foam::autoPtr<Thermo> Foam::basicThermo::New
|
||||
)
|
||||
);
|
||||
|
||||
typename Thermo::fvMeshDictPhaseConstructorTable::iterator cstrIter =
|
||||
auto cstrIter =
|
||||
lookupThermo<Thermo, typename Thermo::fvMeshDictPhaseConstructorTable>
|
||||
(
|
||||
thermoDict,
|
||||
|
||||
@ -142,14 +142,13 @@ void Foam::chemistryTabulationMethods::ISAT<CompType, ThermoType>::addToMRU
|
||||
{
|
||||
if (maxMRUSize_ > 0 && MRURetrieve_)
|
||||
{
|
||||
typename SLList<chemPointISAT<CompType, ThermoType>*>::iterator iter =
|
||||
MRUList_.begin();
|
||||
auto iter = MRUList_.begin();
|
||||
|
||||
// First search if the chemPoint is already in the list
|
||||
bool isInList = false;
|
||||
for ( ; iter != MRUList_.end(); ++iter)
|
||||
for (; iter.good(); ++iter)
|
||||
{
|
||||
if (iter() == phi0)
|
||||
if (*iter == phi0)
|
||||
{
|
||||
isInList = true;
|
||||
break;
|
||||
@ -161,10 +160,7 @@ void Foam::chemistryTabulationMethods::ISAT<CompType, ThermoType>::addToMRU
|
||||
// If it is in the list, then move it to front
|
||||
if (iter != MRUList_.begin())
|
||||
{
|
||||
// iter hold the position of the element to move
|
||||
MRUList_.remove(iter);
|
||||
|
||||
// Insert the element in front of the list
|
||||
MRUList_.insert(phi0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,12 +134,6 @@ greyMeanSolidAbsorptionEmission
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::radiation::greyMeanSolidAbsorptionEmission::
|
||||
~greyMeanSolidAbsorptionEmission()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -167,7 +161,7 @@ calc(const label propertyId) const
|
||||
|
||||
scalarField& a = ta.ref().primitiveFieldRef();
|
||||
|
||||
forAllConstIter(HashTable<label>, speciesNames_, iter)
|
||||
forAllConstIters(speciesNames_, iter)
|
||||
{
|
||||
if (mixture_.contains(iter.key()))
|
||||
{
|
||||
|
||||
@ -2,10 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -61,7 +59,6 @@ class greyMeanSolidAbsorptionEmission
|
||||
:
|
||||
public absorptionEmissionModel
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
@ -115,21 +112,14 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~greyMeanSolidAbsorptionEmission();
|
||||
virtual ~greyMeanSolidAbsorptionEmission() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
// Absorption coefficient
|
||||
|
||||
//- Absorption coefficient for continuous phase
|
||||
tmp<volScalarField> aCont(const label bandI = 0) const;
|
||||
|
||||
|
||||
// Emission coefficient
|
||||
|
||||
//- Emission coefficient for continuous phase
|
||||
tmp<volScalarField> eCont(const label bandI = 0) const;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -425,12 +425,12 @@ bool finishReaction = false;
|
||||
if (newFormat_)
|
||||
{
|
||||
specieString.replaceAll(" ", "_");
|
||||
size_t strEnd = specieString.find_last_not_of('_');
|
||||
const auto strEnd = specieString.find_last_not_of('_');
|
||||
currentSpecieName = specieString.substr(0, strEnd + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t spacePos = specieString.find(' ');
|
||||
const auto spacePos = specieString.find(' ');
|
||||
if (spacePos != string::npos)
|
||||
{
|
||||
currentSpecieName = specieString.substr(0, spacePos);
|
||||
@ -459,13 +459,12 @@ bool finishReaction = false;
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
word elementName = word::validate(thermoFormula.substr(5*i, 2));
|
||||
label nAtoms = atoi(thermoFormula.substr(5*i + 2, 3).c_str());
|
||||
const int nAtoms = atoi(thermoFormula.substr(5*i + 2, 3).c_str());
|
||||
|
||||
if (elementName.size() && nAtoms)
|
||||
{
|
||||
correctElementName(elementName);
|
||||
currentSpecieComposition[nSpecieElements].name() =
|
||||
elementName;
|
||||
currentSpecieComposition[nSpecieElements].name() = elementName;
|
||||
currentSpecieComposition[nSpecieElements++].nAtoms() = nAtoms;
|
||||
}
|
||||
}
|
||||
@ -503,38 +502,26 @@ bool finishReaction = false;
|
||||
<readThermoFormula2>{thermoFormula2} {
|
||||
const string thermoFormula(YYText());
|
||||
word elementName = word::validate(thermoFormula.substr(0, 2));
|
||||
const label nAtoms = atoi(thermoFormula.substr(2, 3).c_str());
|
||||
const int nAtoms = atoi(thermoFormula.substr(2, 3).c_str());
|
||||
|
||||
if
|
||||
(
|
||||
elementName.size()
|
||||
&& elementName.find('0') == string::npos
|
||||
&& elementName.find('0') == std::string::npos
|
||||
&& nAtoms
|
||||
)
|
||||
{
|
||||
correctElementName(elementName);
|
||||
currentSpecieComposition[nSpecieElements].name() =
|
||||
elementName;
|
||||
currentSpecieComposition[nSpecieElements].name() = elementName;
|
||||
currentSpecieComposition[nSpecieElements++].nAtoms() = nAtoms;
|
||||
}
|
||||
|
||||
currentSpecieComposition.setSize(nSpecieElements);
|
||||
|
||||
speciesCompositionTable::iterator specieCompositionIter
|
||||
(
|
||||
speciesComposition_.find(currentSpecieName)
|
||||
);
|
||||
|
||||
if (specieCompositionIter != speciesComposition_.end())
|
||||
{
|
||||
speciesComposition_.erase(specieCompositionIter);
|
||||
}
|
||||
|
||||
speciesComposition_.insert
|
||||
(
|
||||
currentSpecieName,
|
||||
currentSpecieComposition
|
||||
);
|
||||
// Add current specie composition to the hash table
|
||||
// - overwrite existing
|
||||
speciesComposition_.erase(currentSpecieName);
|
||||
speciesComposition_.set(currentSpecieName, currentSpecieComposition);
|
||||
|
||||
BEGIN(readThermoLineLabel1);
|
||||
}
|
||||
@ -589,17 +576,9 @@ bool finishReaction = false;
|
||||
|
||||
<readThermoLineLabel4>{thermoLineLabel4} {
|
||||
|
||||
HashPtrTable<gasHThermoPhysics>::iterator specieThermoIter
|
||||
(
|
||||
speciesThermo_.find(currentSpecieName)
|
||||
);
|
||||
speciesThermo_.erase(currentSpecieName);
|
||||
|
||||
if (specieThermoIter != speciesThermo_.end())
|
||||
{
|
||||
speciesThermo_.erase(specieThermoIter);
|
||||
}
|
||||
|
||||
speciesThermo_.insert
|
||||
speciesThermo_.set
|
||||
(
|
||||
currentSpecieName,
|
||||
autoPtr<gasHThermoPhysics>::New
|
||||
@ -673,14 +652,12 @@ bool finishReaction = false;
|
||||
|
||||
const word keyword = word::validate(YYText());
|
||||
|
||||
HashTable<int>::iterator reactionKeywordIter
|
||||
(
|
||||
reactionKeywordTable_.find(keyword)
|
||||
);
|
||||
const auto reactionKeywordIter =
|
||||
reactionKeywordTable_.cfind(keyword);
|
||||
|
||||
if (reactionKeywordIter != reactionKeywordTable_.end())
|
||||
if (reactionKeywordIter.found())
|
||||
{
|
||||
switch(reactionKeywordIter())
|
||||
switch (reactionKeywordIter.val())
|
||||
{
|
||||
case duplicateReactionType:
|
||||
{
|
||||
@ -785,12 +762,10 @@ bool finishReaction = false;
|
||||
{
|
||||
currentSpecieName = word::validate(YYText());
|
||||
|
||||
HashTable<label>::iterator specieIndexIter
|
||||
(
|
||||
specieIndices_.find(currentSpecieName)
|
||||
);
|
||||
const auto specieIndexIter =
|
||||
specieIndices_.cfind(currentSpecieName);
|
||||
|
||||
if (specieIndexIter != specieIndices_.end())
|
||||
if (specieIndexIter.found())
|
||||
{
|
||||
if (finishReaction)
|
||||
{
|
||||
@ -815,7 +790,7 @@ bool finishReaction = false;
|
||||
lrhsPtr = &lhs;
|
||||
}
|
||||
|
||||
currentSpecieCoeff.index = specieIndexIter();
|
||||
currentSpecieCoeff.index = specieIndexIter.val();
|
||||
lrhsPtr->append(currentSpecieCoeff);
|
||||
|
||||
BEGIN(readReactionDelimiter);
|
||||
@ -829,16 +804,14 @@ bool finishReaction = false;
|
||||
|
||||
<readReactionKeyword>{reactionKeywordSlash} {
|
||||
|
||||
word keyword = word::validate(YYText());
|
||||
const word keyword = word::validate(YYText());
|
||||
|
||||
HashTable<int>::iterator reactionKeywordIter
|
||||
(
|
||||
reactionKeywordTable_.find(keyword)
|
||||
);
|
||||
const auto reactionKeywordIter =
|
||||
reactionKeywordTable_.cfind(keyword);
|
||||
|
||||
if (reactionKeywordIter != reactionKeywordTable_.end())
|
||||
if (reactionKeywordIter.found())
|
||||
{
|
||||
switch(reactionKeywordIter())
|
||||
switch (reactionKeywordIter.val())
|
||||
{
|
||||
case unimolecularFallOffReactionType:
|
||||
{
|
||||
@ -1144,14 +1117,12 @@ bool finishReaction = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
HashTable<label>::iterator specieIndexIter
|
||||
(
|
||||
specieIndices_.find(keyword)
|
||||
);
|
||||
const auto specieIndexIter =
|
||||
specieIndices_.cfind(keyword);
|
||||
|
||||
if (specieIndexIter != specieIndices_.end())
|
||||
if (specieIndexIter.found())
|
||||
{
|
||||
currentThirdBodyIndex = specieIndexIter();
|
||||
currentThirdBodyIndex = specieIndexIter.val();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1170,12 +1141,10 @@ bool finishReaction = false;
|
||||
<readSpecieNamePlus>"+" {
|
||||
currentSpecieName += "+";
|
||||
|
||||
HashTable<label>::iterator specieIndexIter
|
||||
(
|
||||
specieIndices_.find(currentSpecieName)
|
||||
);
|
||||
const auto specieIndexIter =
|
||||
specieIndices_.cfind(currentSpecieName);
|
||||
|
||||
if (specieIndexIter != specieIndices_.end())
|
||||
if (specieIndexIter.found())
|
||||
{
|
||||
if (finishReaction)
|
||||
{
|
||||
@ -1200,7 +1169,7 @@ bool finishReaction = false;
|
||||
lrhsPtr = &lhs;
|
||||
}
|
||||
|
||||
currentSpecieCoeff.index = specieIndexIter();
|
||||
currentSpecieCoeff.index = specieIndexIter.val();
|
||||
lrhsPtr->append(currentSpecieCoeff);
|
||||
|
||||
BEGIN(readReactionDelimiter);
|
||||
@ -1339,15 +1308,13 @@ bool finishReaction = false;
|
||||
|
||||
if (pDependentSpecieName != "M")
|
||||
{
|
||||
HashTable<label>::iterator specieIndexIter
|
||||
(
|
||||
specieIndices_.find(pDependentSpecieName)
|
||||
);
|
||||
const auto specieIndexIter =
|
||||
specieIndices_.cfind(pDependentSpecieName);
|
||||
|
||||
if (specieIndexIter != specieIndices_.end())
|
||||
if (specieIndexIter.found())
|
||||
{
|
||||
thirdBodyEfficiencies = 0.0;
|
||||
thirdBodyEfficiencies[specieIndexIter()] = 1.0;
|
||||
thirdBodyEfficiencies[specieIndexIter.val()] = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1385,14 +1352,11 @@ bool finishReaction = false;
|
||||
<readReactionOrderSpecie>{specieName} {
|
||||
currentSpecieName = word::validate(YYText());
|
||||
|
||||
HashTable<label>::iterator specieIndexIter
|
||||
(
|
||||
specieIndices_.find(currentSpecieName)
|
||||
);
|
||||
const auto specieIndexIter = specieIndices_.cfind(currentSpecieName);
|
||||
|
||||
if (specieIndexIter != specieIndices_.end())
|
||||
if (specieIndexIter.found())
|
||||
{
|
||||
currentSpecieIndex = specieIndexIter();
|
||||
currentSpecieIndex = specieIndexIter.val();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1414,11 +1378,11 @@ bool finishReaction = false;
|
||||
|
||||
bool found = false;
|
||||
|
||||
forAll(lrhs, i)
|
||||
for (gasHReaction::specieCoeffs& coeffs : lrhs)
|
||||
{
|
||||
if (lrhs[i].index == currentSpecieIndex)
|
||||
if (coeffs.index == currentSpecieIndex)
|
||||
{
|
||||
lrhs[i].exponent = stringToScalar(YYText());
|
||||
coeffs.exponent = stringToScalar(YYText());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -73,52 +73,39 @@ void Foam::foamChemistryReader<ThermoType>::readSpeciesComposition()
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through all species in thermoDict to retrieve
|
||||
// the species composition
|
||||
forAll(speciesTable_, si)
|
||||
// Loop through all species in thermoDict to retrieve species composition
|
||||
for (const word& specieName : speciesTable_)
|
||||
{
|
||||
if (thermoDict_.subDict(speciesTable_[si]).isDict("elements"))
|
||||
{
|
||||
dictionary currentElements
|
||||
(
|
||||
thermoDict_.subDict(speciesTable_[si]).subDict("elements")
|
||||
);
|
||||
const dictionary* elemsDict =
|
||||
thermoDict_.subDict(specieName).findDict("elements");
|
||||
|
||||
wordList currentElementsName(currentElements.toc());
|
||||
List<specieElement> currentComposition(currentElementsName.size());
|
||||
|
||||
forAll(currentElementsName, eni)
|
||||
if (!elemsDict)
|
||||
{
|
||||
currentComposition[eni].name() = currentElementsName[eni];
|
||||
FatalIOErrorInFunction(thermoDict_)
|
||||
<< "Specie " << specieName
|
||||
<< " does not contain \"elements\" description."
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
wordList elemNames(elemsDict->toc());
|
||||
List<specieElement> currentComposition(elemNames.size());
|
||||
|
||||
forAll(elemNames, eni)
|
||||
{
|
||||
currentComposition[eni].name() = elemNames[eni];
|
||||
|
||||
currentComposition[eni].nAtoms() =
|
||||
currentElements.lookupOrDefault
|
||||
elemsDict->lookupOrDefault<label>
|
||||
(
|
||||
currentElementsName[eni],
|
||||
elemNames[eni],
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
// Add current specie composition to the hash table
|
||||
speciesCompositionTable::iterator specieCompositionIter
|
||||
(
|
||||
speciesComposition_.find(speciesTable_[si])
|
||||
);
|
||||
|
||||
if (specieCompositionIter != speciesComposition_.end())
|
||||
{
|
||||
speciesComposition_.erase(specieCompositionIter);
|
||||
}
|
||||
|
||||
speciesComposition_.insert(speciesTable_[si], currentComposition);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(thermoDict_)
|
||||
<< "Specie " << speciesTable_[si]
|
||||
<< " does not contain element description."
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
// - overwrite existing
|
||||
speciesComposition_.erase(specieName);
|
||||
speciesComposition_.set(specieName, currentComposition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -72,13 +72,6 @@ Foam::ReactionList<ThermoType>::ReactionList(const ReactionList& reactions)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::ReactionList<ThermoType>::~ReactionList()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
@ -106,10 +99,8 @@ void Foam::ReactionList<ThermoType>::write(Ostream& os) const
|
||||
{
|
||||
os.beginBlock("reactions");
|
||||
|
||||
forAllConstIter(typename SLPtrList<Reaction<ThermoType>>, *this, iter)
|
||||
for (const Reaction<ThermoType>& r : *this)
|
||||
{
|
||||
const Reaction<ThermoType>& r = iter();
|
||||
|
||||
os.beginBlock(r.name());
|
||||
|
||||
os.writeEntry("type", r.type());
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -100,7 +100,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
~ReactionList();
|
||||
~ReactionList() = default;
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
Reference in New Issue
Block a user