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/)
-   -   Read in "Mean" values during runTime (https://www.cfd-online.com/Forums/openfoam-programming-development/156505-read-mean-values-during-runtime.html)

ChrisWe July 8, 2015 10:38

Read in "Mean" values during runTime
 
Hey FOAMERS,

i want to calculate the Dissipation in OpenFOAM in my LES (pimpleFoam). Therefore I have to calculate <du'_i/dx_j * du'_i/dx_j>.
This value has to be averaged during runtime and so my solver needs the actual UPrime2Mean values of every time step.

In OpenFOAM-2.2.0 it is very easy to read in the averaged velocity fields. You only have to add the following code into your createFields.H of your solver:
Code:

volVectorField UM
  (
  IOobject
  (
    "UMean",
    runTime.timeName(),
    mesh,
    IOobject::READ_IF_PRESENT,
    IOobject::AUTO_WRITE
  ),
    mesh,
    dimensionedVector("UM",dimLength/dimTime, vector::zero)
  );

When you compare UMean and UM, they are exactly the same (maybe deltaT shifted) and you can use UM in your solver.

When you do exactly the same in OpenFOAM-2.2.2 or OpenFOAM-2.3.0, UM will not be filled with the UMean values and UM will not be written in your timefolder. :eek:
OpenFOAM brings the following warning:

Code:

--> FOAM Warning :
    From function GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
    in file /home/iagwenze/opt/OpenFOAM/of230/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricField.C at line 108
    read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED suggests that a read constructor for field UMean would be more appropriate.

Is there anybody who knows, why the presented code is not working anymore in OpenFOAM-2.2.2 or OpenFOAM-2.3.0?
Is there another possibility to read in Mean values to your solver?

Cheers,
Christoph

fedvasu October 28, 2016 14:40

i AM FACING SIMILAR PROBLEM
 
Hi ChrisWe,

Did you solve this problem?

Or at least did you circumvent it?

Regards,

ChrisWe October 28, 2016 15:34

Hi,

I did not solve it in an elegant way, but as you mentioned, I circumvented it.
I do not exactly know how I solved it right know (I am not at my PC), but I created a new IOobject and calculated the average with some additional lines in my solver. Something like:
U_avg = U_avg * (timeSteps-1)/timeSteps + U / timeSteps

For example: When I am in my 1001th iteration, I calculate:
U_avg = U_avg * 1000/1001 + U / 1001

I was not happy with this solution, but it works.

I hope this helps...

All the best,
Christoph

fedvasu October 28, 2016 16:39

Quote:

Originally Posted by ChrisWe (Post 623358)
Hi,

I did not solve it in an elegant way, but as you mentioned, I circumvented it.
I do not exactly know how I solved it right know (I am not at my PC), but I created a new IOobject and calculated the average with some additional lines in my solver. Something like:
U_avg = U_avg * (timeSteps-1)/timeSteps + U / timeSteps

For example: When I am in my 1001th iteration, I calculate:
U_avg = U_avg * 1000/1001 + U / 1001

I was not happy with this solution, but it works.

I hope this helps...

All the best,
Christoph


Ahh.. I think that should work for me.. Yeah not elegant.

Thanks,

benqing March 31, 2018 22:48

Quote:

I did not solve it in an elegant way, but as you mentioned, I circumvented it.
I do not exactly know how I solved it right know (I am not at my PC), but I created a new IOobject and calculated the average with some additional lines in my solver. Something like:
U_avg = U_avg * (timeSteps-1)/timeSteps + U / timeSteps

For example: When I am in my 1001th iteration, I calculate:
U_avg = U_avg * 1000/1001 + U / 1001
hi ChrisWe and fedvasu,

i am a new foamer . i want to Read in "Mean" values during runTime.
did you slove this problem? Or would you mind posting your code ?

Regards,
benqing


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