CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   can I access to the "dict" object from codeWrite in a coded function object? (https://www.cfd-online.com/Forums/openfoam-programming-development/239146-can-i-access-dict-object-codewrite-coded-function-object.html)

NotOverUnderated October 22, 2021 09:12

can I access to the "dict" object from codeWrite in a coded function object?
 
Hello,

In a coded function object, I can access the "dict" object from within the codeRead section. However, this object is not available in the codeWrite section. Is it possible to access this object without manually creating the dictionary manually.


Code:

mfunc
{
      type coded
      libs ("libutilityFunctionObjects.so");
      name example;

      codeRead
      #{
            // the object 'dict' is available here.
      #};

      codeWrite
      #{
          // but I can't access it here. How can I access that object?
          // I have tried: this->dict but it doesn't work.
      #};
}

I appreciate your help.

Thank you

olesen October 28, 2021 15:53

Quote:

Originally Posted by NotOverUnderated (Post 814829)
Hello,

In a coded function object, I can access the "dict" object from within the codeRead section. However, this object is not available in the codeWrite section. Is it possible to access this object without manually creating the dictionary manually.


Code:

mfunc
{
      type coded
      libs ("libutilityFunctionObjects.so");
      name example;

      codeRead
      #{
            // the object 'dict' is available here.
      #};

      codeWrite
      #{
          // but I can't access it here. How can I access that object?
          // I have tried: this->dict but it doesn't work.
      #};
}

I appreciate your help.

Thank you


That got added into the OpenFOAM-v2106 release - see the merge-request information for the related commits.



https://develop.openfoam.com/Develop...ts/466/commits


Note that it uses 'this->codeContext()' to access the dictionary in question (or at least part of it). If you run into bugs, open an issue on develop.openfoam.com to discuss there.

NotOverUnderated October 28, 2021 19:46

Thank you for the answer. I have to upgrade to that latest version. Very exciting.


All times are GMT -4. The time now is 11:04.