ENH: rationalize expression string reading

- read construct from dictionary.
  Calling syntax similar to dimensionedType, dimensionedSet,...

  Replaces the older getEntry(), getOptional() static methods

- support readIfPresent
This commit is contained in:
Mark Olesen
2022-09-28 09:24:46 +02:00
parent 3a6e427409
commit ee9119f436
25 changed files with 218 additions and 261 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,16 +39,14 @@ Foam::Function1Types::Function1Expression<Type>::Function1Expression
:
Function1<Type>(entryName, dict, obrPtr),
dict_(dict), // Deep copy
valueExpr_(),
driver_(1, dict_)
valueExpr_("expression", dict_),
driver_(1, dict_) // size=1
{
if (dict.getOrDefault("debug", false))
{
debug |= 1;
}
valueExpr_.readEntry("expression", dict_);
// Basic sanity
if (valueExpr_.empty())
{
@ -70,7 +68,7 @@ Foam::Function1Types::Function1Expression<Type>::Function1Expression
Function1<Type>(rhs),
dict_(rhs.dict_), // Deep copy
valueExpr_(rhs.valueExpr_),
driver_(1, rhs.driver_, dict_)
driver_(1, rhs.driver_, dict_) // size=1
{}

View File

@ -300,8 +300,8 @@ bool Foam::expressions::exprDriver::readDict
{
dict.readIfPresent("debug.driver", debug);
// Regular variables
variableStrings_ = readVariableStrings(dict);
// Regular variables (optional)
variableStrings_ = readVariableStrings(dict, "variables", false);
// Create Function1s from dictionary content
resetFunctions(dict);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -77,7 +77,7 @@ Foam::expressions::exprDriver::readExpression
const dictionary& dict
)
{
return expressions::exprString(dict.get<string>(name), dict);
return expressions::exprString(name, dict);
}
@ -87,7 +87,7 @@ Foam::expressions::exprDriver::readExpression
const word& name
)
{
return readExpression(name, dict());
return expressions::exprString(name, dict());
}
@ -99,7 +99,7 @@ Foam::expressions::exprDriver::readVariableStrings
bool mandatory
)
{
return exprTools::getList(dict, keyword, mandatory);
return exprTools::getList(keyword, dict, mandatory);
}
@ -109,7 +109,7 @@ Foam::label Foam::expressions::exprDriver::setVariableStrings
bool mandatory
)
{
variableStrings_ = readVariableStrings(dict, "variable", mandatory);
variableStrings_ = readVariableStrings(dict, "variables", mandatory);
return variableStrings_.size();
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -65,8 +65,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef exprTools_expressionEntry_H
#define exprTools_expressionEntry_H
#ifndef Foam_exprTools_expressionEntry_H
#define Foam_exprTools_expressionEntry_H
#include "exprString.H"
#include "primitiveEntry.H"
@ -115,8 +115,8 @@ public:
// Constructors
//- Construct null
expressionEntry() = default;
//- Default construct
expressionEntry() noexcept = default;
// Selectors

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,7 +95,7 @@ Foam::expressions::exprResultDelayed::exprResultDelayed
:
exprResult(dict.subOrEmptyDict("value")),
name_(dict.get<word>("name")),
startExpr_(dict.get<string>("startupValue"), dict),
startExpr_("startupValue", dict),
storeInterval_(dict.get<scalar>("storeInterval")),
delay_(dict.get<scalar>("delay"))
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -82,7 +82,7 @@ Foam::expressions::exprResultStored::exprResultStored
:
expressions::exprResult(dict.subOrEmptyDict("value")),
name_(dict.get<word>("name")),
startExpr_(dict.get<string>("initialValue"), dict)
startExpr_("initialValue", dict)
{}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,6 +28,7 @@ License
#include "exprString.H"
#include "stringOps.H"
#include "expressionEntry.H"
#include "error.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -47,36 +48,6 @@ void Foam::expressions::exprString::inplaceExpand
}
Foam::expressions::exprString
Foam::expressions::exprString::getEntry
(
const word& key,
const dictionary& dict,
const bool stripComments
)
{
exprString expr;
expr.readEntry(key, dict, true, stripComments); // mandatory
return expr;
}
Foam::expressions::exprString
Foam::expressions::exprString::getOptional
(
const word& key,
const dictionary& dict,
const bool stripComments
)
{
exprString expr;
expr.readEntry(key, dict, false, stripComments); // optional
return expr;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::expressions::exprString::expand
@ -103,15 +74,14 @@ bool Foam::expressions::exprString::readEntry
(
const word& keyword,
const dictionary& dict,
bool mandatory,
const bool stripComments
bool mandatory
)
{
const bool ok = dict.readEntry(keyword, *this, keyType::LITERAL, mandatory);
if (ok && !empty())
{
this->expand(dict, stripComments); // strip comments
this->expand(dict, true); // strip comments
}
else
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,8 +40,8 @@ SeeAlso
\*---------------------------------------------------------------------------*/
#ifndef expressions_exprString_H
#define expressions_exprString_H
#ifndef Foam_expressions_exprString_H
#define Foam_expressions_exprString_H
#include "string.H"
#include "dictionary.H"
@ -75,34 +75,26 @@ public:
exprString(exprString&& rhs) = default;
//- Copy construct from std::string
inline explicit exprString(const std::string& s, bool doValidate=true);
inline explicit exprString(const std::string& s, bool doCheck=true);
//- Move construct from std::string
inline explicit exprString(std::string&& s, bool doValidate=true);
inline explicit exprString(std::string&& s, bool doCheck=true);
//- Construct as copy of character array
inline explicit exprString(const char* s, bool doValidate=true);
inline explicit exprString(const char* s, bool doCheck=true);
//- Copy construct and expand with dictionary variables,
//- and strip C/C++ comments from the input
//- Construct from dictionary entry lookup.
//- Expands dictionary variables and strips and strips any
//- embedded C/C++ comments
inline exprString
(
const std::string& str,
const word& entryName, //!< Lookup key. LITERAL (not REGEX)
const dictionary& dict,
const bool stripComments = true
const bool mandatory = true
);
//- Move construct and expand with dictionary variables,
//- and strip C/C++ comments from the input
inline exprString
(
std::string&& str,
const dictionary& dict,
const bool stripComments = true
);
//- Construct from Istream and expand with dictionary variables,
//- and strip C/C++ comments from the input
//- Construct from Istream with dictionary context for expanding
//- dictionary variables. Strips any embedded C/C++ comments
inline exprString
(
Istream& is,
@ -117,8 +109,38 @@ public:
// Static Member Functions
//- Copy convert string to exprString.
// No expansions, know what you are doing.
inline static exprString toExpr(const std::string& str);
//- Move convert string to exprString.
// No expansions, know what you are doing.
inline static exprString toExpr(std::string&& str);
//- Copy convert string to exprString with dictionary expansions,
//- stripping any embedded C/C++ comments
//
// \sa inplaceExpand() for expansion details
static exprString toExpr
(
const std::string& str,
const dictionary& dict,
const bool stripComments = true
);
//- Move convert string to exprString with dictionary expansions,
//- stripping any embedded C/C++ comments
//
// \sa inplaceExpand() for expansion details
static exprString toExpr
(
std::string&& str,
const dictionary& dict,
const bool stripComments = true
);
//- Inplace expansion with dictionary variables,
//- and strip C/C++ comments from the input.
//- and strip any embedded C/C++ comments
//
// \par Expansion behaviour
// - alternatives = True
@ -133,34 +155,6 @@ public:
const bool stripComments = true
);
//- Get and expand expression with dictionary entries,
//- optionally strip C/C++ comments from the input.
// Expansion behaviour as per inplaceExpand
static exprString getEntry
(
const word& keyword, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict,
const bool stripComments = true
);
//- Get and expand expression with dictionary entries,
//- optionally strip C/C++ comments from the input.
// Expansion behaviour as per inplaceExpand
static exprString getOptional
(
const word& keyword, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict,
const bool stripComments = true
);
//- Copy convert string to exprString.
// No expansions, know what you are doing.
inline static exprString toExpr(const std::string& str);
//- Move convert string to exprString.
// No expansions, know what you are doing.
inline static exprString toExpr(std::string&& str);
// Member Functions
@ -168,20 +162,28 @@ public:
inline bool valid() const;
//- Inplace expansion with dictionary variables,
//- and strip C/C++ comments from the input
//- and strip any embedded C/C++ comments.
// \sa inplaceExpand() for expansion details
void expand(const dictionary& dict, const bool stripComments = true);
//- Inplace trim leading and trailing whitespace
void trim();
//- Read/expand entry with dictionary variables,
//- and strip C/C++ comments from the input
//- and strip any embedded C/C++ comments from the input
bool readEntry
(
const word& keyword, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict,
bool mandatory = true,
const bool stripComments = true
bool mandatory = true
);
//- Read/expand optional entry with dictionary variables,
//- and strip any embedded C/C++ comments from the input
inline bool readIfPresent
(
const word& keyword, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict
);
@ -206,7 +208,7 @@ public:
// Write
//- Dictionary entry for expression string, normally suppressing
//- empty strings. Generally used verbatim output (readability)
//- empty strings. Generally uses verbatim output (readability)
// \return true if entry was written
bool writeEntry
(

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,13 +33,13 @@ License
inline Foam::expressions::exprString::exprString
(
const std::string& s,
bool doValidate
bool doCheck
)
:
string(s)
{
#ifdef FULLDEBUG
if (doValidate)
if (doCheck)
{
(void)valid();
}
@ -50,13 +50,13 @@ inline Foam::expressions::exprString::exprString
inline Foam::expressions::exprString::exprString
(
std::string&& s,
bool doValidate
bool doCheck
)
:
string(std::move(s))
{
#ifdef FULLDEBUG
if (doValidate)
if (doCheck)
{
(void)valid();
}
@ -67,13 +67,13 @@ inline Foam::expressions::exprString::exprString
inline Foam::expressions::exprString::exprString
(
const char* s,
bool doValidate
bool doCheck
)
:
string(s)
{
#ifdef FULLDEBUG
if (doValidate)
if (doCheck)
{
(void)valid();
}
@ -83,27 +83,19 @@ inline Foam::expressions::exprString::exprString
inline Foam::expressions::exprString::exprString
(
const std::string& str,
const word& entryName,
const dictionary& dict,
const bool removeComments
const bool mandatory
)
:
string(str)
{
expand(dict, removeComments);
}
inline Foam::expressions::exprString::exprString
(
std::string&& str,
const dictionary& dict,
const bool removeComments
)
:
string(std::move(str))
{
expand(dict, removeComments);
if (mandatory)
{
readEntry(entryName, dict);
}
else
{
readIfPresent(entryName, dict);
}
}
@ -120,6 +112,64 @@ inline Foam::expressions::exprString::exprString
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
inline Foam::expressions::exprString
Foam::expressions::exprString::toExpr(const std::string& str)
{
exprString expr;
expr.string::operator=(str);
return expr;
}
inline Foam::expressions::exprString
Foam::expressions::exprString::toExpr(std::string&& str)
{
exprString expr;
expr.string::operator=(std::move(str));
return expr;
}
inline Foam::expressions::exprString
Foam::expressions::exprString::toExpr
(
const std::string& str,
const dictionary& dict,
const bool stripComments
)
{
// Copy - no validate
exprString expr(str, false);
expr.expand(dict, stripComments);
return expr;
}
inline Foam::expressions::exprString
Foam::expressions::exprString::toExpr
(
std::string&& str,
const dictionary& dict,
const bool stripComments
)
{
// Move - no validate
exprString expr(std::move(str), false);
expr.expand(dict, stripComments);
return expr;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::expressions::exprString::valid() const
@ -139,25 +189,13 @@ inline bool Foam::expressions::exprString::valid() const
}
inline Foam::expressions::exprString
Foam::expressions::exprString::toExpr(const std::string& str)
inline bool Foam::expressions::exprString::readIfPresent
(
const word& key,
const dictionary& dict
)
{
exprString expr;
expr.string::operator=(str);
return expr;
}
inline Foam::expressions::exprString
Foam::expressions::exprString::toExpr(std::string&& str)
{
exprString expr;
expr.string::operator=(std::move(str));
return expr;
return readEntry(key, dict, false); // non-mandatory
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -81,8 +81,8 @@ static List<expressions::exprString> expandExprStrings
(
exprTools::getList
(
dict,
varExpr.substr(1),
dict,
mandatory,
recursionDepth
)
@ -99,7 +99,10 @@ static List<expressions::exprString> expandExprStrings
}
else
{
result.append(expressions::exprString(varExpr, dict));
result.append
(
expressions::exprString::toExpr(std::move(varExpr), dict)
);
}
}
}
@ -113,13 +116,13 @@ static List<expressions::exprString> expandExprStrings
} // End namespace Foam
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::List<Foam::expressions::exprString>
Foam::exprTools::getList
(
const dictionary& dict,
const word& keyword,
const dictionary& dict,
bool mandatory,
label recursionDepth
)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef exprTools_H
#define exprTools_H
#ifndef Foam_exprTools_H
#define Foam_exprTools_H
#include "exprOps.H"
#include "exprString.H"
@ -93,8 +93,8 @@ string toString(ITstream& is);
// \endcode
List<expressions::exprString> getList
(
const dictionary& dict,
const word& keyword,
const dictionary& dict,
bool mandatory = true,
label recursionDepth = 0
);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,7 +42,7 @@ Foam::PatchFunction1Types::PatchExprField<Type>::PatchExprField
:
PatchFunction1<Type>(pp, entryName, dict, faceValues),
dict_(dict), // Deep copy
valueExpr_(),
valueExpr_("expression", dict_),
driver_(fvPatch::lookupPatch(this->patch()), dict_)
{
if (dict.getOrDefault("debug", false))
@ -50,8 +50,6 @@ Foam::PatchFunction1Types::PatchExprField<Type>::PatchExprField
debug |= 1;
}
valueExpr_.readEntry("expression", dict_);
// Basic sanity
if (valueExpr_.empty())
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,29 +51,42 @@ void Foam::expressions::patchExprFieldBase::readExpressions
gradExpr_.clear();
fracExpr_.clear();
string exprValue, exprGrad, exprFrac;
bool evalValue = false, evalGrad = false, evalFrac = false;
if (expectedTypes::VALUE_TYPE == expectedType)
{
// Mandatory
evalValue = dict.readEntry("valueExpr", exprValue, keyType::LITERAL);
valueExpr_.readEntry("valueExpr", dict);
}
else if (expectedTypes::GRADIENT_TYPE == expectedType)
{
// Mandatory
evalGrad = dict.readEntry("gradientExpr", exprGrad, keyType::LITERAL);
gradExpr_.readEntry("gradientExpr", dict);
}
else
{
// MIXED_TYPE
evalValue =
dict.readIfPresent("valueExpr", exprValue, keyType::LITERAL);
const bool evalValue = valueExpr_.readIfPresent("valueExpr", dict);
const bool evalGrad = gradExpr_.readIfPresent("gradientExpr", dict);
evalGrad =
dict.readIfPresent("gradientExpr", exprGrad, keyType::LITERAL);
// Expect a fraction as well
// - but allow it to be optional and defer treatment to inherited BC
if (!evalValue && !evalGrad)
if (evalValue && evalGrad)
{
if
(
fracExpr_.readIfPresent("fractionExpr", dict)
&& !fracExpr_.empty()
)
{
// Add function call wrapping for point data,
// but not for 0/1 (handled as shortcuts later)
if (wantPointData && fracExpr_ != "0" && fracExpr_ != "1")
{
fracExpr_ = "toPoint(" + fracExpr_ + ")";
}
}
}
else
{
FatalIOErrorInFunction(dict)
<< "Entries 'valueExpr' and 'gradientExpr' "
@ -94,45 +107,6 @@ void Foam::expressions::patchExprFieldBase::readExpressions
}
}
}
// When both value/gradient specified (ie, mixed) expect a fraction
// - if missing, defer treatment to inherited BC
if (evalValue && evalGrad && dict.readIfPresent("fractionExpr", exprFrac))
{
stringOps::inplaceTrim(exprFrac);
if (exprFrac == "0" || exprFrac == "1")
{
// Special cases, handled with more efficiency
fracExpr_ = exprFrac;
}
else if (!exprFrac.empty())
{
evalFrac = true;
if (wantPointData)
{
exprFrac = "toPoint(" + exprFrac + ")";
}
}
}
// Expansions
if (evalValue)
{
valueExpr_ = expressions::exprString(exprValue, dict);
}
if (evalGrad)
{
gradExpr_ = expressions::exprString(exprGrad, dict);
}
if (evalFrac)
{
fracExpr_ = expressions::exprString(exprFrac, dict);
}
}

View File

@ -377,7 +377,7 @@ bool Foam::functionObjects::fvExpressionField::read(const dictionary& dict)
case actionType::opModify:
{
// Optional <fieldMask> for modify
maskExpr_.readEntry("fieldMask", dict, false);
maskExpr_.readIfPresent("fieldMask", dict);
[[fallthrough]];
}
case actionType::opNew: