CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   dieselfoam - How to print variables? (

mystix September 14, 2010 04:34

dieselfoam - How to print variables?
Hallo Foamers,

I try to analyze sprays using the dieselfoam-solver.

And I want to print out some variables (Xratio, denominator, Sh, Nu...) over time, but I dont know how.

Can someone help me please?

Thank you in advance!

Edison_Ge September 14, 2010 08:05

My way of achieving this would be add the desired field variable in creatField.H and in the solver assign the related valued to the added field variables. Give it a go, but there may be other smarter way of doing it.

mystix September 14, 2010 09:31

The problem is there is no createFields.H file for the dieselFoam solver.

Palminchi September 14, 2010 10:30

Yes, there is a createFields.H in dieselFoam. If it is not in the dieselFoam directory, it is located in the dieselEngineFoam one. If you check the options file inside the Make dir, you will see that there is a list of routes which mean that when the solver looks for createFields, if isn't in the solver's dir, it will look for it where options file says. Anyway, you can copy createFields.H to your dieselFoam directory and then add the fields or variables you want to have.

Best regards!

mystix September 16, 2010 11:55

Thank you for answers, I copied createFields.H from the dieselEngineFoam to the dieselFoam directory and added the variable Xratio:

volScalarField Xratio
dimensionedScalar("Xratio", dimless, 0.0)

Now there is a Xratio file in the timestep folder but, the values for Xratio are always 0. That can't be right.

Someone can help me print out the Xratio data please?

mturcios777 September 16, 2010 13:40

I'm currently trying to to figure this out myself. Here, you've created the field and set it to write on timestep output, but it has been initialized with a value of 0 everywhere, and no indication (here anyway) of where this field is calculated.

This variable isn't built in to dieselFoam, have you implemented it yourself elsewhere?

Edison_Ge September 17, 2010 02:14

you'll have to assign value to the new variable in the solver. Just like what happens to velocity U and pressure p

mystix September 17, 2010 04:22

Xratio is declared, initialized and calculated in


How can I assign the related valued to the added field variables?

Edison_Ge September 17, 2010 09:03

hi Markus,
From what I can understand Xratio is a local variable so you can not assin its value to the new field object you've just create. You can try to make it a class member and then give it a return function. Then you can assign the Xratio value to the new field object.
Take Nu for example, there's a return funtion Nu() for Nu. So in the solver you can assign Nu to a new object, simply write
objectX = turbulenc->Nu();
But i'm not that familiar with c++, there may be a easier way.

All times are GMT -4. The time now is 07:39.