ENH: provide explicit literal/regex for dictionary findEntry

This commit is contained in:
Mark Olesen
2023-02-22 15:33:25 +01:00
parent 7246b49eac
commit f3d447579a
6 changed files with 19 additions and 24 deletions

View File

@ -99,9 +99,9 @@ Foam::expressions::exprResultDelayed::exprResultDelayed
storeInterval_(dict.get<scalar>("storeInterval")), storeInterval_(dict.get<scalar>("storeInterval")),
delay_(dict.get<scalar>("delay")) delay_(dict.get<scalar>("delay"))
{ {
const entry *eptr = dict.findEntry("storedValues"); const entry *eptr = dict.findEntry("storedValues", keyType::LITERAL);
if (eptr) if (eptr && eptr->isStream())
{ {
storedValues_ = DLList<ValueAtTime>(eptr->stream()); storedValues_ = DLList<ValueAtTime>(eptr->stream());
} }

View File

@ -106,11 +106,11 @@ Foam::tmp<Foam::fvGeometryScheme> Foam::fvGeometryScheme::New
const word& defaultScheme const word& defaultScheme
) )
{ {
const entry* ePtr = dict.findEntry("method"); const entry* eptr = dict.findEntry("method", keyType::LITERAL);
const word schemeName const word schemeName
( (
ePtr eptr
? word(ePtr->stream()) ? word(eptr->stream())
: dict.getOrDefault<word>("type", defaultScheme) : dict.getOrDefault<word>("type", defaultScheme)
); );

View File

@ -292,7 +292,7 @@ void Foam::sampledSets::initDict(const dictionary& dict, const bool initial)
writers_.clear(); writers_.clear();
} }
const entry* eptr = dict.findEntry("sets"); const entry* eptr = dict.findEntry("sets", keyType::LITERAL);
if (eptr && eptr->isDict()) if (eptr && eptr->isDict())
{ {
@ -529,7 +529,7 @@ bool Foam::sampledSets::read(const dictionary& dict)
samplePointScheme_ = samplePointScheme_ =
dict.getOrDefault<word>("interpolationScheme", "cellPoint"); dict.getOrDefault<word>("interpolationScheme", "cellPoint");
const entry* eptr = dict.findEntry("sets"); const entry* eptr = dict.findEntry("sets", keyType::LITERAL);
if (eptr) if (eptr)
{ {

View File

@ -297,7 +297,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
sampleNodeScheme_ = sampleNodeScheme_ =
dict.getOrDefault<word>("interpolationScheme", "cellPoint"); dict.getOrDefault<word>("interpolationScheme", "cellPoint");
const entry* eptr = dict.findEntry("surfaces"); const entry* eptr = dict.findEntry("surfaces", keyType::LITERAL);
// Surface writer type and format options // Surface writer type and format options
const word writerType = const word writerType =

View File

@ -128,7 +128,7 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
<< exit(FatalError); << exit(FatalError);
} }
//const auto* eptr = dict.findEntry("thicknessLayers"); //const auto* eptr = dict.findEntry("thicknessLayers", keyType::LITERAL);
//if (eptr) //if (eptr)
//{ //{
// // Detect either a list (parsed as a scalarList) or // // Detect either a list (parsed as a scalarList) or

View File

@ -89,14 +89,16 @@ Foam::radiation::boundaryRadiationProperties::boundaryRadiationProperties
{ {
const label patchi = pp.index(); const label patchi = pp.index();
const auto* ePtr = radiationDict.findEntry(pp.name()); // Allow wildcard matches
const auto* eptr =
radiationDict.findEntry(pp.name(), keyType::REGEX);
if (ePtr && ePtr->isDict()) if (eptr && eptr->isDict())
{ {
radBoundaryPropertiesPtrList_.set radBoundaryPropertiesPtrList_.set
( (
patchi, patchi,
boundaryRadiationPropertiesPatch::New(ePtr->dict(), pp) boundaryRadiationPropertiesPatch::New(eptr->dict(), pp)
); );
matchedEntries.insert(pp.name()); matchedEntries.insert(pp.name());
@ -132,32 +134,25 @@ Foam::radiation::boundaryRadiationProperties::boundaryRadiationProperties
{ {
const label zonei = fz.index(); const label zonei = fz.index();
if (!matchedEntries.found(fz.name())) if (!matchedEntries.contains(fz.name()))
{ {
// Note: avoid wildcard matches. Assume user explicitly // Note: avoid wildcard matches. Assume user explicitly
// provided information for faceZones. // provided information for faceZones.
const auto* ePtr = radiationDict.findEntry
const auto* eptr = radiationDict.findEntry
( (
fz.name(), fz.name(),
keyType::LITERAL keyType::LITERAL
); );
// Skip face zones that are not used in boundary radiation if (eptr && eptr->isDict())
if (!ePtr)
{ {
continue;
}
if (ePtr->isDict())
{
const dictionary& dict = ePtr->dict();
radZonePropertiesPtrList_.set radZonePropertiesPtrList_.set
( (
zonei, zonei,
boundaryRadiationPropertiesPatch::New boundaryRadiationPropertiesPatch::New
( (
dict, eptr->dict(),
dummyRef dummyRef
) )
); );