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")),
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());
}

View File

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

View File

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

View File

@ -297,7 +297,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
sampleNodeScheme_ =
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
const word writerType =

View File

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