CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Write out turbulence model functions (https://www.cfd-online.com/Forums/openfoam/65297-write-out-turbulence-model-functions.html)

bae127 June 10, 2009 22:35

Write out turbulence model functions
 
I am trying to modify turbulence models and would like to write out the value of some functions. For example, in kOmegaSST.C there is a private member function called F1. I would like to write out the value of this function each time I write out the other dependent variables.

I have tried the following syntax:

if(runTime_.outputTime())
{
F1.write()
}

While technically this works, the file name which is created is not "F1", but the function representation of F1 (e.g. tanh(pow4(min(min(max((((1|betaStar)*sqrt....)

Is there any way to force OpenFOAM to name this file something meaningful, like "F1"?

waynezw0618 June 10, 2009 22:47

try IOobject
 
F1_
(
IOobject
(
"F1",
runTime_.timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),

what you want to modify?

bae127 June 10, 2009 23:23

Thanks
 
Thanks for the help. I thought I had tried this before, and it did not work. I copied your syntax and everything works fine. I must have had a typo.

While the IOobject works, I am still wonding if there is a possibility of using the ".write()" function to accomplish this. The problem with the IOobject approach is that it requires a user to add an initial condition for "F1". This is not hard, but if an inexperienced user does not know that they need this initial condition, it can lead to lots of questions for me. Does anyone know the syntax to accomplish this with ".write()" ?

waynezw0618 June 11, 2009 01:38

No it does work
i use this to output F1,and you could find out in the post before.
for initial condition i think it is not important for steady calculation.it is just a guess and after iteration it will get the correct values.
Quote:

Originally Posted by bae127 (Post 218881)
Thanks for the help. I thought I had tried this before, and it did not work. I copied your syntax and everything works fine. I must have had a typo.

While the IOobject works, I am still wonding if there is a possibility of using the ".write()" function to accomplish this. The problem with the IOobject approach is that it requires a user to add an initial condition for "F1". This is not hard, but if an inexperienced user does not know that they need this initial condition, it can lead to lots of questions for me. Does anyone know the syntax to accomplish this with ".write()" ?


ngj June 11, 2009 03:44

You could also change the

IOobject::MUST_READ

to

IOobject::NO_READ

and use a different constructor for the F1

Best regards,

Niels

bae127 June 11, 2009 07:37

NO_WRITE does not work
 
NGJ,

I know that I have tried this before... and I just did to reconfirm. If I make this change to my current code, it will compile fine. However, at run time I get an error like...

NO_READ specified for read-constructor of object F1 of class IOobject#0 Foam::error::printStack(Foam::Ostream&) in "/home/edge/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/edge/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Foam::regIOobject::readStream() in "/home/edge/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
....

You mentioned using a different constructor for F1. Could you elaborate on this a little? I appologize; I am a long time Fortran 90/95 user and am still working on learning C++.

ngj June 11, 2009 07:52

Well, then welcome to the world of C++:)

What I mean by using a different constructor is that you can choose to set it to the field of another volScalarField, e.g.

volScalarField F1
(
IOobject
(
"F1",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pd
);

as initialization, and then you can set the values on run-time! Note that the one you have used initializes based on the mesh, whereas my initializes based on another volScalarField. You will be able to find examples of this use in e.g. /interFoam/createFields.H.
You can find the documentation here:
http://foam.sourceforge.net/doc/Doxy...onedField.html

Hope it did help,

Best regards,

Niels

bae127 June 11, 2009 07:58

Thank you
 
Niels,

Thank you for the explanation. It is very helpful.


All times are GMT -4. The time now is 14:52.