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/)
-   -   Howto create runtime variable for internal field (https://www.cfd-online.com/Forums/openfoam-programming-development/181970-howto-create-runtime-variable-internal-field.html)

PositronCascade December 26, 2016 20:28

Howto create runtime variable for internal field
 
Hello everyone. Assume that I have a variable like this:

http://i.imgur.com/of7Dlmr.gif

And I want to change DT respect to T after every iteration and it should be like this, I need to get the value of that cell and evaluate DT equation, use it for iterations and write it to time folder and update it at next iteration step.

So I define it like this:

Code:

dimensionedScalar a (laminarTransport.lookup("a"));
dimensionedScalar b (laminarTransport.lookup("b"));
volScalarField DT = a*T+b

I compile it and run, everything seems okay but when I look into time folder, lets say 10, I can't get the value for each cell. Instead, it says for internal uniform 100, for instance but I want to see the distribution of DT inside the domain.

The way I am trying to calculate DT is not appropriate way? If not, call you tell me how can I define this kind of variable, please?

I hope you can help me to find my mistake!
Regards

rhythm January 5, 2017 07:33

Hi,

You have to initialise your volScalarField with IOobject as follows:

Code:

volScalarField DT
(
    IOobject
    (
        "DT",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    a*T + b
);

Hope this helps.

Cheers,
Ben


All times are GMT -4. The time now is 19:16.