CodedFunction1: New Function1 which uses codeStream to dynamically compile the value function code

For example in the new tutorial case:
tutorials/incompressible/pimpleFoam/laminar/pitzDailyPulse
a cosine bell velocity pulse is specified at the inlet by directly defining the
code for it:

    inlet
    {
        type            uniformFixedValue;
        uniformValue    coded;

        name            pulse;

        codeInclude
        #{
            #include "mathematicalConstants.H"
        #};

        code
        #{
            return vector
            (
                0.5*(1 - cos(constant::mathematical::twoPi*min(x/0.3, 1))),
                0,
                0
            );
        #};
    }

which is then compiled automatically and linked into the running pimpleFoam
dynamically and executed to set the inlet velocity.
This commit is contained in:
Henry Weller
2020-01-31 23:39:59 +00:00
parent aff00a2e7e
commit 0dd2e97bd8
35 changed files with 1218 additions and 1379 deletions

View File

@ -193,13 +193,9 @@ bool Foam::codedFunctionObject::read(const dictionary& dict)
// The name keyword is "name". "redirectType" is also maintained here
// for backwards compatibility, but "name" is taken in preference and
// is printed in the error message if neither keyword is present.
name_ = word::null;
name_ = dict.lookupOrDefault("redirectType", name_);
name_ = dict.lookupOrDefault("name", name_);
if (name_ == word::null)
{
dict.lookup("name"); // <-- generate error message with "name" in it
}
name_ = dict.found("redirectType")
? dict.lookup<word>("redirectType")
: dict.lookup<word>("name");
updateLibrary(name_);
return redirectFunctionObject().read(dict);