mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: additional patch expressions (#2114)
- snGrad, internalField, neighbourField. Functional use as per swak: "... + internalField(T) ..." ENH: additional volume/patch expressions - deltaT() STYLE: rename exprDriverWriter -> fvExprDriverWriter - the original class name was a misnomer since it holds a reference to fvExprDriver BUG: expression faceToPoint/pointToFace definitions were flipped ENH: refactor expression hierarchy and code style - handle TimeState reference at the top-level for simpler derivations - unified internal search parameters (cruft)
This commit is contained in:
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,6 +29,7 @@ License
|
||||
#include "exprDriver.H"
|
||||
#include "expressionEntry.H"
|
||||
#include "stringOps.H"
|
||||
#include "TimeState.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,9 +44,31 @@ namespace expressions
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
int Foam::expressions::exprDriver::getSearchControls(const dictionary& dict)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
if (dict.getOrDefault("searchInMemory", true))
|
||||
{
|
||||
val |= int(searchControls::SEARCH_REGISTRY);
|
||||
}
|
||||
if (dict.getOrDefault("searchFiles", false))
|
||||
{
|
||||
val |= int(searchControls::SEARCH_FILES);
|
||||
}
|
||||
if (dict.getOrDefault("cacheReadFields", false))
|
||||
{
|
||||
val |= int(searchControls::CACHE_READ_FIELDS);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
#if 0
|
||||
@ -78,14 +101,27 @@ static string getEntryString
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::expressions::exprDriver::resetTimeReference(const TimeState* ts)
|
||||
{
|
||||
timeStatePtr_ = ts;
|
||||
}
|
||||
|
||||
|
||||
void Foam::expressions::exprDriver::resetTimeReference(const TimeState& ts)
|
||||
{
|
||||
timeStatePtr_ = &ts;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::expressions::exprDriver::exprDriver
|
||||
(
|
||||
bool cacheReadFields,
|
||||
bool searchInMemory,
|
||||
bool searchFiles,
|
||||
const dictionary& dict
|
||||
enum searchControls search,
|
||||
const dictionary& dict,
|
||||
const TimeState* ts
|
||||
)
|
||||
:
|
||||
dict_(dict),
|
||||
@ -93,6 +129,7 @@ Foam::expressions::exprDriver::exprDriver
|
||||
variableStrings_(),
|
||||
variables_(),
|
||||
arg1Value_(0),
|
||||
timeStatePtr_(ts),
|
||||
stashedTokenId_(0),
|
||||
|
||||
// Controls
|
||||
@ -106,9 +143,7 @@ Foam::expressions::exprDriver::exprDriver
|
||||
(
|
||||
dict.getOrDefault("prevIterIsOldTime", false)
|
||||
),
|
||||
cacheReadFields_(cacheReadFields),
|
||||
searchInMemory_(searchInMemory || cacheReadFields),
|
||||
searchFiles_(searchFiles)
|
||||
searchCtrl_(search)
|
||||
{}
|
||||
|
||||
|
||||
@ -122,6 +157,7 @@ Foam::expressions::exprDriver::exprDriver
|
||||
variableStrings_(rhs.variableStrings_),
|
||||
variables_(rhs.variables_),
|
||||
arg1Value_(rhs.arg1Value_),
|
||||
timeStatePtr_(rhs.timeStatePtr_),
|
||||
stashedTokenId_(0),
|
||||
|
||||
debugScanner_(rhs.debugScanner_),
|
||||
@ -129,23 +165,21 @@ Foam::expressions::exprDriver::exprDriver
|
||||
allowShadowing_(rhs.allowShadowing_),
|
||||
prevIterIsOldTime_(rhs.prevIterIsOldTime_),
|
||||
|
||||
cacheReadFields_(rhs.cacheReadFields_),
|
||||
searchInMemory_(rhs.searchInMemory_),
|
||||
searchFiles_(rhs.searchFiles_)
|
||||
searchCtrl_(rhs.searchCtrl_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::expressions::exprDriver::exprDriver
|
||||
(
|
||||
const dictionary& dict
|
||||
const dictionary& dict,
|
||||
const TimeState* ts
|
||||
)
|
||||
:
|
||||
exprDriver
|
||||
(
|
||||
dict.getOrDefault("cacheReadFields", false),
|
||||
dict.getOrDefault("searchInMemory", true),
|
||||
dict.getOrDefault("searchFiles", false),
|
||||
dict
|
||||
searchControls(exprDriver::getSearchControls(dict)),
|
||||
dict,
|
||||
ts
|
||||
)
|
||||
{
|
||||
readDict(dict);
|
||||
@ -154,6 +188,32 @@ Foam::expressions::exprDriver::exprDriver
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::TimeState* Foam::expressions::exprDriver::timeState() const
|
||||
{
|
||||
return timeStatePtr_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::expressions::exprDriver::timeValue() const
|
||||
{
|
||||
if (timeStatePtr_)
|
||||
{
|
||||
return timeStatePtr_->value();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::expressions::exprDriver::deltaT() const
|
||||
{
|
||||
if (timeStatePtr_)
|
||||
{
|
||||
return timeStatePtr_->deltaT().value();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::expressions::exprDriver::readDict
|
||||
(
|
||||
const dictionary& dict
|
||||
@ -196,18 +256,6 @@ void Foam::expressions::exprDriver::clearVariables()
|
||||
}
|
||||
|
||||
|
||||
void Foam::expressions::exprDriver::setArgument(scalar val)
|
||||
{
|
||||
arg1Value_ = val;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::expressions::exprDriver::argValue() const
|
||||
{
|
||||
return arg1Value_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::expressions::exprDriver::evaluateVariable
|
||||
(
|
||||
const word& varName,
|
||||
@ -383,20 +431,58 @@ void Foam::expressions::exprDriver::setDebugging
|
||||
}
|
||||
|
||||
|
||||
bool Foam::expressions::exprDriver::setCaching(bool on) noexcept
|
||||
{
|
||||
int val(searchCtrl_);
|
||||
bool old = (val & searchControls::CACHE_READ_FIELDS);
|
||||
|
||||
if (!on)
|
||||
{
|
||||
// Off
|
||||
val &= ~(searchControls::CACHE_READ_FIELDS);
|
||||
}
|
||||
else if (!old)
|
||||
{
|
||||
// Toggled on.
|
||||
// Caching read fields implies both registry and disk use
|
||||
val |=
|
||||
(
|
||||
searchControls::SEARCH_REGISTRY
|
||||
| searchControls::SEARCH_FILES
|
||||
| searchControls::CACHE_READ_FIELDS
|
||||
);
|
||||
}
|
||||
|
||||
searchCtrl_ = searchControls(val);
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
void Foam::expressions::exprDriver::setSearchBehaviour
|
||||
(
|
||||
bool cacheReadFields,
|
||||
bool searchInMemory,
|
||||
bool searchFiles
|
||||
enum searchControls search,
|
||||
const bool caching
|
||||
)
|
||||
{
|
||||
searchInMemory_ = searchInMemory_ || cacheReadFields_;
|
||||
int val(search);
|
||||
if (caching || (val & searchControls::CACHE_READ_FIELDS))
|
||||
{
|
||||
// Caching read fields implies both registry and disk use
|
||||
val |=
|
||||
(
|
||||
searchControls::SEARCH_REGISTRY
|
||||
| searchControls::SEARCH_FILES
|
||||
| searchControls::CACHE_READ_FIELDS
|
||||
);
|
||||
}
|
||||
searchCtrl_ = searchControls(val);
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
Info<< "Searching "
|
||||
<< " registry:" << searchInMemory_
|
||||
<< " disk:" << searchFiles_
|
||||
<< " cache-read:" << cacheReadFields_ << nl;
|
||||
<< " registry:" << searchRegistry()
|
||||
<< " disk:" << searchFiles()
|
||||
<< " cache-read:" << cacheReadFields() << nl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -406,12 +492,7 @@ void Foam::expressions::exprDriver::setSearchBehaviour
|
||||
const exprDriver& rhs
|
||||
)
|
||||
{
|
||||
setSearchBehaviour
|
||||
(
|
||||
rhs.cacheReadFields_,
|
||||
rhs.searchInMemory_,
|
||||
rhs.searchFiles_
|
||||
);
|
||||
searchCtrl_ = rhs.searchCtrl_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -68,6 +68,10 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class TimeState;
|
||||
|
||||
namespace expressions
|
||||
{
|
||||
|
||||
@ -77,6 +81,29 @@ namespace expressions
|
||||
|
||||
class exprDriver
|
||||
{
|
||||
public:
|
||||
|
||||
// Data Types
|
||||
|
||||
//- Search/caching controls
|
||||
enum searchControls
|
||||
{
|
||||
NO_SEARCH = 0,
|
||||
SEARCH_REGISTRY = 1, //!< Search registry before disk
|
||||
SEARCH_FILES = 2, //!< Search disk (eg, standalone app)
|
||||
CACHE_READ_FIELDS = 4, //!< Cache fields read from disk
|
||||
DEFAULT_SEARCH = (SEARCH_REGISTRY)
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Get search/caching controls from dictionary entries
|
||||
static int getSearchControls(const dictionary& dict);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
@ -98,6 +125,9 @@ protected:
|
||||
//- Special-purpose scalar reference argument
|
||||
scalar arg1Value_;
|
||||
|
||||
//- Reference to the time-state
|
||||
mutable const TimeState* timeStatePtr_;
|
||||
|
||||
|
||||
// Controls, tracing etc.
|
||||
|
||||
@ -116,18 +146,28 @@ protected:
|
||||
//- Use value of previous iteration when oldTime is requested
|
||||
bool prevIterIsOldTime_;
|
||||
|
||||
//- Keep fields read from disc in memory
|
||||
bool cacheReadFields_;
|
||||
|
||||
//- Search in registry before looking on disk
|
||||
bool searchInMemory_;
|
||||
|
||||
//- Search on disk (eg, for a standalone application)
|
||||
bool searchFiles_;
|
||||
//- Registry/disk/caching control
|
||||
searchControls searchCtrl_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
inline bool searchRegistry() const noexcept;
|
||||
inline bool searchFiles() const noexcept;
|
||||
inline bool cacheReadFields() const noexcept;
|
||||
|
||||
//- Reset the time-state reference
|
||||
void resetTimeReference(const TimeState* ts);
|
||||
|
||||
//- Reset the time-state reference
|
||||
void resetTimeReference(const TimeState& ts);
|
||||
|
||||
//- Lookup field object.
|
||||
// \return const-ref tmp or invalid if not found
|
||||
template<class GeoField>
|
||||
static tmp<GeoField>
|
||||
cfindFieldObject(const objectRegistry& obr, const word& fldName);
|
||||
|
||||
//- Read an interpolation table
|
||||
template<typename TableType>
|
||||
static bool readTable
|
||||
@ -159,7 +199,8 @@ protected:
|
||||
//- Fill a random field
|
||||
//
|
||||
// \param field the field to populate
|
||||
// \param seed the seed value.
|
||||
// \param seed the seed value. If zero or negative, use as an offset
|
||||
// to the current timeIndex (if a time-state is available)
|
||||
// \param gaussian generate a Gaussian distribution
|
||||
void fill_random
|
||||
(
|
||||
@ -227,20 +268,23 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor, and null construct with search preferences
|
||||
//- Default construct, and default construct with search preferences
|
||||
explicit exprDriver
|
||||
(
|
||||
bool cacheReadFields = false,
|
||||
bool searchInMemory = true,
|
||||
bool searchFiles = false,
|
||||
const dictionary& dict = dictionary::null
|
||||
enum searchControls search = searchControls::DEFAULT_SEARCH,
|
||||
const dictionary& dict = dictionary::null,
|
||||
const TimeState* ts = nullptr
|
||||
);
|
||||
|
||||
//- Copy construct
|
||||
exprDriver(const exprDriver&);
|
||||
exprDriver(const exprDriver& rhs);
|
||||
|
||||
//- Construct from a dictionary
|
||||
explicit exprDriver(const dictionary& dict);
|
||||
explicit exprDriver
|
||||
(
|
||||
const dictionary& dict,
|
||||
const TimeState* ts = nullptr
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -261,20 +305,30 @@ public:
|
||||
return 1;
|
||||
}
|
||||
|
||||
//- Reference to the current time-state (can be nullptr)
|
||||
const TimeState* timeState() const;
|
||||
|
||||
//- The current time value
|
||||
virtual scalar timeValue() const;
|
||||
|
||||
//- The current deltaT value
|
||||
virtual scalar deltaT() const;
|
||||
|
||||
|
||||
//- The dictionary with all input data/specification
|
||||
const dictionary& dict() const
|
||||
const dictionary& dict() const noexcept
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
//- Const access to expression result
|
||||
virtual const exprResult& result() const
|
||||
const exprResult& result() const noexcept
|
||||
{
|
||||
return result_;
|
||||
}
|
||||
|
||||
//- Non-const access to expression result
|
||||
virtual exprResult& result()
|
||||
exprResult& result() noexcept
|
||||
{
|
||||
return result_;
|
||||
}
|
||||
@ -287,28 +341,28 @@ public:
|
||||
tmp<Field<Type>> getResult(bool wantPointData=false);
|
||||
|
||||
//- The result type as word - same as result().valueType()
|
||||
virtual word getResultType() const
|
||||
const word& getResultType() const noexcept
|
||||
{
|
||||
return result_.valueType();
|
||||
}
|
||||
|
||||
|
||||
// Globals, Mesh Related
|
||||
// Specials
|
||||
|
||||
//- Set special-purpose scalar reference argument.
|
||||
//- Get special-purpose scalar reference argument.
|
||||
// Typically available as \c arg() in an expression and
|
||||
// may corrspond to table index, time value etc.
|
||||
scalar argValue() const;
|
||||
// may correspond to table index, time value etc.
|
||||
inline scalar argValue() const noexcept;
|
||||
|
||||
|
||||
// General Controls
|
||||
|
||||
//- Get "look-behind" parsing context (internal bookkeeping)
|
||||
inline int stashedTokenId() const;
|
||||
inline int stashedTokenId() const noexcept;
|
||||
|
||||
//- Reset "look-behind" parsing context (mutable operation)
|
||||
// \return the previous value
|
||||
inline int resetStashedTokenId(int tokenId=0) const;
|
||||
inline int resetStashedTokenId(int tokenId=0) const noexcept;
|
||||
|
||||
|
||||
//- Set the scanner/parser debug
|
||||
@ -317,26 +371,26 @@ public:
|
||||
//- Set the scanner/parser debug to match the input
|
||||
void setDebugging(const exprDriver& rhs);
|
||||
|
||||
//- Set search behaviour
|
||||
//- Toggle CACHE_READ_FIELDS control
|
||||
bool setCaching(bool on) noexcept;
|
||||
|
||||
//- Set search behaviour,
|
||||
//- with additional CACHE_READ_FIELDS toggle on
|
||||
void setSearchBehaviour
|
||||
(
|
||||
bool cacheReadFields,
|
||||
bool searchInMemory,
|
||||
bool searchFiles
|
||||
enum searchControls search,
|
||||
const bool caching = false
|
||||
);
|
||||
|
||||
//- Set search behaviour to be identical to rhs
|
||||
void setSearchBehaviour(const exprDriver& rhs);
|
||||
|
||||
//- Read access to scanner debug
|
||||
bool debugScanner() const { return debugScanner_; }
|
||||
inline bool debugScanner() const noexcept;
|
||||
|
||||
//- Read access to parser debug
|
||||
bool debugParser() const { return debugParser_; }
|
||||
inline bool debugParser() const noexcept;
|
||||
|
||||
bool cacheReadFields() const { return cacheReadFields_; }
|
||||
bool searchInMemory() const { return searchInMemory_; }
|
||||
bool searchFiles() const { return searchFiles_; }
|
||||
bool prevIterIsOldTime() const { return prevIterIsOldTime_; }
|
||||
|
||||
|
||||
@ -348,7 +402,7 @@ public:
|
||||
//- Set special-purpose scalar reference argument.
|
||||
// Typically available as \c arg() in an expression and
|
||||
// may corrspond to table index, time value etc.
|
||||
virtual void setArgument(const scalar val);
|
||||
inline void setArgument(const scalar val) noexcept;
|
||||
|
||||
//- True if named variable exists
|
||||
inline virtual bool hasVariable(const word& name) const;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "exprDriver.H"
|
||||
#include "FieldOps.H"
|
||||
#include "Random.H"
|
||||
#include "TimeState.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -38,6 +39,18 @@ void Foam::expressions::exprDriver::fill_random
|
||||
const bool gaussian
|
||||
) const
|
||||
{
|
||||
if (seed <= 0)
|
||||
{
|
||||
if (timeStatePtr_)
|
||||
{
|
||||
seed = (timeStatePtr_->timeIndex() - seed);
|
||||
}
|
||||
else
|
||||
{
|
||||
seed = -seed;
|
||||
}
|
||||
}
|
||||
|
||||
if (gaussian)
|
||||
{
|
||||
Random::gaussianGeneratorOp<scalar> gen(seed);
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,18 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::expressions::exprDriver::setArgument(scalar val) noexcept
|
||||
{
|
||||
arg1Value_ = val;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::expressions::exprDriver::argValue() const noexcept
|
||||
{
|
||||
return arg1Value_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprDriver::hasVariable
|
||||
(
|
||||
const word& name
|
||||
@ -101,7 +113,7 @@ inline Type Foam::expressions::exprDriver::evaluateUniform
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline int Foam::expressions::exprDriver::stashedTokenId() const
|
||||
inline int Foam::expressions::exprDriver::stashedTokenId() const noexcept
|
||||
{
|
||||
return stashedTokenId_;
|
||||
}
|
||||
@ -110,12 +122,42 @@ inline int Foam::expressions::exprDriver::stashedTokenId() const
|
||||
inline int Foam::expressions::exprDriver::resetStashedTokenId
|
||||
(
|
||||
int tokenId
|
||||
) const
|
||||
) const noexcept
|
||||
{
|
||||
const int old = stashedTokenId_;
|
||||
int old = stashedTokenId_;
|
||||
stashedTokenId_ = tokenId;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprDriver::debugScanner() const noexcept
|
||||
{
|
||||
return debugScanner_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprDriver::debugParser() const noexcept
|
||||
{
|
||||
return debugParser_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprDriver::searchRegistry() const noexcept
|
||||
{
|
||||
return (searchCtrl_ & searchControls::SEARCH_REGISTRY);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprDriver::searchFiles() const noexcept
|
||||
{
|
||||
return (searchCtrl_ & searchControls::SEARCH_FILES);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::expressions::exprDriver::cacheReadFields() const noexcept
|
||||
{
|
||||
return (searchCtrl_ & searchControls::CACHE_READ_FIELDS);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2010-2018
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,7 +26,25 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class GeoField>
|
||||
Foam::tmp<GeoField>
|
||||
Foam::expressions::exprDriver::cfindFieldObject
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const word& fldName
|
||||
)
|
||||
{
|
||||
tmp<GeoField> tfld;
|
||||
|
||||
tfld.cref(obr.cfindObject<GeoField>(fldName));
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class TableType>
|
||||
bool Foam::expressions::exprDriver::readTable
|
||||
|
||||
@ -388,7 +388,7 @@ public:
|
||||
inline bool hasValue() const;
|
||||
|
||||
//- Basic type for the field or single value
|
||||
inline const word& valueType() const;
|
||||
inline const word& valueType() const noexcept;
|
||||
|
||||
//- True if representing point data,
|
||||
//- or test for same value as wantPointData argument
|
||||
|
||||
@ -240,7 +240,8 @@ inline bool Foam::expressions::exprResult::hasValue() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::word& Foam::expressions::exprResult::valueType() const
|
||||
inline const Foam::word&
|
||||
Foam::expressions::exprResult::valueType() const noexcept
|
||||
{
|
||||
return valType_;
|
||||
}
|
||||
|
||||
@ -49,12 +49,6 @@ defineTypeNameAndDebug(parseDriver, 0);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::expressions::fieldExpr::parseDriver::parseDriver()
|
||||
:
|
||||
parseDriver(1)
|
||||
{}
|
||||
|
||||
|
||||
Foam::expressions::fieldExpr::parseDriver::parseDriver
|
||||
(
|
||||
const label len
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,7 +36,7 @@ Description
|
||||
Functions
|
||||
\table
|
||||
Function | Description | Number of arguments |
|
||||
rand | Random field | 0/1 |
|
||||
rand | Random field | 0/1 |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
@ -98,11 +98,8 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct - uses size = 1
|
||||
parseDriver();
|
||||
|
||||
//- Construct with specified size
|
||||
explicit parseDriver(const label len);
|
||||
//- Default construct (size=1), or with specified size
|
||||
explicit parseDriver(const label len = 1);
|
||||
|
||||
//- Construct for specified size with given dictionary
|
||||
parseDriver(const label len, const dictionary& dict);
|
||||
|
||||
@ -26,66 +26,68 @@
|
||||
#define TOK_DEG_TO_RAD 26
|
||||
#define TOK_RAD_TO_DEG 27
|
||||
#define TOK_ARG 28
|
||||
#define TOK_SCALAR_ID 29
|
||||
#define TOK_MIN 30
|
||||
#define TOK_COMMA 31
|
||||
#define TOK_MAX 32
|
||||
#define TOK_SUM 33
|
||||
#define TOK_AVERAGE 34
|
||||
#define TOK_EXP 35
|
||||
#define TOK_LOG 36
|
||||
#define TOK_LOG10 37
|
||||
#define TOK_SQR 38
|
||||
#define TOK_SQRT 39
|
||||
#define TOK_CBRT 40
|
||||
#define TOK_SIN 41
|
||||
#define TOK_COS 42
|
||||
#define TOK_TAN 43
|
||||
#define TOK_ASIN 44
|
||||
#define TOK_ACOS 45
|
||||
#define TOK_ATAN 46
|
||||
#define TOK_SINH 47
|
||||
#define TOK_COSH 48
|
||||
#define TOK_TANH 49
|
||||
#define TOK_POW 50
|
||||
#define TOK_ATAN2 51
|
||||
#define TOK_POS 52
|
||||
#define TOK_NEG 53
|
||||
#define TOK_POS0 54
|
||||
#define TOK_NEG0 55
|
||||
#define TOK_SIGN 56
|
||||
#define TOK_FLOOR 57
|
||||
#define TOK_CEIL 58
|
||||
#define TOK_ROUND 59
|
||||
#define TOK_HYPOT 60
|
||||
#define TOK_RAND 61
|
||||
#define TOK_VECTOR_ID 62
|
||||
#define TOK_SPH_TENSOR_ID 63
|
||||
#define TOK_SYM_TENSOR_ID 64
|
||||
#define TOK_IDENTITY_TENSOR 65
|
||||
#define TOK_TENSOR_ID 66
|
||||
#define TOK_LTRUE 67
|
||||
#define TOK_LFALSE 68
|
||||
#define TOK_BOOL 69
|
||||
#define TOK_BOOL_ID 70
|
||||
#define TOK_MAG 71
|
||||
#define TOK_MAGSQR 72
|
||||
#define TOK_VECTOR 73
|
||||
#define TOK_TENSOR 74
|
||||
#define TOK_SYM_TENSOR 75
|
||||
#define TOK_SPH_TENSOR 76
|
||||
#define TOK_CMPT_X 77
|
||||
#define TOK_CMPT_Y 78
|
||||
#define TOK_CMPT_Z 79
|
||||
#define TOK_CMPT_XX 80
|
||||
#define TOK_CMPT_XY 81
|
||||
#define TOK_CMPT_XZ 82
|
||||
#define TOK_CMPT_YX 83
|
||||
#define TOK_CMPT_YY 84
|
||||
#define TOK_CMPT_YZ 85
|
||||
#define TOK_CMPT_ZX 86
|
||||
#define TOK_CMPT_ZY 87
|
||||
#define TOK_CMPT_ZZ 88
|
||||
#define TOK_CMPT_II 89
|
||||
#define TOK_TRANSPOSE 90
|
||||
#define TOK_DIAG 91
|
||||
#define TOK_TIME 29
|
||||
#define TOK_DELTA_T 30
|
||||
#define TOK_SCALAR_ID 31
|
||||
#define TOK_MIN 32
|
||||
#define TOK_COMMA 33
|
||||
#define TOK_MAX 34
|
||||
#define TOK_SUM 35
|
||||
#define TOK_AVERAGE 36
|
||||
#define TOK_EXP 37
|
||||
#define TOK_LOG 38
|
||||
#define TOK_LOG10 39
|
||||
#define TOK_SQR 40
|
||||
#define TOK_SQRT 41
|
||||
#define TOK_CBRT 42
|
||||
#define TOK_SIN 43
|
||||
#define TOK_COS 44
|
||||
#define TOK_TAN 45
|
||||
#define TOK_ASIN 46
|
||||
#define TOK_ACOS 47
|
||||
#define TOK_ATAN 48
|
||||
#define TOK_SINH 49
|
||||
#define TOK_COSH 50
|
||||
#define TOK_TANH 51
|
||||
#define TOK_POW 52
|
||||
#define TOK_ATAN2 53
|
||||
#define TOK_POS 54
|
||||
#define TOK_NEG 55
|
||||
#define TOK_POS0 56
|
||||
#define TOK_NEG0 57
|
||||
#define TOK_SIGN 58
|
||||
#define TOK_FLOOR 59
|
||||
#define TOK_CEIL 60
|
||||
#define TOK_ROUND 61
|
||||
#define TOK_HYPOT 62
|
||||
#define TOK_RAND 63
|
||||
#define TOK_VECTOR_ID 64
|
||||
#define TOK_SPH_TENSOR_ID 65
|
||||
#define TOK_SYM_TENSOR_ID 66
|
||||
#define TOK_IDENTITY_TENSOR 67
|
||||
#define TOK_TENSOR_ID 68
|
||||
#define TOK_LTRUE 69
|
||||
#define TOK_LFALSE 70
|
||||
#define TOK_BOOL 71
|
||||
#define TOK_BOOL_ID 72
|
||||
#define TOK_MAG 73
|
||||
#define TOK_MAGSQR 74
|
||||
#define TOK_VECTOR 75
|
||||
#define TOK_TENSOR 76
|
||||
#define TOK_SYM_TENSOR 77
|
||||
#define TOK_SPH_TENSOR 78
|
||||
#define TOK_CMPT_X 79
|
||||
#define TOK_CMPT_Y 80
|
||||
#define TOK_CMPT_Z 81
|
||||
#define TOK_CMPT_XX 82
|
||||
#define TOK_CMPT_XY 83
|
||||
#define TOK_CMPT_XZ 84
|
||||
#define TOK_CMPT_YX 85
|
||||
#define TOK_CMPT_YY 86
|
||||
#define TOK_CMPT_YZ 87
|
||||
#define TOK_CMPT_ZX 88
|
||||
#define TOK_CMPT_ZY 89
|
||||
#define TOK_CMPT_ZZ 90
|
||||
#define TOK_CMPT_II 91
|
||||
#define TOK_TRANSPOSE 92
|
||||
#define TOK_DIAG 93
|
||||
|
||||
@ -166,7 +166,8 @@ svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; }
|
||||
svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); }
|
||||
svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); }
|
||||
svalue (lhs) ::= ARG LPAREN RPAREN . { lhs = driver->argValue(); }
|
||||
dnl svalue (lhs) ::= TIME LPAREN RPAREN . { lhs = driver->timeValue(); }
|
||||
svalue (lhs) ::= TIME LPAREN RPAREN . { lhs = driver->timeValue(); }
|
||||
svalue (lhs) ::= DELTA_T LPAREN RPAREN . { lhs = driver->deltaT(); }
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * Fields * * * * * * * * * * * * * * * * *\
|
||||
|
||||
@ -57,7 +57,7 @@ union scanToken
|
||||
Foam::scalar svalue;
|
||||
Foam::word* name;
|
||||
|
||||
//- Null construct, bit-wise zero for union content
|
||||
//- Default construct, bit-wise zero for union content
|
||||
scanToken() : ivalue(0) {}
|
||||
};
|
||||
|
||||
@ -73,7 +73,7 @@ class scanner
|
||||
//- Wrapped lemon parser
|
||||
parser* parser_;
|
||||
|
||||
// Ragel code state, action
|
||||
//- Ragel code state, action
|
||||
int cs, act;
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, optionally setting debugging
|
||||
//- Default construct, optionally setting debugging
|
||||
explicit scanner(bool withDebug = false)
|
||||
:
|
||||
parser_(nullptr),
|
||||
|
||||
@ -171,7 +171,7 @@ static const int fieldExpr_error = 0;
|
||||
static const int fieldExpr_en_main = 11;
|
||||
|
||||
|
||||
#line 304 "fieldExprScanner.rl"
|
||||
#line 305 "fieldExprScanner.rl"
|
||||
|
||||
|
||||
|
||||
@ -411,7 +411,7 @@ bool Foam::expressions::fieldExpr::scanner::process
|
||||
act = 0;
|
||||
}
|
||||
|
||||
#line 534 "fieldExprScanner.rl"
|
||||
#line 535 "fieldExprScanner.rl"
|
||||
/* ^^^ FSM initialization here ^^^ */;
|
||||
|
||||
|
||||
@ -3385,7 +3385,7 @@ case 10:
|
||||
_out: {}
|
||||
}
|
||||
|
||||
#line 536 "fieldExprScanner.rl"
|
||||
#line 537 "fieldExprScanner.rl"
|
||||
/* ^^^ FSM execution here ^^^ */;
|
||||
|
||||
if (0 == cs)
|
||||
|
||||
@ -212,7 +212,7 @@ static int driverTokenType
|
||||
|
||||
number => emit_number;
|
||||
|
||||
## operators
|
||||
## Operators
|
||||
'!' =>{ EMIT_TOKEN(NOT); };
|
||||
'%' =>{ EMIT_TOKEN(PERCENT); };
|
||||
'(' =>{ EMIT_TOKEN(LPAREN); };
|
||||
@ -292,6 +292,7 @@ static int driverTokenType
|
||||
"tensor::I" =>{ EMIT_TOKEN(IDENTITY_TENSOR); };
|
||||
"arg" =>{ EMIT_TOKEN(ARG); };
|
||||
## "time" =>{ EMIT_TOKEN(TIME); };
|
||||
## "deltaT" =>{ EMIT_TOKEN(DELTA_T); };
|
||||
|
||||
## Identifier (field, etc - error if unknown)
|
||||
## Handle 'bare' names and single/double quoted ones
|
||||
|
||||
@ -6,11 +6,10 @@ divert(-1)dnl
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019 OpenCFD Ltd.
|
||||
# Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GNU General Public
|
||||
# License GPL-3.0 or later <https://www.gnu.org/licenses/gpl-3.0>
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# Description
|
||||
# Field handling m4/lemon macros.
|
||||
@ -47,7 +46,8 @@ divert(-1)dnl
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
define([declare_field],
|
||||
[define([_value_type_]$1, [$3])dnl
|
||||
[dnl
|
||||
define([_value_type_]$1, [$3])dnl
|
||||
define([_new_]$1, [driver->$4<$3>($][1).ptr()])dnl
|
||||
define([_get_]$1, [driver->$5<$3>($][1).ptr()])dnl
|
||||
%type $1 { $2* }])
|
||||
@ -92,11 +92,7 @@ define([rule_get_field],
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
define([rule_driver_select],
|
||||
[$1 (lhs) ::= $2 LPAREN IDENTIFIER (ident) RPAREN .
|
||||
{
|
||||
lhs = driver->$3(make_obj(ident->name)).ptr();
|
||||
}]
|
||||
)
|
||||
[rule_driver_unary_named($1, $2, IDENTIFIER, $3)])
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -129,13 +125,13 @@ define([rule_field_from_value],
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# rule_negate_op(target, valType)
|
||||
# rule_negate_op(target)
|
||||
#
|
||||
# Description
|
||||
# Production rules for field negation
|
||||
#
|
||||
# Example
|
||||
# rule_negate_op(sfield, Foam::scalar)
|
||||
# rule_negate_op(sfield)
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
define([rule_negate_op],
|
||||
@ -167,7 +163,8 @@ define([rule_binary_op],
|
||||
[$1 (lhs) ::= $2 (a) $4 $3 (b) .
|
||||
{
|
||||
lhs = (make_tmp(a) $5 make_tmp(b)).ptr();
|
||||
}])
|
||||
}]
|
||||
)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -263,7 +260,7 @@ define([rule_const_multiply],
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# rule_scalar_divide(out, in1, in2, [valType])
|
||||
# rule_scalar_divide(out, in1, in2, [value_type])
|
||||
#
|
||||
# Description
|
||||
# Production rule for division by scalar operation
|
||||
@ -332,8 +329,8 @@ define([rule_scalar_modulo],
|
||||
# rule_unary_assign(out, in, tok, function)
|
||||
#
|
||||
# Description
|
||||
# Production rule for a unary function, using FieldOps::assign for the
|
||||
# implementation.
|
||||
# Production rule for a unary function,
|
||||
# using FieldOps::assign for the implementation.
|
||||
#
|
||||
# Example
|
||||
# rule_unary_assign(sfield, sfield, FLOOR, Foam::floorOp<Foam::scalar>())
|
||||
@ -353,8 +350,8 @@ define([rule_unary_assign],
|
||||
# rule_binary_assign(out, in1, in2, tok, function)
|
||||
#
|
||||
# Description
|
||||
# Production rule for a binary function, using FieldOps::assign for the
|
||||
# implementation.
|
||||
# Production rule for a binary function,
|
||||
# using FieldOps::assign for the implementation.
|
||||
#
|
||||
# Example
|
||||
# rule_binary_assign(sfield, sfield, sfield, HYPOT, Foam::hypot)
|
||||
@ -374,7 +371,7 @@ define([rule_binary_assign],
|
||||
# rule_driver_nullary(out, tok, func)
|
||||
#
|
||||
# Description
|
||||
# Production rule for driver-specific field reduction
|
||||
# Production rule for driver-specific nullary method.
|
||||
#
|
||||
# Example
|
||||
# rule_driver_nullary(vfield, POS, field_cellCentre)
|
||||
@ -393,10 +390,11 @@ define([rule_driver_nullary],
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# rule_driver_inplace_unary(inOut, tok, func)
|
||||
# rule_driver_inplace_unary(inOut, tok, method)
|
||||
#
|
||||
# Description
|
||||
# Production rule for driver-specific field reduction
|
||||
# Production rule for a driver-specific unary method
|
||||
# modifying the field inplace.
|
||||
#
|
||||
# Example
|
||||
# rule_driver_inplace_unary(sfield, WEIGHTED_AVERAGE, volAverage)
|
||||
@ -416,10 +414,10 @@ define([rule_driver_inplace_unary],
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# rule_driver_unary(out, in, tok, func)
|
||||
# rule_driver_unary(out, in, tok, method, [value_type])
|
||||
#
|
||||
# Description
|
||||
# Production rule for driver-specific field reduction
|
||||
# Production rule for a driver-specific unary method
|
||||
#
|
||||
# Example
|
||||
# rule_driver_unary(sfield, psfield, POINT_TO_CELL, pointToCell)
|
||||
@ -433,7 +431,42 @@ define([rule_driver_inplace_unary],
|
||||
define([rule_driver_unary],
|
||||
[$1 (lhs) ::= $3 LPAREN $2 (a) RPAREN .
|
||||
{
|
||||
lhs = driver->$4(make_obj(a)).ptr();
|
||||
lhs = driver->$4[]dnl # The method call
|
||||
ifelse($5,[],[],[<$5>])dnl # Optional template parameter (value_type)
|
||||
(make_obj(a)).ptr();
|
||||
}]
|
||||
)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# rule_driver_unary_named(out, tok, identType, method, [value_type])
|
||||
#
|
||||
# Description
|
||||
# Production rule for a driver-specific unary method
|
||||
#
|
||||
# Example
|
||||
# rule_driver_unary_named
|
||||
# (
|
||||
# sfield,
|
||||
# SN_GRAD,
|
||||
# SCALAR_ID,
|
||||
# patchNormalField,
|
||||
# Foam::scalar
|
||||
# )
|
||||
#
|
||||
# sfield(lhs) ::= SN_GRAD LPAREN SCALAR_ID (ident) RPAREN .
|
||||
# {
|
||||
# lhs = driver->patchNormalField<Foam::scalar>(make_obj(ident->name)).ptr();
|
||||
# }
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
define([rule_driver_unary_named],
|
||||
[$1 (lhs) ::= $2 LPAREN $3 (ident) RPAREN .
|
||||
{
|
||||
lhs = driver->$4[]dnl # The method call
|
||||
ifelse($5,[],[],[<$5>])dnl # Optional template parameter (value_type)
|
||||
(make_obj(ident->name)).ptr();
|
||||
}]
|
||||
)
|
||||
|
||||
|
||||
@ -269,12 +269,10 @@ fields/volFields/volFields.C
|
||||
fields/surfaceFields/surfaceFields.C
|
||||
|
||||
expr = expressions
|
||||
$(expr)/base/exprDriverWriter.C
|
||||
|
||||
$(expr)/base/fvExprDriver.C
|
||||
$(expr)/base/fvExprDriverFields.C
|
||||
$(expr)/base/fvExprDriverIO.C
|
||||
$(expr)/base/fvExprDriverNew.C
|
||||
$(expr)/base/fvExprDriverWriter.C
|
||||
|
||||
patchExpr = $(expr)/patch
|
||||
$(patchExpr)/patchExpr.C
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,7 +27,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvExprDriver.H"
|
||||
#include "exprDriverWriter.H"
|
||||
#include "fvExprDriverWriter.H"
|
||||
#include "expressionEntry.H"
|
||||
#include "exprResultGlobals.H"
|
||||
|
||||
@ -94,19 +94,12 @@ const Foam::fvMesh* Foam::expressions::fvExprDriver::resetDefaultMesh
|
||||
|
||||
Foam::expressions::fvExprDriver::fvExprDriver
|
||||
(
|
||||
bool cacheReadFields,
|
||||
bool searchInMemory,
|
||||
bool searchFiles,
|
||||
const dictionary& dict
|
||||
enum exprDriver::searchControls search,
|
||||
const dictionary& dict,
|
||||
const TimeState* ts
|
||||
)
|
||||
:
|
||||
expressions::exprDriver
|
||||
(
|
||||
cacheReadFields,
|
||||
searchInMemory,
|
||||
searchFiles,
|
||||
dict
|
||||
),
|
||||
expressions::exprDriver(search, dict, ts),
|
||||
globalScopes_(),
|
||||
delayedVariables_(),
|
||||
storedVariables_(),
|
||||
@ -133,16 +126,17 @@ Foam::expressions::fvExprDriver::fvExprDriver
|
||||
|
||||
Foam::expressions::fvExprDriver::fvExprDriver
|
||||
(
|
||||
const dictionary& dict
|
||||
const dictionary& dict,
|
||||
const TimeState* ts
|
||||
)
|
||||
:
|
||||
fvExprDriver
|
||||
(
|
||||
dict.getOrDefault("cacheReadFields", false),
|
||||
dict.getOrDefault("searchInMemory", true),
|
||||
dict.getOrDefault("searchFiles", false),
|
||||
dict
|
||||
)
|
||||
expressions::exprDriver(dict, ts),
|
||||
globalScopes_(),
|
||||
delayedVariables_(),
|
||||
storedVariables_(),
|
||||
specialVariablesIndex_(-1),
|
||||
otherMeshName_(),
|
||||
writer_(nullptr)
|
||||
{
|
||||
readDict(dict);
|
||||
}
|
||||
@ -168,7 +162,7 @@ bool Foam::expressions::fvExprDriver::readDict
|
||||
// {
|
||||
// for (const fileName& libName : plugins)
|
||||
// {
|
||||
// this->runTime().libs().open
|
||||
// this->mesh().time().libs().open
|
||||
// (
|
||||
// "libswak" + libName + "FunctionPlugin" // verbose = true
|
||||
// );
|
||||
@ -244,24 +238,6 @@ bool Foam::expressions::fvExprDriver::readDict
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::Time& Foam::expressions::fvExprDriver::runTime() const
|
||||
{
|
||||
return this->mesh().time();
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::expressions::fvExprDriver::timeName() const
|
||||
{
|
||||
return runTime().timeName();
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::expressions::fvExprDriver::timeValue() const
|
||||
{
|
||||
return runTime().value();
|
||||
}
|
||||
|
||||
|
||||
void Foam::expressions::fvExprDriver::updateSpecialVariables(bool force)
|
||||
{
|
||||
const bool updated = this->update();
|
||||
@ -594,7 +570,7 @@ Foam::word Foam::expressions::fvExprDriver::getFieldClassName
|
||||
const word& name
|
||||
) const
|
||||
{
|
||||
if (searchInMemory())
|
||||
if (searchRegistry())
|
||||
{
|
||||
const regIOobject* ioptr = this->mesh().findObject<regIOobject>(name);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,7 +53,6 @@ Description
|
||||
SourceFiles
|
||||
fvExprDriverI.H
|
||||
fvExprDriver.C
|
||||
fvExprDriverFields.C
|
||||
fvExprDriverIO.C
|
||||
fvExprDriverNew.C
|
||||
fvExprDriverTemplates.C
|
||||
@ -79,7 +78,7 @@ namespace expressions
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class exprDriverWriter;
|
||||
class fvExprDriverWriter;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvExprDriver Declaration
|
||||
@ -118,7 +117,7 @@ class fvExprDriver
|
||||
word otherMeshName_;
|
||||
|
||||
//- Writing and restoring
|
||||
autoPtr<exprDriverWriter> writer_;
|
||||
autoPtr<fvExprDriverWriter> writer_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -268,19 +267,6 @@ protected:
|
||||
const MeshRef& meshRef
|
||||
);
|
||||
|
||||
//- Create a random field
|
||||
//
|
||||
// \param field the field to populate
|
||||
// \param seed the seed value. If zero or negative, use as an offset
|
||||
// to the current timeIndex
|
||||
// \param gaussian generate a Gaussian distribution
|
||||
void fill_random
|
||||
(
|
||||
scalarField& field,
|
||||
label seed = 0,
|
||||
const bool gaussian = false
|
||||
) const;
|
||||
|
||||
|
||||
// Sets
|
||||
|
||||
@ -325,7 +311,7 @@ protected:
|
||||
public:
|
||||
|
||||
// Friends
|
||||
friend class exprDriverWriter;
|
||||
friend class fvExprDriverWriter;
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
@ -374,20 +360,24 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor, and null construct with search preferences
|
||||
//- Default construct, and default construct with search preferences
|
||||
explicit fvExprDriver
|
||||
(
|
||||
bool cacheReadFields = false,
|
||||
bool searchInMemory = true,
|
||||
bool searchFiles = false,
|
||||
const dictionary& dict = dictionary::null
|
||||
enum exprDriver::searchControls search =
|
||||
exprDriver::searchControls::DEFAULT_SEARCH,
|
||||
const dictionary& dict = dictionary::null,
|
||||
const TimeState* ts = nullptr
|
||||
);
|
||||
|
||||
//- Copy construct
|
||||
fvExprDriver(const fvExprDriver&);
|
||||
|
||||
//- Construct from a dictionary
|
||||
explicit fvExprDriver(const dictionary& dict);
|
||||
explicit fvExprDriver
|
||||
(
|
||||
const dictionary& dict,
|
||||
const TimeState* ts = nullptr
|
||||
);
|
||||
|
||||
|
||||
//- Return a reference to the selected value driver
|
||||
@ -428,18 +418,6 @@ public:
|
||||
virtual label pointSize() const = 0;
|
||||
|
||||
|
||||
// Globals, Mesh Related
|
||||
|
||||
//- The Time associated with the mesh
|
||||
const Time& runTime() const;
|
||||
|
||||
//- The current time name
|
||||
virtual word timeName() const;
|
||||
|
||||
//- The current time value
|
||||
virtual scalar timeValue() const;
|
||||
|
||||
|
||||
// General Controls
|
||||
|
||||
//- Status of cache-sets (static variable)
|
||||
|
||||
@ -1,49 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvExprDriver.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::expressions::fvExprDriver::fill_random
|
||||
(
|
||||
scalarField& field,
|
||||
label seed,
|
||||
const bool gaussian
|
||||
) const
|
||||
{
|
||||
exprDriver::fill_random
|
||||
(
|
||||
field, (seed <= 0 ? (runTime().timeIndex() - seed) : seed),
|
||||
gaussian
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,7 +27,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvExprDriver.H"
|
||||
#include "exprDriverWriter.H"
|
||||
#include "fvExprDriverWriter.H"
|
||||
#include "cellSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
@ -263,7 +263,7 @@ void Foam::expressions::fvExprDriver::createWriterAndRead(const word& name)
|
||||
{
|
||||
if (!writer_ && hasDataToWrite())
|
||||
{
|
||||
writer_.reset(new exprDriverWriter(name + "_" + this->type(), *this));
|
||||
writer_.reset(new fvExprDriverWriter(name + "_" + this->type(), *this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,6 +29,7 @@ License
|
||||
#include "surfaceMesh.H"
|
||||
#include "fvsPatchField.H"
|
||||
#include "pointPatchField.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -141,16 +142,16 @@ bool Foam::expressions::fvExprDriver::foundField
|
||||
{
|
||||
Info<< "fvExprDriver::foundField. Name: " << name
|
||||
<< " Type: " << Type::typeName
|
||||
<< " registry:" << searchInMemory()
|
||||
<< " registry:" << searchRegistry()
|
||||
<< " disk:" << searchFiles() << endl;
|
||||
}
|
||||
|
||||
// if (std::is_void<Type>::value) ...
|
||||
|
||||
if (searchInMemory())
|
||||
if (searchRegistry())
|
||||
{
|
||||
const regIOobject* ioptr =
|
||||
this->mesh().findObject<regIOobject>(name);
|
||||
this->mesh().cfindObject<regIOobject>(name);
|
||||
|
||||
if (this->mesh().foundObject<Type>(name))
|
||||
{
|
||||
@ -332,7 +333,7 @@ Foam::tmp<GeomField> Foam::expressions::fvExprDriver::getOrReadFieldImpl
|
||||
|
||||
if
|
||||
(
|
||||
searchInMemory()
|
||||
searchRegistry()
|
||||
&& (origFldPtr = obr.cfindObject<GeomField>(name)) != nullptr
|
||||
)
|
||||
{
|
||||
@ -494,7 +495,7 @@ Foam::autoPtr<T> Foam::expressions::fvExprDriver::getTopoSet
|
||||
}
|
||||
else
|
||||
{
|
||||
const T* ptr = mesh.thisDb().findObject<T>(name);
|
||||
const T* ptr = mesh.thisDb().cfindObject<T>(name);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
@ -534,7 +535,7 @@ bool Foam::expressions::fvExprDriver::updateSet
|
||||
const label oldSize = setPtr->size();
|
||||
|
||||
bool updated = false;
|
||||
const polyMesh& mesh = dynamic_cast<const polyMesh&>(setPtr->db());
|
||||
const auto& mesh = dynamicCast<const polyMesh>(setPtr->db());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -582,7 +583,7 @@ bool Foam::expressions::fvExprDriver::updateSet
|
||||
|
||||
word sName = name;
|
||||
|
||||
const T* ptr = mesh.thisDb().findObject<T>(name);
|
||||
const T* ptr = mesh.thisDb().template cfindObject<T>(name);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,7 +26,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "exprDriverWriter.H"
|
||||
#include "fvExprDriverWriter.H"
|
||||
#include "fvExprDriver.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -36,7 +36,7 @@ namespace Foam
|
||||
namespace expressions
|
||||
{
|
||||
|
||||
defineTypeName(exprDriverWriter);
|
||||
defineTypeName(fvExprDriverWriter);
|
||||
|
||||
} // namespace expressions
|
||||
} // namespace Foam
|
||||
@ -44,7 +44,7 @@ namespace expressions
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::expressions::exprDriverWriter::exprDriverWriter
|
||||
Foam::expressions::fvExprDriverWriter::fvExprDriverWriter
|
||||
(
|
||||
const word& name,
|
||||
fvExprDriver& driver
|
||||
@ -66,14 +66,14 @@ Foam::expressions::exprDriverWriter::exprDriverWriter
|
||||
{
|
||||
if (headerOk())
|
||||
{
|
||||
readData(readStream("exprDriverWriter", true));
|
||||
readData(readStream("fvExprDriverWriter", true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::expressions::exprDriverWriter::readData(Istream& is)
|
||||
bool Foam::expressions::fvExprDriverWriter::readData(Istream& is)
|
||||
{
|
||||
dictionary dict(is);
|
||||
|
||||
@ -85,7 +85,7 @@ bool Foam::expressions::exprDriverWriter::readData(Istream& is)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::expressions::exprDriverWriter::writeData(Ostream& os) const
|
||||
bool Foam::expressions::fvExprDriverWriter::writeData(Ostream& os) const
|
||||
{
|
||||
// driver_.writeDict(os);
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2011-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,18 +25,18 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::expressions::exprDriverWriter
|
||||
Foam::expressions::fvExprDriverWriter
|
||||
|
||||
Description
|
||||
Registered input/output for an expressions::fvExprDriver
|
||||
|
||||
SourceFiles
|
||||
exprDriverWriter.C
|
||||
fvExprDriverWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef expressions_exprDriverWriter_H
|
||||
#define expressions_exprDriverWriter_H
|
||||
#ifndef expressions_fvExprDriverWriter_H
|
||||
#define expressions_fvExprDriverWriter_H
|
||||
|
||||
#include "fvExprDriver.H"
|
||||
#include "regIOobject.H"
|
||||
@ -49,10 +49,10 @@ namespace expressions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class exprDriverWriter Declaration
|
||||
Class fvExprDriverWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class exprDriverWriter
|
||||
class fvExprDriverWriter
|
||||
:
|
||||
public regIOobject
|
||||
{
|
||||
@ -64,30 +64,30 @@ class exprDriverWriter
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No null constructor
|
||||
exprDriverWriter() = delete;
|
||||
//- No default construct
|
||||
fvExprDriverWriter() = delete;
|
||||
|
||||
//- No copy construct
|
||||
exprDriverWriter(const exprDriverWriter&) = delete;
|
||||
fvExprDriverWriter(const fvExprDriverWriter&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const exprDriverWriter&) = delete;
|
||||
void operator=(const fvExprDriverWriter&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeNameNoDebug("exprDriverWriter");
|
||||
TypeNameNoDebug("fvExprDriverWriter");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for named driver
|
||||
exprDriverWriter(const word& name, fvExprDriver& driver);
|
||||
fvExprDriverWriter(const word& name, fvExprDriver& driver);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~exprDriverWriter() = default;
|
||||
virtual ~fvExprDriverWriter() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -69,14 +69,23 @@ addNamedToRunTimeSelectionTable
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
static inline const fvPatch& lookupFvPatch
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& patchName
|
||||
)
|
||||
{
|
||||
return mesh.boundary()[patchName];
|
||||
}
|
||||
|
||||
static inline const TimeState* lookupTimeState
|
||||
(
|
||||
const fvPatch& p
|
||||
)
|
||||
{
|
||||
return &static_cast<const TimeState&>(p.boundaryMesh().mesh().time());
|
||||
}
|
||||
|
||||
static inline const fvPatch& lookupFvPatch
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& patchName
|
||||
)
|
||||
{
|
||||
return mesh.boundary()[patchName];
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -99,14 +108,6 @@ const Foam::fvPatch& Foam::expressions::patchExpr::parseDriver::getFvPatch
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::expressions::patchExpr::parseDriver::parseDriver(const fvPatch& p)
|
||||
:
|
||||
parsing::genericRagelLemonDriver(),
|
||||
expressions::fvExprDriver(),
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::expressions::patchExpr::parseDriver::parseDriver
|
||||
(
|
||||
const fvPatch& p,
|
||||
@ -114,7 +115,7 @@ Foam::expressions::patchExpr::parseDriver::parseDriver
|
||||
)
|
||||
:
|
||||
parsing::genericRagelLemonDriver(),
|
||||
expressions::fvExprDriver(dict),
|
||||
expressions::fvExprDriver(dict, lookupTimeState(p)),
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
@ -122,11 +123,11 @@ Foam::expressions::patchExpr::parseDriver::parseDriver
|
||||
Foam::expressions::patchExpr::parseDriver::parseDriver
|
||||
(
|
||||
const fvPatch& p,
|
||||
const parseDriver& driver_
|
||||
const parseDriver& rhs
|
||||
)
|
||||
:
|
||||
parsing::genericRagelLemonDriver(),
|
||||
expressions::fvExprDriver(driver_),
|
||||
expressions::fvExprDriver(rhs),
|
||||
patch_(p)
|
||||
{}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,6 +46,9 @@ Description
|
||||
faceToPoint | Interpolate face values onto points | 1 |
|
||||
pointToFace | Interpolate point values onto faces | 1 |
|
||||
rand | Random field | 0/1 |
|
||||
snGrad | Surface normal field | 0 |
|
||||
internalField | Internal field next to patch | 0 |
|
||||
neighbourField | patch field on opposite side of coupled patch | 0 |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
@ -120,14 +123,15 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for specified patch
|
||||
explicit parseDriver(const fvPatch& p);
|
||||
|
||||
//- Construct for specified patch with given dictionary
|
||||
parseDriver(const fvPatch& p, const dictionary& dict);
|
||||
//- Construct for specified patch, with dictionary information
|
||||
explicit parseDriver
|
||||
(
|
||||
const fvPatch& p,
|
||||
const dictionary& dict = dictionary::null
|
||||
);
|
||||
|
||||
//- Construct for specified patch with copy of driver context
|
||||
parseDriver(const fvPatch& p, const parseDriver& driver_);
|
||||
parseDriver(const fvPatch& p, const parseDriver& driver);
|
||||
|
||||
//- Construct with patchName for the given mesh
|
||||
parseDriver(const word& patchName, const fvMesh& mesh);
|
||||
@ -136,6 +140,7 @@ public:
|
||||
//- specified in dictionary
|
||||
parseDriver(const dictionary& dict, const fvMesh& mesh);
|
||||
|
||||
|
||||
//- Clone
|
||||
virtual autoPtr<expressions::fvExprDriver> clone() const
|
||||
{
|
||||
@ -189,9 +194,7 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Field Information
|
||||
|
||||
// Fields
|
||||
// General
|
||||
|
||||
//- Set result
|
||||
template<class Type>
|
||||
@ -206,25 +209,37 @@ public:
|
||||
template<class Type>
|
||||
tmp<Field<Type>> getVariableIfAvailable(const word& fldName) const;
|
||||
|
||||
//- Retrieve field (vol field)
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
getVolField(const word& fldName);
|
||||
|
||||
//- Retrieve field (surface field)
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
getSurfaceField(const word& fldName);
|
||||
|
||||
//- Retrieve field (point field)
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
getPointField(const word& fldName);
|
||||
// Field Retrieval
|
||||
|
||||
//- Return named field
|
||||
template<class Type>
|
||||
tmp<Field<Type>> getField(const word& fldName);
|
||||
|
||||
//- Retrieve field (vol field)
|
||||
template<class Type>
|
||||
tmp<Field<Type>> getVolField(const word& fldName);
|
||||
|
||||
//- Retrieve field (surface field)
|
||||
template<class Type>
|
||||
tmp<Field<Type>> getSurfaceField(const word& fldName);
|
||||
|
||||
//- Retrieve field (point field)
|
||||
template<class Type>
|
||||
tmp<Field<Type>> getPointField(const word& fldName);
|
||||
|
||||
//- Return internal field next to patch
|
||||
template<class Type>
|
||||
tmp<Field<Type>> patchInternalField(const word& fldName);
|
||||
|
||||
//- Return patchField on the opposite patch of a coupled patch
|
||||
template<class Type>
|
||||
tmp<Field<Type>> patchNeighbourField(const word& fldName);
|
||||
|
||||
//- Return surface normal field (snGrad)
|
||||
template<class Type>
|
||||
tmp<Field<Type>> patchNormalField(const word& fldName);
|
||||
|
||||
|
||||
// Field "shape" conversions
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -90,10 +90,11 @@ Foam::expressions::patchExpr::parseDriver::field_rand
|
||||
bool gaussian
|
||||
) const
|
||||
{
|
||||
auto tresult = tmp<scalarField>::New(this->size());
|
||||
fill_random(tresult.ref(), seed, gaussian);
|
||||
auto tfld = tmp<scalarField>::New(this->size());
|
||||
|
||||
return tresult;
|
||||
exprDriver::fill_random(tfld.ref(), seed, gaussian);
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -114,80 +114,313 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
|
||||
return tfield;
|
||||
}
|
||||
|
||||
const objectRegistry& obr = this->mesh().thisDb();
|
||||
const label patchIndex = patch_.index();
|
||||
|
||||
|
||||
// Field types
|
||||
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfieldType;
|
||||
typedef GeometricField<Type, pointPatchField, pointMesh> pfieldType;
|
||||
|
||||
const objectRegistry& obr = this->mesh().thisDb();
|
||||
// Local, temporary storage and/or lookup values
|
||||
bool findField = true;
|
||||
tmp<vfieldType> vfield;
|
||||
tmp<sfieldType> sfield;
|
||||
tmp<pfieldType> pfield;
|
||||
|
||||
const vfieldType* vfield = obr.findObject<vfieldType>(name);
|
||||
const sfieldType* sfield = obr.findObject<sfieldType>(name);
|
||||
const pfieldType* pfield = obr.findObject<pfieldType>(name);
|
||||
if (findField)
|
||||
{
|
||||
vfield = exprDriver::cfindFieldObject<vfieldType>(obr, name);
|
||||
findField = !vfield.valid();
|
||||
}
|
||||
if (findField)
|
||||
{
|
||||
sfield = exprDriver::cfindFieldObject<sfieldType>(obr, name);
|
||||
findField = !sfield.valid();
|
||||
}
|
||||
if (findField)
|
||||
{
|
||||
pfield = exprDriver::cfindFieldObject<pfieldType>(obr, name);
|
||||
findField = !pfield.valid();
|
||||
}
|
||||
|
||||
// Local, temporary storage
|
||||
tmp<vfieldType> t_vfield;
|
||||
tmp<sfieldType> t_sfield;
|
||||
tmp<pfieldType> t_pfield;
|
||||
|
||||
if (searchFiles() && !vfield && !sfield && !pfield)
|
||||
if (findField && searchFiles())
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
{
|
||||
t_vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
vfield = t_vfield.get();
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
}
|
||||
else if (fldType == sfieldType::typeName)
|
||||
{
|
||||
t_sfield = this->readAndRegister<sfieldType>(name, mesh());
|
||||
sfield = t_sfield.get();
|
||||
sfield = this->readAndRegister<sfieldType>(name, mesh());
|
||||
}
|
||||
else if (fldType == pfieldType::typeName)
|
||||
{
|
||||
t_pfield = this->readAndRegister<pfieldType>
|
||||
pfield = this->readAndRegister<pfieldType>
|
||||
(
|
||||
name,
|
||||
pointMesh::New(mesh())
|
||||
);
|
||||
pfield = t_pfield.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const label patchIndex = patch_.index();
|
||||
|
||||
if (vfield)
|
||||
if (vfield.valid())
|
||||
{
|
||||
return tmp<Field<Type>>::New
|
||||
(
|
||||
vfield->boundaryField()[patchIndex]
|
||||
vfield().boundaryField()[patchIndex]
|
||||
);
|
||||
}
|
||||
|
||||
if (sfield)
|
||||
if (sfield.valid())
|
||||
{
|
||||
return tmp<Field<Type>>::New
|
||||
(
|
||||
sfield->boundaryField()[patchIndex]
|
||||
sfield().boundaryField()[patchIndex]
|
||||
);
|
||||
}
|
||||
|
||||
if (pfield)
|
||||
if (pfield.valid())
|
||||
{
|
||||
return pfield->boundaryField()[patchIndex].patchInternalField();
|
||||
return pfield().boundaryField()[patchIndex].patchInternalField();
|
||||
}
|
||||
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "No field '" << name << "' of type "
|
||||
<< pTraits<Type>::typeName << nl << nl
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< sfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<sfieldType>()) << nl
|
||||
<< flatOutput(obr.sortedNames<sfieldType>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< pfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<pfieldType>()) << nl
|
||||
<< flatOutput(obr.sortedNames<pfieldType>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<Field<Type>>::New();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::expressions::patchExpr::parseDriver::patchInternalField
|
||||
(
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tfield = getVariableIfAvailable<Type>(name);
|
||||
|
||||
if (tfield.valid())
|
||||
{
|
||||
return tfield;
|
||||
}
|
||||
|
||||
const objectRegistry& obr = this->mesh().thisDb();
|
||||
const label patchIndex = patch_.index();
|
||||
|
||||
|
||||
// Field types
|
||||
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
|
||||
typedef GeometricField<Type, pointPatchField, pointMesh> pfieldType;
|
||||
|
||||
// Local, temporary storage and/or lookup values
|
||||
bool findField = true;
|
||||
tmp<vfieldType> vfield;
|
||||
tmp<pfieldType> pfield;
|
||||
|
||||
if (findField)
|
||||
{
|
||||
vfield = exprDriver::cfindFieldObject<vfieldType>(obr, name);
|
||||
findField = !vfield.valid();
|
||||
}
|
||||
if (findField)
|
||||
{
|
||||
pfield = exprDriver::cfindFieldObject<pfieldType>(obr, name);
|
||||
findField = !pfield.valid();
|
||||
}
|
||||
|
||||
if (findField && searchFiles())
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
{
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
}
|
||||
else if (fldType == pfieldType::typeName)
|
||||
{
|
||||
pfield = this->readAndRegister<pfieldType>
|
||||
(
|
||||
name,
|
||||
pointMesh::New(mesh())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (vfield.valid())
|
||||
{
|
||||
return vfield().boundaryField()[patchIndex].patchInternalField();
|
||||
}
|
||||
if (pfield.valid())
|
||||
{
|
||||
return pfield().boundaryField()[patchIndex].patchInternalField();
|
||||
}
|
||||
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "No field '" << name << "' of type "
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< pfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<pfieldType>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<Field<Type>>::New();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::expressions::patchExpr::parseDriver::patchNeighbourField
|
||||
(
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tfield = getVariableIfAvailable<Type>(name);
|
||||
|
||||
if (tfield.valid())
|
||||
{
|
||||
return tfield;
|
||||
}
|
||||
|
||||
const objectRegistry& obr = this->mesh().thisDb();
|
||||
const label patchIndex = patch_.index();
|
||||
|
||||
|
||||
// Field types
|
||||
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
|
||||
|
||||
// Local, temporary storage and/or lookup values
|
||||
bool findField = true;
|
||||
tmp<vfieldType> vfield;
|
||||
|
||||
if (findField)
|
||||
{
|
||||
vfield = exprDriver::cfindFieldObject<vfieldType>(obr, name);
|
||||
findField = !vfield.valid();
|
||||
}
|
||||
|
||||
if (findField && searchFiles())
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
{
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (vfield.valid())
|
||||
{
|
||||
return vfield().boundaryField()[patchIndex].patchNeighbourField();
|
||||
}
|
||||
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "No field '" << name << "' of type "
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<Field<Type>>::New();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::expressions::patchExpr::parseDriver::patchNormalField
|
||||
(
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tfield = getVariableIfAvailable<Type>(name);
|
||||
|
||||
if (tfield.valid())
|
||||
{
|
||||
return tfield;
|
||||
}
|
||||
|
||||
const objectRegistry& obr = this->mesh().thisDb();
|
||||
const label patchIndex = patch_.index();
|
||||
|
||||
|
||||
// Field types
|
||||
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
|
||||
|
||||
// Local, temporary storage and/or lookup values
|
||||
tmp<vfieldType> vfield;
|
||||
bool findField = true;
|
||||
|
||||
if (findField)
|
||||
{
|
||||
vfield = exprDriver::cfindFieldObject<vfieldType>(obr, name);
|
||||
findField = !vfield.valid();
|
||||
}
|
||||
|
||||
if (findField && searchFiles())
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
{
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (vfield.valid())
|
||||
{
|
||||
return vfield().boundaryField()[patchIndex].snGrad();
|
||||
}
|
||||
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "No field '" << name << "' of type "
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<Field<Type>>::New();
|
||||
@ -203,7 +436,7 @@ Foam::expressions::patchExpr::parseDriver::faceToPoint
|
||||
{
|
||||
primitivePatchInterpolation interp(patch_.patch());
|
||||
|
||||
return interp.pointToFaceInterpolate(field);
|
||||
return interp.faceToPointInterpolate(field);
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +449,7 @@ Foam::expressions::patchExpr::parseDriver::pointToFace
|
||||
{
|
||||
primitivePatchInterpolation interp(patch_.patch());
|
||||
|
||||
return interp.faceToPointInterpolate(field);
|
||||
return interp.pointToFaceInterpolate(field);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,85 +27,89 @@
|
||||
#define TOK_RAD_TO_DEG 27
|
||||
#define TOK_ARG 28
|
||||
#define TOK_TIME 29
|
||||
#define TOK_SCALAR_ID 30
|
||||
#define TOK_SSCALAR_ID 31
|
||||
#define TOK_MIN 32
|
||||
#define TOK_COMMA 33
|
||||
#define TOK_MAX 34
|
||||
#define TOK_SUM 35
|
||||
#define TOK_AVERAGE 36
|
||||
#define TOK_EXP 37
|
||||
#define TOK_LOG 38
|
||||
#define TOK_LOG10 39
|
||||
#define TOK_SQR 40
|
||||
#define TOK_SQRT 41
|
||||
#define TOK_CBRT 42
|
||||
#define TOK_SIN 43
|
||||
#define TOK_COS 44
|
||||
#define TOK_TAN 45
|
||||
#define TOK_ASIN 46
|
||||
#define TOK_ACOS 47
|
||||
#define TOK_ATAN 48
|
||||
#define TOK_SINH 49
|
||||
#define TOK_COSH 50
|
||||
#define TOK_TANH 51
|
||||
#define TOK_POW 52
|
||||
#define TOK_ATAN2 53
|
||||
#define TOK_POS 54
|
||||
#define TOK_NEG 55
|
||||
#define TOK_POS0 56
|
||||
#define TOK_NEG0 57
|
||||
#define TOK_SIGN 58
|
||||
#define TOK_FLOOR 59
|
||||
#define TOK_CEIL 60
|
||||
#define TOK_ROUND 61
|
||||
#define TOK_HYPOT 62
|
||||
#define TOK_RAND 63
|
||||
#define TOK_VECTOR_ID 64
|
||||
#define TOK_SVECTOR_ID 65
|
||||
#define TOK_SPH_TENSOR_ID 66
|
||||
#define TOK_SSPH_TENSOR_ID 67
|
||||
#define TOK_SYM_TENSOR_ID 68
|
||||
#define TOK_SSYM_TENSOR_ID 69
|
||||
#define TOK_IDENTITY_TENSOR 70
|
||||
#define TOK_TENSOR_ID 71
|
||||
#define TOK_STENSOR_ID 72
|
||||
#define TOK_LTRUE 73
|
||||
#define TOK_LFALSE 74
|
||||
#define TOK_BOOL 75
|
||||
#define TOK_SBOOL_ID 76
|
||||
#define TOK_FACE_AREA 77
|
||||
#define TOK_FACE_EXPR 78
|
||||
#define TOK_WEIGHT_AVERAGE 79
|
||||
#define TOK_WEIGHT_SUM 80
|
||||
#define TOK_POINT_EXPR 81
|
||||
#define TOK_PSCALAR_ID 82
|
||||
#define TOK_PVECTOR_ID 83
|
||||
#define TOK_PSPH_TENSOR_ID 84
|
||||
#define TOK_PSYM_TENSOR_ID 85
|
||||
#define TOK_PTENSOR_ID 86
|
||||
#define TOK_PBOOL_ID 87
|
||||
#define TOK_POINTS 88
|
||||
#define TOK_MAG 89
|
||||
#define TOK_MAGSQR 90
|
||||
#define TOK_VECTOR 91
|
||||
#define TOK_TENSOR 92
|
||||
#define TOK_SYM_TENSOR 93
|
||||
#define TOK_SPH_TENSOR 94
|
||||
#define TOK_CMPT_X 95
|
||||
#define TOK_CMPT_Y 96
|
||||
#define TOK_CMPT_Z 97
|
||||
#define TOK_CMPT_XX 98
|
||||
#define TOK_CMPT_XY 99
|
||||
#define TOK_CMPT_XZ 100
|
||||
#define TOK_CMPT_YX 101
|
||||
#define TOK_CMPT_YY 102
|
||||
#define TOK_CMPT_YZ 103
|
||||
#define TOK_CMPT_ZX 104
|
||||
#define TOK_CMPT_ZY 105
|
||||
#define TOK_CMPT_ZZ 106
|
||||
#define TOK_CMPT_II 107
|
||||
#define TOK_TRANSPOSE 108
|
||||
#define TOK_DIAG 109
|
||||
#define TOK_POINT_TO_FACE 110
|
||||
#define TOK_FACE_TO_POINT 111
|
||||
#define TOK_DELTA_T 30
|
||||
#define TOK_SCALAR_ID 31
|
||||
#define TOK_SSCALAR_ID 32
|
||||
#define TOK_INTERNAL_FIELD 33
|
||||
#define TOK_NEIGHBOUR_FIELD 34
|
||||
#define TOK_SN_GRAD 35
|
||||
#define TOK_MIN 36
|
||||
#define TOK_COMMA 37
|
||||
#define TOK_MAX 38
|
||||
#define TOK_SUM 39
|
||||
#define TOK_AVERAGE 40
|
||||
#define TOK_EXP 41
|
||||
#define TOK_LOG 42
|
||||
#define TOK_LOG10 43
|
||||
#define TOK_SQR 44
|
||||
#define TOK_SQRT 45
|
||||
#define TOK_CBRT 46
|
||||
#define TOK_SIN 47
|
||||
#define TOK_COS 48
|
||||
#define TOK_TAN 49
|
||||
#define TOK_ASIN 50
|
||||
#define TOK_ACOS 51
|
||||
#define TOK_ATAN 52
|
||||
#define TOK_SINH 53
|
||||
#define TOK_COSH 54
|
||||
#define TOK_TANH 55
|
||||
#define TOK_POW 56
|
||||
#define TOK_ATAN2 57
|
||||
#define TOK_POS 58
|
||||
#define TOK_NEG 59
|
||||
#define TOK_POS0 60
|
||||
#define TOK_NEG0 61
|
||||
#define TOK_SIGN 62
|
||||
#define TOK_FLOOR 63
|
||||
#define TOK_CEIL 64
|
||||
#define TOK_ROUND 65
|
||||
#define TOK_HYPOT 66
|
||||
#define TOK_RAND 67
|
||||
#define TOK_VECTOR_ID 68
|
||||
#define TOK_SVECTOR_ID 69
|
||||
#define TOK_SPH_TENSOR_ID 70
|
||||
#define TOK_SSPH_TENSOR_ID 71
|
||||
#define TOK_SYM_TENSOR_ID 72
|
||||
#define TOK_SSYM_TENSOR_ID 73
|
||||
#define TOK_IDENTITY_TENSOR 74
|
||||
#define TOK_TENSOR_ID 75
|
||||
#define TOK_STENSOR_ID 76
|
||||
#define TOK_LTRUE 77
|
||||
#define TOK_LFALSE 78
|
||||
#define TOK_BOOL 79
|
||||
#define TOK_SBOOL_ID 80
|
||||
#define TOK_FACE_AREA 81
|
||||
#define TOK_FACE_EXPR 82
|
||||
#define TOK_WEIGHT_AVERAGE 83
|
||||
#define TOK_WEIGHT_SUM 84
|
||||
#define TOK_POINT_EXPR 85
|
||||
#define TOK_PSCALAR_ID 86
|
||||
#define TOK_PVECTOR_ID 87
|
||||
#define TOK_PSPH_TENSOR_ID 88
|
||||
#define TOK_PSYM_TENSOR_ID 89
|
||||
#define TOK_PTENSOR_ID 90
|
||||
#define TOK_PBOOL_ID 91
|
||||
#define TOK_POINTS 92
|
||||
#define TOK_MAG 93
|
||||
#define TOK_MAGSQR 94
|
||||
#define TOK_VECTOR 95
|
||||
#define TOK_TENSOR 96
|
||||
#define TOK_SYM_TENSOR 97
|
||||
#define TOK_SPH_TENSOR 98
|
||||
#define TOK_CMPT_X 99
|
||||
#define TOK_CMPT_Y 100
|
||||
#define TOK_CMPT_Z 101
|
||||
#define TOK_CMPT_XX 102
|
||||
#define TOK_CMPT_XY 103
|
||||
#define TOK_CMPT_XZ 104
|
||||
#define TOK_CMPT_YX 105
|
||||
#define TOK_CMPT_YY 106
|
||||
#define TOK_CMPT_YZ 107
|
||||
#define TOK_CMPT_ZX 108
|
||||
#define TOK_CMPT_ZY 109
|
||||
#define TOK_CMPT_ZZ 110
|
||||
#define TOK_CMPT_II 111
|
||||
#define TOK_TRANSPOSE 112
|
||||
#define TOK_DIAG 113
|
||||
#define TOK_POINT_TO_FACE 114
|
||||
#define TOK_FACE_TO_POINT 115
|
||||
|
||||
@ -121,6 +121,7 @@ svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); }
|
||||
svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); }
|
||||
svalue (lhs) ::= ARG LPAREN RPAREN . { lhs = driver->argValue(); }
|
||||
svalue (lhs) ::= TIME LPAREN RPAREN . { lhs = driver->timeValue(); }
|
||||
svalue (lhs) ::= DELTA_T LPAREN RPAREN . { lhs = driver->deltaT(); }
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * Face Fields * * * * * * * * * * * * * * * *\
|
||||
@ -147,6 +148,7 @@ evaluate ::= _target_ (a) . { driver->setResult(a); }
|
||||
rule_field_from_value(_target_, svalue)
|
||||
rule_get_field(_target_, SCALAR_ID)
|
||||
rule_get_field(_target_, SSCALAR_ID)
|
||||
rule_get_patchfields(_target_, _value_type_, SCALAR_ID)
|
||||
|
||||
rules_standard(_target_, _value_type_, _logic_)
|
||||
rules_inplace_gUnary(_target_)
|
||||
@ -188,6 +190,7 @@ evaluate ::= _target_ (a) . { driver->setResult(a); }
|
||||
|
||||
rule_get_field(_target_, VECTOR_ID)
|
||||
rule_get_field(_target_, SVECTOR_ID)
|
||||
rule_get_patchfields(_target_, _value_type_, VECTOR_ID)
|
||||
|
||||
rules_standard(_target_, _value_type_, _logic_)
|
||||
rules_inplace_gUnary(_target_)
|
||||
@ -207,6 +210,7 @@ evaluate ::= _target_ (a) . { driver->setResult(a); }
|
||||
|
||||
rule_get_field(_target_, SPH_TENSOR_ID)
|
||||
rule_get_field(_target_, SSPH_TENSOR_ID)
|
||||
rule_get_patchfields(_target_, _value_type_, SPH_TENSOR_ID)
|
||||
|
||||
rules_standard(_target_, _value_type_, _logic_)
|
||||
rules_inplace_gUnary(_target_)
|
||||
@ -226,6 +230,7 @@ evaluate ::= _target_ (a) . { driver->setResult(a); }
|
||||
|
||||
rule_get_field(_target_, SYM_TENSOR_ID)
|
||||
rule_get_field(_target_, SSYM_TENSOR_ID)
|
||||
rule_get_patchfields(_target_, _value_type_, SYM_TENSOR_ID)
|
||||
|
||||
rules_standard(_target_, _value_type_, _logic_)
|
||||
rules_inplace_gUnary(_target_)
|
||||
@ -246,6 +251,7 @@ tfield (lhs) ::= IDENTITY_TENSOR . { lhs = _new_tfield(Foam::tensor::I); }
|
||||
|
||||
rule_get_field(_target_, TENSOR_ID)
|
||||
rule_get_field(_target_, STENSOR_ID)
|
||||
rule_get_patchfields(_target_, _value_type_, TENSOR_ID)
|
||||
|
||||
rules_standard(_target_, _value_type_, _logic_)
|
||||
rules_inplace_gUnary(_target_)
|
||||
|
||||
@ -6,11 +6,10 @@ divert(-1)dnl
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019 OpenCFD Ltd.
|
||||
# Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# Description
|
||||
# Driver-specific m4/lemon macros for patch expressions.
|
||||
@ -31,6 +30,29 @@ divert(-1)dnl
|
||||
|
||||
use_bool_logic()dnl # Use boolField directly
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Patch-specific driver rules
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# rule_get_patchfields(out, valType, ident)
|
||||
#
|
||||
# Description
|
||||
# Production rules to get patch internal field
|
||||
# and patch neighbour field
|
||||
#
|
||||
# Example
|
||||
# rule_get_patchfields(sfield, Foam::scalar, SCALAR_ID)
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
define([rule_get_patchfields],
|
||||
[dnl
|
||||
rule_driver_unary_named($1, INTERNAL_FIELD, $3, patchInternalField, $2)dnl
|
||||
rule_driver_unary_named($1, NEIGHBOUR_FIELD, $3, patchNeighbourField, $2)dnl
|
||||
rule_driver_unary_named($1, SN_GRAD, $3, patchNormalField, $2)dnl
|
||||
])
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Driver rules
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
@ -57,7 +57,7 @@ union scanToken
|
||||
Foam::scalar svalue;
|
||||
Foam::word* name;
|
||||
|
||||
//- Null construct, bit-wise zero for union content
|
||||
//- Default construct, bit-wise zero for union content
|
||||
scanToken() : ivalue(0) {}
|
||||
};
|
||||
|
||||
@ -73,7 +73,7 @@ class scanner
|
||||
//- Wrapped lemon parser
|
||||
parser* parser_;
|
||||
|
||||
// Ragel code state, action
|
||||
//- Ragel code state, action
|
||||
int cs, act;
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, optionally setting debugging
|
||||
//- Default construct, optionally setting debugging
|
||||
explicit scanner(bool withDebug = false)
|
||||
:
|
||||
parser_(nullptr),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -186,12 +186,12 @@ static int driverTokenType
|
||||
|
||||
switch (lookBehind)
|
||||
{
|
||||
case TOK_CSET : good = driver_.isCellSet(ident); break;
|
||||
case TOK_FSET : good = driver_.isFaceSet(ident); break;
|
||||
case TOK_PSET : good = driver_.isPointSet(ident); break;
|
||||
case TOK_CZONE : good = driver_.isCellZone(ident); break;
|
||||
case TOK_FZONE : good = driver_.isFaceZone(ident); break;
|
||||
case TOK_PZONE : good = driver_.isPointZone(ident); break;
|
||||
case TOK_CELL_SET : good = driver_.isCellSet(ident); break;
|
||||
case TOK_FACE_SET : good = driver_.isFaceSet(ident); break;
|
||||
case TOK_POINT_SET : good = driver_.isPointSet(ident); break;
|
||||
case TOK_CELL_ZONE : good = driver_.isCellZone(ident); break;
|
||||
case TOK_FACE_ZONE : good = driver_.isFaceZone(ident); break;
|
||||
case TOK_POINT_ZONE : good = driver_.isPointZone(ident); break;
|
||||
}
|
||||
|
||||
if (good)
|
||||
@ -336,7 +336,7 @@ static int driverTokenType
|
||||
|
||||
number => emit_number;
|
||||
|
||||
## operators
|
||||
## Operators
|
||||
'!' =>{ EMIT_TOKEN(NOT); };
|
||||
'%' =>{ EMIT_TOKEN(PERCENT); };
|
||||
'(' =>{ EMIT_TOKEN(LPAREN); };
|
||||
@ -404,6 +404,11 @@ static int driverTokenType
|
||||
"weightSum" =>{ EMIT_TOKEN(WEIGHT_SUM); };
|
||||
"rand" =>{ EMIT_TOKEN(RAND); };
|
||||
|
||||
## Patch-specific
|
||||
"snGrad" =>{ EMIT_TOKEN(SN_GRAD); };
|
||||
"internalField" =>{ EMIT_TOKEN(INTERNAL_FIELD); };
|
||||
"neighbourField" =>{ EMIT_TOKEN(NEIGHBOUR_FIELD); };
|
||||
|
||||
## Types
|
||||
"bool" =>{ EMIT_TOKEN(BOOL); };
|
||||
"vector" =>{ EMIT_TOKEN(VECTOR); };
|
||||
@ -418,6 +423,7 @@ static int driverTokenType
|
||||
"tensor::I" =>{ EMIT_TOKEN(IDENTITY_TENSOR); };
|
||||
"arg" =>{ EMIT_TOKEN(ARG); };
|
||||
"time" =>{ EMIT_TOKEN(TIME); };
|
||||
"deltaT" =>{ EMIT_TOKEN(DELTA_T); };
|
||||
|
||||
## Identifier (field, etc - error if unknown)
|
||||
## Handle 'bare' names and single/double quoted ones
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -81,23 +81,23 @@ addNamedToRunTimeSelectionTable
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
static inline const TimeState* lookupTimeState
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
bool cacheReadFields
|
||||
const polyMesh& m
|
||||
)
|
||||
:
|
||||
parsing::genericRagelLemonDriver(),
|
||||
expressions::fvExprDriver(cacheReadFields),
|
||||
mesh_(mesh),
|
||||
resultType_(),
|
||||
isLogical_(false),
|
||||
fieldGeoType_(NO_DATA),
|
||||
resultDimension_()
|
||||
{}
|
||||
{
|
||||
return &static_cast<const TimeState&>(m.time());
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||
(
|
||||
@ -106,7 +106,7 @@ Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||
)
|
||||
:
|
||||
parsing::genericRagelLemonDriver(),
|
||||
expressions::fvExprDriver(dict),
|
||||
expressions::fvExprDriver(dict, lookupTimeState(mesh)),
|
||||
mesh_(mesh),
|
||||
resultType_(),
|
||||
isLogical_(false),
|
||||
@ -128,7 +128,9 @@ Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||
isLogical_(false),
|
||||
fieldGeoType_(NO_DATA),
|
||||
resultDimension_()
|
||||
{}
|
||||
{
|
||||
resetTimeReference(mesh_.time()); // Extra safety
|
||||
}
|
||||
|
||||
|
||||
Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||
@ -150,7 +152,7 @@ Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||
)
|
||||
:
|
||||
parsing::genericRagelLemonDriver(),
|
||||
expressions::fvExprDriver(dict),
|
||||
expressions::fvExprDriver(dict, lookupTimeState(mesh)),
|
||||
mesh_(mesh),
|
||||
resultType_(),
|
||||
isLogical_(false),
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -177,16 +177,13 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for specified mesh
|
||||
//- Construct for specified mesh, with dictionary information
|
||||
explicit parseDriver
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
bool cacheReadFields = false
|
||||
const dictionary& dict = dictionary::null
|
||||
);
|
||||
|
||||
//- Construct for specified mesh with given dictionary
|
||||
parseDriver(const fvMesh& mesh, const dictionary& dict);
|
||||
|
||||
//- Construct for specified mesh with copy of driver context
|
||||
parseDriver(const fvMesh& mesh, const parseDriver& driver);
|
||||
|
||||
@ -196,6 +193,7 @@ public:
|
||||
//- Construct with patchName and region specified in dictionary
|
||||
parseDriver(const dictionary& dict, const fvMesh& mesh);
|
||||
|
||||
|
||||
//- Clone
|
||||
virtual autoPtr<expressions::fvExprDriver> clone() const
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -266,17 +266,11 @@ Foam::expressions::volumeExpr::parseDriver::field_rand
|
||||
bool gaussian
|
||||
) const
|
||||
{
|
||||
auto tresult = volScalarField::New
|
||||
(
|
||||
"rand",
|
||||
mesh(),
|
||||
dimless
|
||||
);
|
||||
auto& fld = tresult.ref().primitiveFieldRef();
|
||||
auto tfld = volScalarField::New("rand", mesh(), dimless);
|
||||
|
||||
fill_random(fld, seed, gaussian);
|
||||
exprDriver::fill_random(tfld.ref().primitiveFieldRef(), seed, gaussian);
|
||||
|
||||
return tresult;
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -245,7 +245,9 @@ Foam::expressions::volumeExpr::parseDriver::newVolField
|
||||
const Type& val
|
||||
) const
|
||||
{
|
||||
return GeometricField<Type,fvPatchField,volMesh>::New
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
return fieldType::New
|
||||
(
|
||||
word("constant.") + word(pTraits<Type>::typeName),
|
||||
mesh(),
|
||||
@ -261,7 +263,9 @@ Foam::expressions::volumeExpr::parseDriver::newSurfaceField
|
||||
const Type& val
|
||||
) const
|
||||
{
|
||||
return GeometricField<Type,fvsPatchField,surfaceMesh>::New
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
|
||||
|
||||
return fieldType::New
|
||||
(
|
||||
word("constant.") + word(pTraits<Type>::typeName),
|
||||
mesh(),
|
||||
@ -277,7 +281,9 @@ Foam::expressions::volumeExpr::parseDriver::newPointField
|
||||
const Type& val
|
||||
) const
|
||||
{
|
||||
return GeometricField<Type,pointPatchField,pointMesh>::New
|
||||
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
|
||||
|
||||
return fieldType::New
|
||||
(
|
||||
word("constant.") + word(pTraits<Type>::typeName),
|
||||
pointMesh::New(mesh()),
|
||||
|
||||
@ -27,94 +27,95 @@
|
||||
#define TOK_RAD_TO_DEG 27
|
||||
#define TOK_ARG 28
|
||||
#define TOK_TIME 29
|
||||
#define TOK_SCALAR_ID 30
|
||||
#define TOK_MIN 31
|
||||
#define TOK_COMMA 32
|
||||
#define TOK_MAX 33
|
||||
#define TOK_SUM 34
|
||||
#define TOK_AVERAGE 35
|
||||
#define TOK_EXP 36
|
||||
#define TOK_LOG 37
|
||||
#define TOK_LOG10 38
|
||||
#define TOK_SQR 39
|
||||
#define TOK_SQRT 40
|
||||
#define TOK_CBRT 41
|
||||
#define TOK_SIN 42
|
||||
#define TOK_COS 43
|
||||
#define TOK_TAN 44
|
||||
#define TOK_ASIN 45
|
||||
#define TOK_ACOS 46
|
||||
#define TOK_ATAN 47
|
||||
#define TOK_SINH 48
|
||||
#define TOK_COSH 49
|
||||
#define TOK_TANH 50
|
||||
#define TOK_POW 51
|
||||
#define TOK_ATAN2 52
|
||||
#define TOK_POS 53
|
||||
#define TOK_NEG 54
|
||||
#define TOK_POS0 55
|
||||
#define TOK_NEG0 56
|
||||
#define TOK_SIGN 57
|
||||
#define TOK_FLOOR 58
|
||||
#define TOK_CEIL 59
|
||||
#define TOK_ROUND 60
|
||||
#define TOK_HYPOT 61
|
||||
#define TOK_RAND 62
|
||||
#define TOK_VECTOR_ID 63
|
||||
#define TOK_SPH_TENSOR_ID 64
|
||||
#define TOK_SYM_TENSOR_ID 65
|
||||
#define TOK_IDENTITY_TENSOR 66
|
||||
#define TOK_TENSOR_ID 67
|
||||
#define TOK_LTRUE 68
|
||||
#define TOK_LFALSE 69
|
||||
#define TOK_BOOL 70
|
||||
#define TOK_CSET 71
|
||||
#define TOK_IDENTIFIER 72
|
||||
#define TOK_CZONE 73
|
||||
#define TOK_CELL_VOLUME 74
|
||||
#define TOK_WEIGHT_AVERAGE 75
|
||||
#define TOK_WEIGHT_SUM 76
|
||||
#define TOK_FACE_EXPR 77
|
||||
#define TOK_SSCALAR_ID 78
|
||||
#define TOK_SVECTOR_ID 79
|
||||
#define TOK_SSPH_TENSOR_ID 80
|
||||
#define TOK_SSYM_TENSOR_ID 81
|
||||
#define TOK_STENSOR_ID 82
|
||||
#define TOK_FSET 83
|
||||
#define TOK_FZONE 84
|
||||
#define TOK_FACE_AREA 85
|
||||
#define TOK_FACE_CENTRE 86
|
||||
#define TOK_POINT_EXPR 87
|
||||
#define TOK_PSCALAR_ID 88
|
||||
#define TOK_PVECTOR_ID 89
|
||||
#define TOK_PSPH_TENSOR_ID 90
|
||||
#define TOK_PSYM_TENSOR_ID 91
|
||||
#define TOK_PTENSOR_ID 92
|
||||
#define TOK_PSET 93
|
||||
#define TOK_PZONE 94
|
||||
#define TOK_POINTS 95
|
||||
#define TOK_MAG 96
|
||||
#define TOK_MAGSQR 97
|
||||
#define TOK_VECTOR 98
|
||||
#define TOK_TENSOR 99
|
||||
#define TOK_SYM_TENSOR 100
|
||||
#define TOK_SPH_TENSOR 101
|
||||
#define TOK_CMPT_X 102
|
||||
#define TOK_CMPT_Y 103
|
||||
#define TOK_CMPT_Z 104
|
||||
#define TOK_CMPT_XX 105
|
||||
#define TOK_CMPT_XY 106
|
||||
#define TOK_CMPT_XZ 107
|
||||
#define TOK_CMPT_YX 108
|
||||
#define TOK_CMPT_YY 109
|
||||
#define TOK_CMPT_YZ 110
|
||||
#define TOK_CMPT_ZX 111
|
||||
#define TOK_CMPT_ZY 112
|
||||
#define TOK_CMPT_ZZ 113
|
||||
#define TOK_CMPT_II 114
|
||||
#define TOK_TRANSPOSE 115
|
||||
#define TOK_DIAG 116
|
||||
#define TOK_POINT_TO_CELL 117
|
||||
#define TOK_RECONSTRUCT 118
|
||||
#define TOK_CELL_TO_FACE 119
|
||||
#define TOK_CELL_TO_POINT 120
|
||||
#define TOK_DELTA_T 30
|
||||
#define TOK_SCALAR_ID 31
|
||||
#define TOK_MIN 32
|
||||
#define TOK_COMMA 33
|
||||
#define TOK_MAX 34
|
||||
#define TOK_SUM 35
|
||||
#define TOK_AVERAGE 36
|
||||
#define TOK_EXP 37
|
||||
#define TOK_LOG 38
|
||||
#define TOK_LOG10 39
|
||||
#define TOK_SQR 40
|
||||
#define TOK_SQRT 41
|
||||
#define TOK_CBRT 42
|
||||
#define TOK_SIN 43
|
||||
#define TOK_COS 44
|
||||
#define TOK_TAN 45
|
||||
#define TOK_ASIN 46
|
||||
#define TOK_ACOS 47
|
||||
#define TOK_ATAN 48
|
||||
#define TOK_SINH 49
|
||||
#define TOK_COSH 50
|
||||
#define TOK_TANH 51
|
||||
#define TOK_POW 52
|
||||
#define TOK_ATAN2 53
|
||||
#define TOK_POS 54
|
||||
#define TOK_NEG 55
|
||||
#define TOK_POS0 56
|
||||
#define TOK_NEG0 57
|
||||
#define TOK_SIGN 58
|
||||
#define TOK_FLOOR 59
|
||||
#define TOK_CEIL 60
|
||||
#define TOK_ROUND 61
|
||||
#define TOK_HYPOT 62
|
||||
#define TOK_RAND 63
|
||||
#define TOK_VECTOR_ID 64
|
||||
#define TOK_SPH_TENSOR_ID 65
|
||||
#define TOK_SYM_TENSOR_ID 66
|
||||
#define TOK_IDENTITY_TENSOR 67
|
||||
#define TOK_TENSOR_ID 68
|
||||
#define TOK_LTRUE 69
|
||||
#define TOK_LFALSE 70
|
||||
#define TOK_BOOL 71
|
||||
#define TOK_CELL_SET 72
|
||||
#define TOK_IDENTIFIER 73
|
||||
#define TOK_CELL_ZONE 74
|
||||
#define TOK_CELL_VOLUME 75
|
||||
#define TOK_WEIGHT_AVERAGE 76
|
||||
#define TOK_WEIGHT_SUM 77
|
||||
#define TOK_FACE_EXPR 78
|
||||
#define TOK_SSCALAR_ID 79
|
||||
#define TOK_SVECTOR_ID 80
|
||||
#define TOK_SSPH_TENSOR_ID 81
|
||||
#define TOK_SSYM_TENSOR_ID 82
|
||||
#define TOK_STENSOR_ID 83
|
||||
#define TOK_FACE_SET 84
|
||||
#define TOK_FACE_ZONE 85
|
||||
#define TOK_FACE_AREA 86
|
||||
#define TOK_FACE_CENTRE 87
|
||||
#define TOK_POINT_EXPR 88
|
||||
#define TOK_PSCALAR_ID 89
|
||||
#define TOK_PVECTOR_ID 90
|
||||
#define TOK_PSPH_TENSOR_ID 91
|
||||
#define TOK_PSYM_TENSOR_ID 92
|
||||
#define TOK_PTENSOR_ID 93
|
||||
#define TOK_POINT_SET 94
|
||||
#define TOK_POINT_ZONE 95
|
||||
#define TOK_POINTS 96
|
||||
#define TOK_MAG 97
|
||||
#define TOK_MAGSQR 98
|
||||
#define TOK_VECTOR 99
|
||||
#define TOK_TENSOR 100
|
||||
#define TOK_SYM_TENSOR 101
|
||||
#define TOK_SPH_TENSOR 102
|
||||
#define TOK_CMPT_X 103
|
||||
#define TOK_CMPT_Y 104
|
||||
#define TOK_CMPT_Z 105
|
||||
#define TOK_CMPT_XX 106
|
||||
#define TOK_CMPT_XY 107
|
||||
#define TOK_CMPT_XZ 108
|
||||
#define TOK_CMPT_YX 109
|
||||
#define TOK_CMPT_YY 110
|
||||
#define TOK_CMPT_YZ 111
|
||||
#define TOK_CMPT_ZX 112
|
||||
#define TOK_CMPT_ZY 113
|
||||
#define TOK_CMPT_ZZ 114
|
||||
#define TOK_CMPT_II 115
|
||||
#define TOK_TRANSPOSE 116
|
||||
#define TOK_DIAG 117
|
||||
#define TOK_POINT_TO_CELL 118
|
||||
#define TOK_RECONSTRUCT 119
|
||||
#define TOK_CELL_TO_FACE 120
|
||||
#define TOK_CELL_TO_POINT 121
|
||||
|
||||
@ -161,6 +161,7 @@ svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); }
|
||||
svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); }
|
||||
svalue (lhs) ::= ARG LPAREN RPAREN . { lhs = driver->argValue(); }
|
||||
svalue (lhs) ::= TIME LPAREN RPAREN . { lhs = driver->timeValue(); }
|
||||
svalue (lhs) ::= DELTA_T LPAREN RPAREN . { lhs = driver->deltaT(); }
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * Volume Fields * * * * * * * * * * * * * * * *\
|
||||
|
||||
@ -6,11 +6,10 @@ divert(-1)dnl
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019 OpenCFD Ltd.
|
||||
# Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# Description
|
||||
# Driver-specific m4/lemon macros for volume expressions.
|
||||
@ -35,8 +34,8 @@ divert(-1)dnl
|
||||
|
||||
define([rules_driver_volume_functions],
|
||||
[dnl
|
||||
rule_driver_select(_logic_, CSET, field_cellSet)dnl
|
||||
rule_driver_select(_logic_, CZONE, field_cellZone)dnl
|
||||
rule_driver_select(_logic_, CELL_SET, field_cellSet)dnl
|
||||
rule_driver_select(_logic_, CELL_ZONE, field_cellZone)dnl
|
||||
dnl
|
||||
rule_driver_nullary(_scalar_, CELL_VOLUME, field_cellVolume)dnl
|
||||
rule_driver_nullary(_vector_, POS, field_cellCentre)dnl CELL_CENTRE
|
||||
@ -57,8 +56,8 @@ dnl
|
||||
|
||||
define([rules_driver_surface_functions],
|
||||
[dnl
|
||||
rule_driver_select(_logic_, FSET, field_faceSet)dnl
|
||||
rule_driver_select(_logic_, FZONE, field_faceZone)dnl
|
||||
rule_driver_select(_logic_, FACE_SET, field_faceSet)dnl
|
||||
rule_driver_select(_logic_, FACE_ZONE, field_faceZone)dnl
|
||||
dnl
|
||||
rule_driver_nullary(_scalar_, FACE_AREA, field_faceArea)dnl
|
||||
rule_driver_nullary(_vector_, FACE_CENTRE, field_faceCentre)dnl
|
||||
@ -80,8 +79,8 @@ dnl
|
||||
|
||||
define([rules_driver_point_functions],
|
||||
[dnl
|
||||
rule_driver_select(_logic_, PSET, field_pointSet)dnl
|
||||
rule_driver_select(_logic_, PZONE, field_pointZone)dnl
|
||||
rule_driver_select(_logic_, POINT_SET, field_pointSet)dnl
|
||||
rule_driver_select(_logic_, POINT_ZONE, field_pointZone)dnl
|
||||
dnl
|
||||
rule_driver_nullary(_vector_, POINTS, field_pointField)dnl
|
||||
dnl
|
||||
|
||||
@ -57,7 +57,7 @@ union scanToken
|
||||
Foam::scalar svalue;
|
||||
Foam::word* name;
|
||||
|
||||
//- Null construct, bit-wise zero for union content
|
||||
//- Default construct, bit-wise zero for union content
|
||||
scanToken() : ivalue(0) {}
|
||||
};
|
||||
|
||||
@ -73,7 +73,7 @@ class scanner
|
||||
//- Wrapped lemon parser
|
||||
parser* parser_;
|
||||
|
||||
// Ragel code state, action
|
||||
//- Ragel code state, action
|
||||
int cs, act;
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, optionally setting debugging
|
||||
//- Default construct, optionally setting debugging
|
||||
explicit scanner(bool withDebug = false)
|
||||
:
|
||||
parser_(nullptr),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -61,12 +61,12 @@ namespace Foam
|
||||
// Special handling for these known (stashed) look-back types
|
||||
static const Enum<int> lookBehindTokenEnums
|
||||
({
|
||||
TOKEN_PAIR("cellSet", CSET),
|
||||
TOKEN_PAIR("faceSet", FSET),
|
||||
TOKEN_PAIR("pointSet", PSET),
|
||||
TOKEN_PAIR("cellZone", CZONE),
|
||||
TOKEN_PAIR("faceZone", FZONE),
|
||||
TOKEN_PAIR("pointZone", PZONE),
|
||||
TOKEN_PAIR("cellSet", CELL_SET),
|
||||
TOKEN_PAIR("faceSet", FACE_SET),
|
||||
TOKEN_PAIR("pointSet", POINT_SET),
|
||||
TOKEN_PAIR("cellZone", CELL_ZONE),
|
||||
TOKEN_PAIR("faceZone", FACE_ZONE),
|
||||
TOKEN_PAIR("pointZone", POINT_ZONE),
|
||||
});
|
||||
|
||||
#define HAS_LOOKBEHIND_TOKENS
|
||||
@ -201,12 +201,12 @@ static int driverTokenType
|
||||
|
||||
switch (lookBehind)
|
||||
{
|
||||
case TOK_CSET : good = driver_.isCellSet(ident); break;
|
||||
case TOK_FSET : good = driver_.isFaceSet(ident); break;
|
||||
case TOK_PSET : good = driver_.isPointSet(ident); break;
|
||||
case TOK_CZONE : good = driver_.isCellZone(ident); break;
|
||||
case TOK_FZONE : good = driver_.isFaceZone(ident); break;
|
||||
case TOK_PZONE : good = driver_.isPointZone(ident); break;
|
||||
case TOK_CELL_SET : good = driver_.isCellSet(ident); break;
|
||||
case TOK_FACE_SET : good = driver_.isFaceSet(ident); break;
|
||||
case TOK_POINT_SET : good = driver_.isPointSet(ident); break;
|
||||
case TOK_CELL_ZONE : good = driver_.isCellZone(ident); break;
|
||||
case TOK_FACE_ZONE : good = driver_.isFaceZone(ident); break;
|
||||
case TOK_POINT_ZONE : good = driver_.isPointZone(ident); break;
|
||||
}
|
||||
|
||||
if (good)
|
||||
@ -365,7 +365,7 @@ static int driverTokenType
|
||||
|
||||
number => emit_number;
|
||||
|
||||
## operators
|
||||
## Operators
|
||||
'!' =>{ EMIT_TOKEN(NOT); };
|
||||
'%' =>{ EMIT_TOKEN(PERCENT); };
|
||||
'(' =>{ EMIT_TOKEN(LPAREN); };
|
||||
@ -447,6 +447,7 @@ static int driverTokenType
|
||||
"tensor::I" =>{ EMIT_TOKEN(IDENTITY_TENSOR); };
|
||||
"arg" =>{ EMIT_TOKEN(ARG); };
|
||||
"time" =>{ EMIT_TOKEN(TIME); };
|
||||
"deltaT" =>{ EMIT_TOKEN(DELTA_T); };
|
||||
|
||||
## Identifier (field, etc - error if unknown)
|
||||
## Handle 'bare' names and single/double quoted ones
|
||||
|
||||
Reference in New Issue
Block a user