mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add objectRegistry handling to expressions driver
- needed for future embedding
This commit is contained in:
@ -29,7 +29,7 @@ License
|
|||||||
#include "exprDriver.H"
|
#include "exprDriver.H"
|
||||||
#include "expressionEntry.H"
|
#include "expressionEntry.H"
|
||||||
#include "stringOps.H"
|
#include "stringOps.H"
|
||||||
#include "TimeState.H"
|
#include "Time.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -115,34 +115,40 @@ void Foam::expressions::exprDriver::resetTimeReference(const TimeState& ts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::expressions::exprDriver::resetDb(const objectRegistry* obrPtr)
|
||||||
|
{
|
||||||
|
obrPtr_ = obrPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::expressions::exprDriver::resetDb(const objectRegistry& db)
|
||||||
|
{
|
||||||
|
resetDb(&db);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::expressions::exprDriver::exprDriver
|
Foam::expressions::exprDriver::exprDriver
|
||||||
(
|
(
|
||||||
enum searchControls search,
|
enum searchControls search,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const TimeState* ts
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
dict_(dict),
|
dict_(dict),
|
||||||
result_(),
|
result_(),
|
||||||
variableStrings_(),
|
variableStrings_(),
|
||||||
variables_(),
|
variables_(16),
|
||||||
arg1Value_(0),
|
arg1Value_(0),
|
||||||
timeStatePtr_(ts),
|
timeStatePtr_(nullptr),
|
||||||
|
obrPtr_(nullptr),
|
||||||
stashedTokenId_(0),
|
stashedTokenId_(0),
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
debugScanner_(dict.getOrDefault("debugScanner", false)),
|
debugScanner_(dict.getOrDefault("debugScanner", false)),
|
||||||
debugParser_(dict.getOrDefault("debugParser", false)),
|
debugParser_(dict.getOrDefault("debugParser", false)),
|
||||||
allowShadowing_
|
allowShadowing_(dict.getOrDefault("allowShadowing", false)),
|
||||||
(
|
prevIterIsOldTime_(dict.getOrDefault("prevIterIsOldTime", false)),
|
||||||
dict.getOrDefault("allowShadowing", false)
|
|
||||||
),
|
|
||||||
prevIterIsOldTime_
|
|
||||||
(
|
|
||||||
dict.getOrDefault("prevIterIsOldTime", false)
|
|
||||||
),
|
|
||||||
searchCtrl_(search)
|
searchCtrl_(search)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -158,8 +164,10 @@ Foam::expressions::exprDriver::exprDriver
|
|||||||
variables_(rhs.variables_),
|
variables_(rhs.variables_),
|
||||||
arg1Value_(rhs.arg1Value_),
|
arg1Value_(rhs.arg1Value_),
|
||||||
timeStatePtr_(rhs.timeStatePtr_),
|
timeStatePtr_(rhs.timeStatePtr_),
|
||||||
|
obrPtr_(rhs.obrPtr_),
|
||||||
stashedTokenId_(0),
|
stashedTokenId_(0),
|
||||||
|
|
||||||
|
// Controls
|
||||||
debugScanner_(rhs.debugScanner_),
|
debugScanner_(rhs.debugScanner_),
|
||||||
debugParser_(rhs.debugParser_),
|
debugParser_(rhs.debugParser_),
|
||||||
allowShadowing_(rhs.allowShadowing_),
|
allowShadowing_(rhs.allowShadowing_),
|
||||||
@ -171,15 +179,13 @@ Foam::expressions::exprDriver::exprDriver
|
|||||||
|
|
||||||
Foam::expressions::exprDriver::exprDriver
|
Foam::expressions::exprDriver::exprDriver
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const TimeState* ts
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
exprDriver
|
exprDriver
|
||||||
(
|
(
|
||||||
searchControls(exprDriver::getSearchControls(dict)),
|
searchControls(exprDriver::getSearchControls(dict)),
|
||||||
dict,
|
dict
|
||||||
ts
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
readDict(dict);
|
readDict(dict);
|
||||||
@ -188,9 +194,17 @@ Foam::expressions::exprDriver::exprDriver
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::TimeState* Foam::expressions::exprDriver::timeState() const
|
const Foam::TimeState* Foam::expressions::exprDriver::timeState() const noexcept
|
||||||
{
|
{
|
||||||
return timeStatePtr_;
|
if (timeStatePtr_)
|
||||||
|
{
|
||||||
|
return timeStatePtr_;
|
||||||
|
}
|
||||||
|
else if (obrPtr_)
|
||||||
|
{
|
||||||
|
return &(obrPtr_->time());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -200,6 +214,10 @@ Foam::scalar Foam::expressions::exprDriver::timeValue() const
|
|||||||
{
|
{
|
||||||
return timeStatePtr_->value();
|
return timeStatePtr_->value();
|
||||||
}
|
}
|
||||||
|
else if (obrPtr_)
|
||||||
|
{
|
||||||
|
return obrPtr_->time().value();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +228,10 @@ Foam::scalar Foam::expressions::exprDriver::deltaT() const
|
|||||||
{
|
{
|
||||||
return timeStatePtr_->deltaT().value();
|
return timeStatePtr_->deltaT().value();
|
||||||
}
|
}
|
||||||
|
else if (obrPtr_)
|
||||||
|
{
|
||||||
|
return obrPtr_->time().deltaT().value();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -130,6 +130,9 @@ protected:
|
|||||||
//- Reference to the time-state
|
//- Reference to the time-state
|
||||||
mutable const TimeState* timeStatePtr_;
|
mutable const TimeState* timeStatePtr_;
|
||||||
|
|
||||||
|
//- Pointer to an object registry (for functions etc).
|
||||||
|
const objectRegistry* obrPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Controls, tracing etc.
|
// Controls, tracing etc.
|
||||||
|
|
||||||
@ -274,19 +277,14 @@ public:
|
|||||||
explicit exprDriver
|
explicit exprDriver
|
||||||
(
|
(
|
||||||
enum searchControls search = searchControls::DEFAULT_SEARCH,
|
enum searchControls search = searchControls::DEFAULT_SEARCH,
|
||||||
const dictionary& dict = dictionary::null,
|
const dictionary& dict = dictionary::null
|
||||||
const TimeState* ts = nullptr
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Copy construct
|
//- Copy construct
|
||||||
exprDriver(const exprDriver& rhs);
|
exprDriver(const exprDriver& rhs);
|
||||||
|
|
||||||
//- Construct from a dictionary
|
//- Construct from a dictionary
|
||||||
explicit exprDriver
|
explicit exprDriver(const dictionary& dict);
|
||||||
(
|
|
||||||
const dictionary& dict,
|
|
||||||
const TimeState* ts = nullptr
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -308,7 +306,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Reference to the current time-state (can be nullptr)
|
//- Reference to the current time-state (can be nullptr)
|
||||||
const TimeState* timeState() const;
|
const TimeState* timeState() const noexcept;
|
||||||
|
|
||||||
//- The current time value
|
//- The current time value
|
||||||
virtual scalar timeValue() const;
|
virtual scalar timeValue() const;
|
||||||
@ -349,6 +347,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// External References
|
||||||
|
|
||||||
|
//- Reset the objectRegistry (for functions)
|
||||||
|
void resetDb(const objectRegistry* obrPtr = nullptr);
|
||||||
|
|
||||||
|
//- Reset the objectRegistry (for functions)
|
||||||
|
void resetDb(const objectRegistry& db);
|
||||||
|
|
||||||
|
|
||||||
// Specials
|
// Specials
|
||||||
|
|
||||||
//- Get special-purpose scalar reference argument.
|
//- Get special-purpose scalar reference argument.
|
||||||
|
|||||||
@ -82,7 +82,6 @@ inline void Foam::expressions::exprDriver::addUniformVariable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::expressions::exprDriver::evaluate
|
Foam::tmp<Foam::Field<Type>> Foam::expressions::exprDriver::evaluate
|
||||||
(
|
(
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2010-2018
|
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -201,9 +201,8 @@ bool Foam::expressions::exprDriver::isLocalVariable
|
|||||||
const exprResult& var = variable(name);
|
const exprResult& var = variable(name);
|
||||||
|
|
||||||
DebugInfo
|
DebugInfo
|
||||||
<< " - found (" << var.valueType() << ' '
|
<< " - found (" << var.valueType()
|
||||||
<< var.isPointData() << ')';
|
<< (var.isPointData() ? " point" : "") << ')';
|
||||||
|
|
||||||
|
|
||||||
good = (var.isType<Type>() && var.isPointData(wantPointData));
|
good = (var.isType<Type>() && var.isPointData(wantPointData));
|
||||||
|
|
||||||
|
|||||||
@ -95,11 +95,10 @@ const Foam::fvMesh* Foam::expressions::fvExprDriver::resetDefaultMesh
|
|||||||
Foam::expressions::fvExprDriver::fvExprDriver
|
Foam::expressions::fvExprDriver::fvExprDriver
|
||||||
(
|
(
|
||||||
enum exprDriver::searchControls search,
|
enum exprDriver::searchControls search,
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const TimeState* ts
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
expressions::exprDriver(search, dict, ts),
|
expressions::exprDriver(search, dict),
|
||||||
globalScopes_(),
|
globalScopes_(),
|
||||||
delayedVariables_(),
|
delayedVariables_(),
|
||||||
storedVariables_(),
|
storedVariables_(),
|
||||||
@ -126,11 +125,10 @@ Foam::expressions::fvExprDriver::fvExprDriver
|
|||||||
|
|
||||||
Foam::expressions::fvExprDriver::fvExprDriver
|
Foam::expressions::fvExprDriver::fvExprDriver
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict
|
||||||
const TimeState* ts
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
expressions::exprDriver(dict, ts),
|
expressions::exprDriver(dict),
|
||||||
globalScopes_(),
|
globalScopes_(),
|
||||||
delayedVariables_(),
|
delayedVariables_(),
|
||||||
storedVariables_(),
|
storedVariables_(),
|
||||||
|
|||||||
@ -365,19 +365,14 @@ public:
|
|||||||
(
|
(
|
||||||
enum exprDriver::searchControls search =
|
enum exprDriver::searchControls search =
|
||||||
exprDriver::searchControls::DEFAULT_SEARCH,
|
exprDriver::searchControls::DEFAULT_SEARCH,
|
||||||
const dictionary& dict = dictionary::null,
|
const dictionary& dict = dictionary::null
|
||||||
const TimeState* ts = nullptr
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Copy construct
|
//- Copy construct
|
||||||
fvExprDriver(const fvExprDriver&);
|
fvExprDriver(const fvExprDriver&);
|
||||||
|
|
||||||
//- Construct from a dictionary
|
//- Construct from a dictionary
|
||||||
explicit fvExprDriver
|
explicit fvExprDriver(const dictionary& dict);
|
||||||
(
|
|
||||||
const dictionary& dict,
|
|
||||||
const TimeState* ts = nullptr
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Return a reference to the selected value driver
|
//- Return a reference to the selected value driver
|
||||||
|
|||||||
@ -28,9 +28,8 @@ License
|
|||||||
#include "patchExprDriver.H"
|
#include "patchExprDriver.H"
|
||||||
#include "patchExprScanner.H"
|
#include "patchExprScanner.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "fvPatch.H"
|
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "className.H"
|
#include "fvPatch.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -70,14 +69,6 @@ addNamedToRunTimeSelectionTable
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
static inline const TimeState* lookupTimeState
|
|
||||||
(
|
|
||||||
const fvPatch& p
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return &static_cast<const TimeState&>(p.boundaryMesh().mesh().time());
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline const fvPatch& lookupFvPatch
|
static inline const fvPatch& lookupFvPatch
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
@ -115,9 +106,12 @@ Foam::expressions::patchExpr::parseDriver::parseDriver
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
parsing::genericRagelLemonDriver(),
|
parsing::genericRagelLemonDriver(),
|
||||||
expressions::fvExprDriver(dict, lookupTimeState(p)),
|
expressions::fvExprDriver(dict),
|
||||||
patch_(p)
|
patch_(p)
|
||||||
{}
|
{
|
||||||
|
resetTimeReference(nullptr);
|
||||||
|
resetDb(patch_.boundaryMesh().mesh().thisDb());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::expressions::patchExpr::parseDriver::parseDriver
|
Foam::expressions::patchExpr::parseDriver::parseDriver
|
||||||
@ -129,7 +123,10 @@ Foam::expressions::patchExpr::parseDriver::parseDriver
|
|||||||
parsing::genericRagelLemonDriver(),
|
parsing::genericRagelLemonDriver(),
|
||||||
expressions::fvExprDriver(rhs),
|
expressions::fvExprDriver(rhs),
|
||||||
patch_(p)
|
patch_(p)
|
||||||
{}
|
{
|
||||||
|
resetTimeReference(nullptr);
|
||||||
|
resetDb(patch_.boundaryMesh().mesh().thisDb());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::expressions::patchExpr::parseDriver::parseDriver
|
Foam::expressions::patchExpr::parseDriver::parseDriver
|
||||||
|
|||||||
@ -81,22 +81,6 @@ addNamedToRunTimeSelectionTable
|
|||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
static inline const TimeState* lookupTimeState
|
|
||||||
(
|
|
||||||
const polyMesh& m
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return &static_cast<const TimeState&>(m.time());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::expressions::volumeExpr::parseDriver::parseDriver
|
Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||||
@ -106,13 +90,16 @@ Foam::expressions::volumeExpr::parseDriver::parseDriver
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
parsing::genericRagelLemonDriver(),
|
parsing::genericRagelLemonDriver(),
|
||||||
expressions::fvExprDriver(dict, lookupTimeState(mesh)),
|
expressions::fvExprDriver(dict),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
resultType_(),
|
resultType_(),
|
||||||
isLogical_(false),
|
isLogical_(false),
|
||||||
fieldGeoType_(NO_DATA),
|
fieldGeoType_(NO_DATA),
|
||||||
resultDimension_()
|
resultDimension_()
|
||||||
{}
|
{
|
||||||
|
resetTimeReference(nullptr);
|
||||||
|
resetDb(mesh_.thisDb());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::expressions::volumeExpr::parseDriver::parseDriver
|
Foam::expressions::volumeExpr::parseDriver::parseDriver
|
||||||
@ -129,7 +116,8 @@ Foam::expressions::volumeExpr::parseDriver::parseDriver
|
|||||||
fieldGeoType_(NO_DATA),
|
fieldGeoType_(NO_DATA),
|
||||||
resultDimension_()
|
resultDimension_()
|
||||||
{
|
{
|
||||||
resetTimeReference(mesh_.time()); // Extra safety
|
resetTimeReference(nullptr);
|
||||||
|
resetDb(mesh_.thisDb());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -152,13 +140,16 @@ Foam::expressions::volumeExpr::parseDriver::parseDriver
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
parsing::genericRagelLemonDriver(),
|
parsing::genericRagelLemonDriver(),
|
||||||
expressions::fvExprDriver(dict, lookupTimeState(mesh)),
|
expressions::fvExprDriver(dict),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
resultType_(),
|
resultType_(),
|
||||||
isLogical_(false),
|
isLogical_(false),
|
||||||
fieldGeoType_(NO_DATA),
|
fieldGeoType_(NO_DATA),
|
||||||
resultDimension_()
|
resultDimension_()
|
||||||
{}
|
{
|
||||||
|
resetTimeReference(nullptr);
|
||||||
|
resetDb(mesh_.thisDb());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|||||||
Reference in New Issue
Block a user