mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: provide dictionary access for coded BCs etc (#1922)
- in some cases, additional dictionary inputs are useful for extending
the input parameters or functionality of dynamic coded conditions.
Typically this can be used to provide a simple set of dictionary
inputs that are used to drive specific code, but allows changing the
inputs without causing a recompilation.
Accessed with this type of code:
```
const dictionary& dict = this->codeContext();
```
boundary conditions and function objects:
* specify an additional codeContext dictionary entry:
```
codeContext
{
...
}
```
PatchFunction1:
* The code context dictionary is simply the dictionary used to specify
the PatchFunction1 coefficients.
To replicated persistant data, use local member static data.
Eg,
```
code
#{
// Persistent (Member) Data
static autoPtr<Function1<scalar>> baseVel;
static autoPtr<Function1<vector>> baseDir;
...
#}
```
fvOptions:
* currently not applicable
This commit is contained in:
@ -102,6 +102,7 @@ SourceFiles
|
|||||||
#define codedFvOptionTemplate_H
|
#define codedFvOptionTemplate_H
|
||||||
|
|
||||||
#include "cellSetOption.H"
|
#include "cellSetOption.H"
|
||||||
|
#include "dictionaryContent.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -116,7 +117,8 @@ namespace fv
|
|||||||
|
|
||||||
class ${typeName}FvOption${SourceType}
|
class ${typeName}FvOption${SourceType}
|
||||||
:
|
:
|
||||||
public fv::cellSetOption
|
public fv::cellSetOption,
|
||||||
|
public dictionaryContent
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -153,6 +155,12 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Code context as a dictionary
|
||||||
|
const dictionary& codeContext() const
|
||||||
|
{
|
||||||
|
return dictionaryContent::dict();
|
||||||
|
}
|
||||||
|
|
||||||
//- Correct field
|
//- Correct field
|
||||||
virtual void correct
|
virtual void correct
|
||||||
(
|
(
|
||||||
|
|||||||
@ -107,16 +107,6 @@ ${typeName}PatchFunction1${FieldType}
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
${typeName}PatchFunction1${FieldType}::
|
|
||||||
${typeName}PatchFunction1${FieldType}
|
|
||||||
(
|
|
||||||
const ${typeName}PatchFunction1${FieldType}& rhs
|
|
||||||
)
|
|
||||||
:
|
|
||||||
parent_bctype(rhs)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
${typeName}PatchFunction1${FieldType}::
|
${typeName}PatchFunction1${FieldType}::
|
||||||
${typeName}PatchFunction1${FieldType}
|
${typeName}PatchFunction1${FieldType}
|
||||||
(
|
(
|
||||||
|
|||||||
@ -35,6 +35,7 @@ SourceFiles
|
|||||||
#define codedPatchFunction1Template${FieldType}_H
|
#define codedPatchFunction1Template${FieldType}_H
|
||||||
|
|
||||||
#include "PatchFunction1.H"
|
#include "PatchFunction1.H"
|
||||||
|
#include "dictionaryContent.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -49,12 +50,12 @@ namespace PatchFunction1Types
|
|||||||
|
|
||||||
class ${typeName}PatchFunction1${FieldType}
|
class ${typeName}PatchFunction1${FieldType}
|
||||||
:
|
:
|
||||||
public PatchFunction1<${TemplateType}>
|
public PatchFunction1<${TemplateType}>,
|
||||||
|
public dictionaryContent
|
||||||
{
|
{
|
||||||
//- The parent PatchFunction1 type
|
//- The parent PatchFunction1 type
|
||||||
typedef PatchFunction1<${TemplateType}> parent_bctype;
|
typedef PatchFunction1<${TemplateType}> parent_bctype;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Report a message with the SHA1sum
|
//- Report a message with the SHA1sum
|
||||||
@ -88,7 +89,7 @@ public:
|
|||||||
${typeName}PatchFunction1${FieldType}
|
${typeName}PatchFunction1${FieldType}
|
||||||
(
|
(
|
||||||
const ${typeName}PatchFunction1${FieldType}& rhs
|
const ${typeName}PatchFunction1${FieldType}& rhs
|
||||||
);
|
) = default;
|
||||||
|
|
||||||
//- Copy construct, resetting patch
|
//- Copy construct, resetting patch
|
||||||
${typeName}PatchFunction1${FieldType}
|
${typeName}PatchFunction1${FieldType}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ SourceFiles
|
|||||||
#define codedPoints0MotionSolverTemplate_H
|
#define codedPoints0MotionSolverTemplate_H
|
||||||
|
|
||||||
#include "points0MotionSolver.H"
|
#include "points0MotionSolver.H"
|
||||||
|
#include "dictionaryContent.H"
|
||||||
|
|
||||||
//{{{ begin codeInclude
|
//{{{ begin codeInclude
|
||||||
${codeInclude}
|
${codeInclude}
|
||||||
@ -52,7 +53,8 @@ namespace Foam
|
|||||||
|
|
||||||
class ${typeName}Points0MotionSolver
|
class ${typeName}Points0MotionSolver
|
||||||
:
|
:
|
||||||
public points0MotionSolver
|
public points0MotionSolver,
|
||||||
|
public dictionaryContent
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -100,6 +102,12 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Code context as a dictionary
|
||||||
|
const dictionary& codeContext() const
|
||||||
|
{
|
||||||
|
return dictionaryContent::dict();
|
||||||
|
}
|
||||||
|
|
||||||
//- Provide current points for motion. Uses current motion field
|
//- Provide current points for motion. Uses current motion field
|
||||||
virtual tmp<pointField> curPoints() const;
|
virtual tmp<pointField> curPoints() const;
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@ SourceFiles
|
|||||||
#define fixedValueFvPatchTemplate${FieldType}_H
|
#define fixedValueFvPatchTemplate${FieldType}_H
|
||||||
|
|
||||||
#include "fixedValueFvPatchFields.H"
|
#include "fixedValueFvPatchFields.H"
|
||||||
|
#include "dictionaryContent.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -50,7 +51,8 @@ namespace Foam
|
|||||||
|
|
||||||
class ${typeName}FixedValueFvPatch${FieldType}
|
class ${typeName}FixedValueFvPatch${FieldType}
|
||||||
:
|
:
|
||||||
public fixedValueFvPatchField<${TemplateType}>
|
public fixedValueFvPatchField<${TemplateType}>,
|
||||||
|
public dictionaryContent
|
||||||
{
|
{
|
||||||
//- The parent boundary condition type
|
//- The parent boundary condition type
|
||||||
typedef fixedValueFvPatchField<${TemplateType}> parent_bctype;
|
typedef fixedValueFvPatchField<${TemplateType}> parent_bctype;
|
||||||
@ -140,6 +142,12 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Code context as a dictionary
|
||||||
|
const dictionary& codeContext() const
|
||||||
|
{
|
||||||
|
return dictionaryContent::dict();
|
||||||
|
}
|
||||||
|
|
||||||
//- Update the coefficients associated with the patch field
|
//- Update the coefficients associated with the patch field
|
||||||
virtual void updateCoeffs();
|
virtual void updateCoeffs();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -38,6 +38,7 @@ SourceFiles
|
|||||||
#define coded_fixedValuePointPatchTemplate${FieldType}_H
|
#define coded_fixedValuePointPatchTemplate${FieldType}_H
|
||||||
|
|
||||||
#include "fixedValuePointPatchFields.H"
|
#include "fixedValuePointPatchFields.H"
|
||||||
|
#include "dictionaryContent.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -50,7 +51,8 @@ namespace Foam
|
|||||||
|
|
||||||
class ${typeName}FixedValuePointPatch${FieldType}
|
class ${typeName}FixedValuePointPatch${FieldType}
|
||||||
:
|
:
|
||||||
public fixedValuePointPatchField<${TemplateType}>
|
public fixedValuePointPatchField<${TemplateType}>,
|
||||||
|
public dictionaryContent
|
||||||
{
|
{
|
||||||
//- The parent boundary condition type
|
//- The parent boundary condition type
|
||||||
typedef fixedValuePointPatchField<${TemplateType}> parent_bctype;
|
typedef fixedValuePointPatchField<${TemplateType}> parent_bctype;
|
||||||
@ -141,6 +143,12 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Code context as a dictionary
|
||||||
|
const dictionary& codeContext() const
|
||||||
|
{
|
||||||
|
return dictionaryContent::dict();
|
||||||
|
}
|
||||||
|
|
||||||
//- Update the coefficients associated with the patch field
|
//- Update the coefficients associated with the patch field
|
||||||
virtual void updateCoeffs();
|
virtual void updateCoeffs();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -36,6 +36,7 @@ SourceFiles
|
|||||||
#define functionObjectTemplate_H
|
#define functionObjectTemplate_H
|
||||||
|
|
||||||
#include "regionFunctionObject.H"
|
#include "regionFunctionObject.H"
|
||||||
|
#include "dictionaryContent.H"
|
||||||
|
|
||||||
//{{{ begin codeInclude
|
//{{{ begin codeInclude
|
||||||
${codeInclude}
|
${codeInclude}
|
||||||
@ -55,7 +56,8 @@ class fvMesh;
|
|||||||
|
|
||||||
class ${typeName}FunctionObject
|
class ${typeName}FunctionObject
|
||||||
:
|
:
|
||||||
public functionObjects::regionFunctionObject
|
public functionObjects::regionFunctionObject,
|
||||||
|
public dictionaryContent
|
||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
@ -113,6 +115,12 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Code context as a dictionary
|
||||||
|
const dictionary& codeContext() const
|
||||||
|
{
|
||||||
|
return dictionaryContent::dict();
|
||||||
|
}
|
||||||
|
|
||||||
//- Read optional controls
|
//- Read optional controls
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@ SourceFiles
|
|||||||
#define coded_mixedFvPatchTemplate${FieldType}_H
|
#define coded_mixedFvPatchTemplate${FieldType}_H
|
||||||
|
|
||||||
#include "mixedFvPatchFields.H"
|
#include "mixedFvPatchFields.H"
|
||||||
|
#include "dictionaryContent.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -50,7 +51,8 @@ namespace Foam
|
|||||||
|
|
||||||
class ${typeName}MixedValueFvPatch${FieldType}
|
class ${typeName}MixedValueFvPatch${FieldType}
|
||||||
:
|
:
|
||||||
public mixedFvPatchField<${TemplateType}>
|
public mixedFvPatchField<${TemplateType}>,
|
||||||
|
public dictionaryContent
|
||||||
{
|
{
|
||||||
//- The parent boundary condition type
|
//- The parent boundary condition type
|
||||||
typedef mixedFvPatchField<${TemplateType}> parent_bctype;
|
typedef mixedFvPatchField<${TemplateType}> parent_bctype;
|
||||||
@ -140,6 +142,12 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Code context as a dictionary
|
||||||
|
const dictionary& codeContext() const
|
||||||
|
{
|
||||||
|
return dictionaryContent::dict();
|
||||||
|
}
|
||||||
|
|
||||||
//- Update the coefficients associated with the patch field
|
//- Update the coefficients associated with the patch field
|
||||||
virtual void updateCoeffs();
|
virtual void updateCoeffs();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -60,6 +60,15 @@ void Foam::codedFixedValuePointPatchField<Type>::clearRedirect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
const Foam::dictionary&
|
||||||
|
Foam::codedFixedValuePointPatchField<Type>::codeContext() const
|
||||||
|
{
|
||||||
|
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||||
|
return (ptr ? *ptr : dictionary::null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
const Foam::dictionary&
|
const Foam::dictionary&
|
||||||
Foam::codedFixedValuePointPatchField<Type>::codeDict() const
|
Foam::codedFixedValuePointPatchField<Type>::codeDict() const
|
||||||
@ -235,6 +244,22 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
|
|||||||
constructDict
|
constructDict
|
||||||
).ptr()
|
).ptr()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Forward copy of codeContext to the code template
|
||||||
|
auto* contentPtr =
|
||||||
|
dynamic_cast<dictionaryContent*>(redirectPatchFieldPtr_.get());
|
||||||
|
|
||||||
|
if (contentPtr)
|
||||||
|
{
|
||||||
|
contentPtr->dict(this->codeContext());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< name_ << " Did not derive from dictionaryContent"
|
||||||
|
<< nl << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return *redirectPatchFieldPtr_;
|
return *redirectPatchFieldPtr_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ Description
|
|||||||
codeLibs | linker line: added to LIB_LIBS (Make/options)
|
codeLibs | linker line: added to LIB_LIBS (Make/options)
|
||||||
localCode | c++; local static functions
|
localCode | c++; local static functions
|
||||||
code | c++; patch value assignment
|
code | c++; patch value assignment
|
||||||
|
codeContext | additional dictionary context for the code
|
||||||
\endplaintable
|
\endplaintable
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
@ -56,6 +57,11 @@ Description
|
|||||||
);
|
);
|
||||||
#};
|
#};
|
||||||
|
|
||||||
|
codeContext
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
//codeInclude
|
//codeInclude
|
||||||
//#{
|
//#{
|
||||||
// #include "fvCFD.H"
|
// #include "fvCFD.H"
|
||||||
@ -82,6 +88,10 @@ Description
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
The code context dictionary can be supplied separately as the
|
||||||
|
\c codeContext entry.
|
||||||
|
|
||||||
See also
|
See also
|
||||||
codedFixedValueFvPatchField
|
codedFixedValueFvPatchField
|
||||||
|
|
||||||
@ -136,6 +146,9 @@ class codedFixedValuePointPatchField
|
|||||||
//- Clear redirected object(s)
|
//- Clear redirected object(s)
|
||||||
virtual void clearRedirect() const;
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
|
//- Additional 'codeContext' dictionary to pass through
|
||||||
|
virtual const dictionary& codeContext() const;
|
||||||
|
|
||||||
//- The code dictionary. Inline "code" or from system/codeDict
|
//- The code dictionary. Inline "code" or from system/codeDict
|
||||||
virtual const dictionary& codeDict() const;
|
virtual const dictionary& codeDict() const;
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,15 @@ void Foam::codedFixedValueFvPatchField<Type>::clearRedirect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
const Foam::dictionary&
|
||||||
|
Foam::codedFixedValueFvPatchField<Type>::codeContext() const
|
||||||
|
{
|
||||||
|
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||||
|
return (ptr ? *ptr : dictionary::null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
const Foam::dictionary&
|
const Foam::dictionary&
|
||||||
Foam::codedFixedValueFvPatchField<Type>::codeDict() const
|
Foam::codedFixedValueFvPatchField<Type>::codeDict() const
|
||||||
@ -234,6 +243,22 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
|
|||||||
constructDict
|
constructDict
|
||||||
).ptr()
|
).ptr()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Forward copy of codeContext to the code template
|
||||||
|
auto* contentPtr =
|
||||||
|
dynamic_cast<dictionaryContent*>(redirectPatchFieldPtr_.get());
|
||||||
|
|
||||||
|
if (contentPtr)
|
||||||
|
{
|
||||||
|
contentPtr->dict(this->codeContext());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< name_ << " Did not derive from dictionaryContent"
|
||||||
|
<< nl << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return *redirectPatchFieldPtr_;
|
return *redirectPatchFieldPtr_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ Description
|
|||||||
codeLibs | linker line: added to LIB_LIBS (Make/options)
|
codeLibs | linker line: added to LIB_LIBS (Make/options)
|
||||||
localCode | c++; local static functions
|
localCode | c++; local static functions
|
||||||
code | c++; patch value assignment
|
code | c++; patch value assignment
|
||||||
|
codeContext | additional dictionary context for the code
|
||||||
\endplaintable
|
\endplaintable
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
@ -52,6 +53,11 @@ Usage
|
|||||||
value uniform 0;
|
value uniform 0;
|
||||||
name rampedFixedValue; // name of generated BC
|
name rampedFixedValue; // name of generated BC
|
||||||
|
|
||||||
|
codeContext
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
code
|
code
|
||||||
#{
|
#{
|
||||||
operator==(min(10, 0.1*this->db().time().value()));
|
operator==(min(10, 0.1*this->db().time().value()));
|
||||||
@ -83,6 +89,10 @@ Usage
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
The code context dictionary can be supplied separately as the
|
||||||
|
\c codeContext entry.
|
||||||
|
|
||||||
See also
|
See also
|
||||||
Foam::dynamicCode
|
Foam::dynamicCode
|
||||||
Foam::functionEntries::codeStream
|
Foam::functionEntries::codeStream
|
||||||
@ -138,6 +148,9 @@ class codedFixedValueFvPatchField
|
|||||||
//- Clear redirected object(s)
|
//- Clear redirected object(s)
|
||||||
virtual void clearRedirect() const;
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
|
//- Additional 'codeContext' dictionary to pass through
|
||||||
|
virtual const dictionary& codeContext() const;
|
||||||
|
|
||||||
//- The code dictionary. Inline "code" or from system/codeDict
|
//- The code dictionary. Inline "code" or from system/codeDict
|
||||||
virtual const dictionary& codeDict() const;
|
virtual const dictionary& codeDict() const;
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,15 @@ void Foam::codedMixedFvPatchField<Type>::clearRedirect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
const Foam::dictionary&
|
||||||
|
Foam::codedMixedFvPatchField<Type>::codeContext() const
|
||||||
|
{
|
||||||
|
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||||
|
return (ptr ? *ptr : dictionary::null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
const Foam::dictionary&
|
const Foam::dictionary&
|
||||||
Foam::codedMixedFvPatchField<Type>::codeDict() const
|
Foam::codedMixedFvPatchField<Type>::codeDict() const
|
||||||
@ -240,6 +249,21 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
|
|||||||
).ptr()
|
).ptr()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Forward copy of dictionary content to the code template
|
||||||
|
auto* contentPtr =
|
||||||
|
dynamic_cast<dictionaryContent*>(redirectPatchFieldPtr_.get());
|
||||||
|
|
||||||
|
if (contentPtr)
|
||||||
|
{
|
||||||
|
contentPtr->dict(this->codeContext());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< name_ << " Did not derive from dictionaryContent"
|
||||||
|
<< nl << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return *redirectPatchFieldPtr_;
|
return *redirectPatchFieldPtr_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ Description
|
|||||||
codeLibs | linker line: added to LIB_LIBS (Make/options)
|
codeLibs | linker line: added to LIB_LIBS (Make/options)
|
||||||
localCode | c++; local static functions;
|
localCode | c++; local static functions;
|
||||||
code | c++; patch value assignment
|
code | c++; patch value assignment
|
||||||
|
codeContext | additional dictionary context for the code
|
||||||
\endplaintable
|
\endplaintable
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
@ -93,6 +94,10 @@ Usage
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
The code context dictionary can be supplied separately as the
|
||||||
|
\c codeContext entry.
|
||||||
|
|
||||||
See also
|
See also
|
||||||
Foam::dynamicCode
|
Foam::dynamicCode
|
||||||
Foam::functionEntries::codeStream
|
Foam::functionEntries::codeStream
|
||||||
@ -150,6 +155,9 @@ protected:
|
|||||||
//- Clear redirected object(s)
|
//- Clear redirected object(s)
|
||||||
virtual void clearRedirect() const;
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
|
//- Additional 'codeContext' dictionary to pass through
|
||||||
|
virtual const dictionary& codeContext() const;
|
||||||
|
|
||||||
//- The code dictionary. Inline "code" or from system/codeDict
|
//- The code dictionary. Inline "code" or from system/codeDict
|
||||||
virtual const dictionary& codeDict() const;
|
virtual const dictionary& codeDict() const;
|
||||||
|
|
||||||
|
|||||||
@ -72,6 +72,14 @@ void Foam::functionObjects::codedFunctionObject::clearRedirect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::dictionary&
|
||||||
|
Foam::functionObjects::codedFunctionObject::codeContext() const
|
||||||
|
{
|
||||||
|
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||||
|
return (ptr ? *ptr : dictionary::null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::dictionary&
|
const Foam::dictionary&
|
||||||
Foam::functionObjects::codedFunctionObject::codeDict() const
|
Foam::functionObjects::codedFunctionObject::codeDict() const
|
||||||
{
|
{
|
||||||
@ -157,6 +165,22 @@ Foam::functionObjects::codedFunctionObject::redirectFunctionObject() const
|
|||||||
time_,
|
time_,
|
||||||
constructDict
|
constructDict
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Forward copy of codeContext to the code template
|
||||||
|
auto* contentPtr =
|
||||||
|
dynamic_cast<dictionaryContent*>(redirectFunctionObjectPtr_.get());
|
||||||
|
|
||||||
|
if (contentPtr)
|
||||||
|
{
|
||||||
|
contentPtr->dict(this->codeContext());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< name_ << " Did not derive from dictionaryContent"
|
||||||
|
<< nl << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return *redirectFunctionObjectPtr_;
|
return *redirectFunctionObjectPtr_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@ Description
|
|||||||
codeExecute | c++; upon functionObject::execute()
|
codeExecute | c++; upon functionObject::execute()
|
||||||
codeWrite | c++; upon functionObject::write()
|
codeWrite | c++; upon functionObject::write()
|
||||||
codeEnd | c++; upon functionObject::end()
|
codeEnd | c++; upon functionObject::end()
|
||||||
|
codeContext | additional dictionary context for the code
|
||||||
\endplaintable
|
\endplaintable
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
@ -67,6 +68,10 @@ Usage
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
The code context dictionary can be supplied separately as the
|
||||||
|
\c codeContext entry.
|
||||||
|
|
||||||
See also
|
See also
|
||||||
Foam::functionObject
|
Foam::functionObject
|
||||||
Foam::codedBase
|
Foam::codedBase
|
||||||
@ -128,6 +133,9 @@ protected:
|
|||||||
//- Clear redirected object(s)
|
//- Clear redirected object(s)
|
||||||
virtual void clearRedirect() const;
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
|
//- Additional 'codeContext' dictionary to pass through
|
||||||
|
virtual const dictionary& codeContext() const;
|
||||||
|
|
||||||
//- The code dictionary
|
//- The code dictionary
|
||||||
virtual const dictionary& codeDict() const;
|
virtual const dictionary& codeDict() const;
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,15 @@ void Foam::PatchFunction1Types::CodedField<Type>::clearRedirect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
const Foam::dictionary&
|
||||||
|
Foam::PatchFunction1Types::CodedField<Type>::codeContext() const
|
||||||
|
{
|
||||||
|
// What else would make sense?
|
||||||
|
return dict_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
const Foam::dictionary&
|
const Foam::dictionary&
|
||||||
Foam::PatchFunction1Types::CodedField<Type>::codeDict
|
Foam::PatchFunction1Types::CodedField<Type>::codeDict
|
||||||
@ -148,6 +157,10 @@ Foam::PatchFunction1Types::CodedField<Type>::CodedField
|
|||||||
dict_(dict),
|
dict_(dict),
|
||||||
name_(dict.getOrDefault<word>("name", entryName))
|
name_(dict.getOrDefault<word>("name", entryName))
|
||||||
{
|
{
|
||||||
|
this->codedBase::setCodeContext(dict_);
|
||||||
|
|
||||||
|
// No additional code chunks...
|
||||||
|
|
||||||
updateLibrary(name_);
|
updateLibrary(name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +215,21 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
|
|||||||
this->faceValues()
|
this->faceValues()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Forward copy of codeContext to the code template
|
||||||
|
auto* contentPtr =
|
||||||
|
dynamic_cast<dictionaryContent*>(redirectFunctionPtr_.get());
|
||||||
|
|
||||||
|
if (contentPtr)
|
||||||
|
{
|
||||||
|
contentPtr->dict(this->codeContext());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< name_ << " Did not derive from dictionaryContent"
|
||||||
|
<< nl << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return *redirectFunctionPtr_;
|
return *redirectFunctionPtr_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,10 @@ Usage
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
The code context dictionary is simply the dictionary used to specify
|
||||||
|
the PatchFunction1 coefficients.
|
||||||
|
|
||||||
See also
|
See also
|
||||||
Foam::dynamicCode
|
Foam::dynamicCode
|
||||||
Foam::codedFixedValue
|
Foam::codedFixedValue
|
||||||
@ -132,6 +136,9 @@ protected:
|
|||||||
//- Clear redirected object(s)
|
//- Clear redirected object(s)
|
||||||
virtual void clearRedirect() const;
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
|
//- Additional 'codeContext' dictionary to pass through
|
||||||
|
virtual const dictionary& codeContext() const;
|
||||||
|
|
||||||
// Get the code (sub)dictionary
|
// Get the code (sub)dictionary
|
||||||
virtual const dictionary& codeDict(const dictionary& dict) const;
|
virtual const dictionary& codeDict(const dictionary& dict) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user