CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to get density-field for compressible flow?

Register Blogs Community New Posts Updated Threads Search

Like Tree31Likes
  • 2 Post By gschaider
  • 10 Post By bgoeppner
  • 4 Post By Endel
  • 5 Post By Tobi
  • 10 Post By pooyanni

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2010, 06:59
Default How to get density-field for compressible flow?
  #1
New Member
 
Benedikt Goeppner
Join Date: Jan 2010
Posts: 15
Rep Power: 16
bgoeppner is on a distinguished road
Hi there,

I was wondering how to get the density-field if using some compressible solver?

Beside rhoCentralFoam I think all other solvers define rho as a NOWRITE-object (like basicThermo does with psi, too). As density and compressiblity are a fundamental thing of compressible flow - if not it would be incompressible, right? - there should be a way to visualize those fields in postprocessing, shouldn't it?

Or do I have to calculate the Mach-Number, out of that the compressiblity, and according to this finally the density? Sounds complicated to me..

Is it advisable as an easy solution to create a new solver as a copy of the existing one, say sonicFoam, with rho defined as AUTOWRITE-object?

Ben
bgoeppner is offline   Reply With Quote

Old   April 15, 2010, 09:32
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bgoeppner View Post
Hi there,

I was wondering how to get the density-field if using some compressible solver?

Beside rhoCentralFoam I think all other solvers define rho as a NOWRITE-object (like basicThermo does with psi, too). As density and compressiblity are a fundamental thing of compressible flow - if not it would be incompressible, right? - there should be a way to visualize those fields in postprocessing, shouldn't it?

Or do I have to calculate the Mach-Number, out of that the compressiblity, and according to this finally the density? Sounds complicated to me..

Is it advisable as an easy solution to create a new solver as a copy of the existing one, say sonicFoam, with rho defined as AUTOWRITE-object?

Ben
The rho-Field is there. It's just not being written. I think I saw somewhere in recent commits of 1.6.x a functionObject that lets you write such fields. Alternatively you can try writeFieldsAdditional from http://openfoamwiki.net/index.php/Co...unctionObjects
hogsonik and Flexflix like this.
gschaider is offline   Reply With Quote

Old   April 15, 2010, 11:59
Default
  #3
New Member
 
Benedikt Goeppner
Join Date: Jan 2010
Posts: 15
Rep Power: 16
bgoeppner is on a distinguished road
Hi Bernhard,

thanks for your quick reply. That sounds exactly what I'm looking for. Unfortunately I'm not very used to functionObjects in OpenFOAM right now and the official documention does not offer a lot of instructions about that, too... There's just a general reference to the tutorials-folder... ;-)

I will also check out your tools from the link you posted and have a look at the README-file, as well as I'm currently trying to understand the source-code.

Anyway, if you have any suggestions on where to get more information regarding this topic or if you could give some examples how to use those objects, that would be great!

Edit: I had a look at the source guide and some other resources... Am I right that the following steps would solve my problem?

1) Add some functions to the controlDict:
Code:
functions
(
  rho
  {
    type     writeRegisteredObject;
    functionObjectLibs   ("libfunctionObjects.so");
    objectNames
    (
      rho
    );
  }
)
2) if postprocessing then: Call execFlowFunctionObjects
or if having added the functions-section to control-dict before running the case, everything should be fine anyway

I will try that as soon as I'm back at my simulation-computer...

Last edited by bgoeppner; April 15, 2010 at 13:23.
bgoeppner is offline   Reply With Quote

Old   April 15, 2010, 13:48
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bgoeppner View Post
thanks for your quick reply. That sounds exactly what I'm looking for. Unfortunately I'm not very used to functionObjects in OpenFOAM right now and the official documention does not offer a lot of instructions about that, too... There's just a general reference to the tutorials-folder... ;-)

I will also check out your tools from the link you posted and have a look at the README-file, as well as I'm currently trying to understand the source-code.

Anyway, if you have any suggestions on where to get more information regarding this topic or if you could give some examples how to use those objects, that would be great!
You're on the right track. There is not much more material that I know of.
gschaider is offline   Reply With Quote

Old   April 16, 2010, 07:54
Thumbs up Problem solved
  #5
New Member
 
Benedikt Goeppner
Join Date: Jan 2010
Posts: 15
Rep Power: 16
bgoeppner is on a distinguished road
Just in case someone's having the same problem and is using the search-function, here's the solution:

Add the following to your controlDict:
Code:
functions
{
   rhofunc
   {
      type                 writeRegisteredObject;
      functionObjectLibs   ("libIOFunctionObjects.so");
/*      outputControl        outputTime;*/
      outputControl        timeStep;
      outputInterval       1;
      objectNames
      (
         "rho"
         "psi"
      );
   }
}
If you insert this before running your case, you should have
Code:
outputControl    outputTime
enabled, otherwise (if you run the case without this section) you should have
Code:
outputControl    timeStep
enabled. Then just run
Code:
execFlowFunctionObjects
from your case-directory.

Have fun!
bgoeppner is offline   Reply With Quote

Old   September 9, 2013, 08:37
Default
  #6
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
Hi
for notice:
rhoCentralFoam now (in 2.2.0 version) writes "rho" field itself but doesn't write "phi" field.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   September 29, 2016, 12:04
Default OpenFOAM 4.0: postProcess "rho" field after sonicFoam simulation
  #7
New Member
 
Join Date: Sep 2012
Posts: 13
Rep Power: 15
Endel is on a distinguished road
Hi everyone,

I am using OpenFOAM 4.0 and it seems, that the above solution doesn't work like that anymore. When I follow the work flow above and try to execute
Code:
execFlowFunctionObjects
I get an error message, saying: "execFlowFunctionObjects
execFlowFunctionObjects has been superceded by the '-postProcess' solver command-line option"

I can't figure out a way to calculate the "rho" field after having run the sonicFoam solver. I tried using the postProcess utility but only seem to get more error messages...

I would be very glad about any help!

Thank you very much
Endel is offline   Reply With Quote

Old   January 18, 2017, 11:14
Default
  #8
New Member
 
Join Date: Sep 2012
Posts: 13
Rep Power: 15
Endel is on a distinguished road
Meanwhile I figured out, that the writeRegisteredObject type was superseded by the writeObjects type. Reading one error message after another, I edited the function given above to the following:

Code:
functions
{
   rhofunc
   {
      type                 writeObjects;
      libs            ("libutilityFunctionObjects.so");
      writeControl        timeStep;
      writeInterval       1;
      objects
      ("rho");
   }
}
Executing this with the command

Code:
sonicFoam -postProcess
from my case directory, the utility finally wrote a rho field, which I could display in paraview.

However, the rho field is much to small, on the 10⁻11 level and doesn't show physical behavior...

Does anyone know, whether the function I implemented is still wrong and leads to the faulty results?
nimasam, Tobi, hogsonik and 1 others like this.
Endel is offline   Reply With Quote

Old   March 28, 2017, 12:03
Unhappy
  #9
New Member
 
Eric Emdee
Join Date: Mar 2017
Posts: 6
Rep Power: 9
eemdee is on a distinguished road
Hey Endel, I'm trying to do pretty much the exact same thing (getting density fields from sonicFoam) did you ever figure out how to get the solver to get the correct results?
eemdee is offline   Reply With Quote

Old   March 29, 2017, 11:33
Default
  #10
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

I have no idea about the postProcess tool but if you want to have the density field you can do the following (not the optimal way):

  • Go to your sonicFoam source files
  • edit createFields.H
  • Change the volScalarField rho as follows:
Code:
volScalarField rho
(
    IOobject
    (
        "rho",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    thermo.rho()
);
  • After that re-compile wmake
  • Done

Doing that, the solver will write the density file. I checked it with the shockTube tutorial and the density seems to be okay (0.125 - 0.998). But I have no idea in which range the density can go in shock waves.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   March 29, 2017, 15:09
Default
  #11
New Member
 
Eric Emdee
Join Date: Mar 2017
Posts: 6
Rep Power: 9
eemdee is on a distinguished road
This worked for me, though I have yet to confirm whether it is physical or not. One question though, why do you say that this isn't the optimal way?

Thanks a lot for your help!
eemdee is offline   Reply With Quote

Old   March 29, 2017, 15:13
Default
  #12
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

I said this might be not the optimal way because if you could do it in a post-processing way I would prefer this instead of recompiling. Maybe there are smarter way that I do not know. If the way of Endel would work, it would be smarter, right? And in fact, I am not an expert. Well, if it works for you, I am happy. Good luck and the density field you write is actually the one FOAM uses.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 26, 2017, 08:51
Default Adding different density values
  #13
New Member
 
Sarath Raj
Join Date: Nov 2016
Posts: 3
Rep Power: 10
Aadithya is on a distinguished road
Hlo friends...

I am using interFoam solver is it possible to add different density values in the same case file by using setFields utility.????????
Aadithya is offline   Reply With Quote

Old   April 26, 2017, 20:23
Default
  #14
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Aadithya View Post
Hlo friends...

I am using interFoam solver is it possible to add different density values in the same case file by using setFields utility.????????
No. In the classic interFoam the rhos of the two phases are constant values and the overall rho is calculated according to the alpha-field
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   June 10, 2019, 19:19
Default Using inline -postProcess tool
  #15
New Member
 
pooyan
Join Date: Mar 2013
Location: Boston, US
Posts: 6
Rep Power: 13
pooyanni is on a distinguished road
Quote:
Originally Posted by Endel View Post
Meanwhile I figured out, that the writeRegisteredObject type was superseded by the writeObjects type. Reading one error message after another, I edited the function given above to the following:

Code:
functions
{
   rhofunc
   {
      type                 writeObjects;
      libs            ("libutilityFunctionObjects.so");
      writeControl        timeStep;
      writeInterval       1;
      objects
      ("rho");
   }
}
Executing this with the command

Code:
sonicFoam -postProcess
from my case directory, the utility finally wrote a rho field, which I could display in paraview.

However, the rho field is much to small, on the 10⁻11 level and doesn't show physical behavior...

Does anyone know, whether the function I implemented is still wrong and leads to the faulty results?

I think you can simply write the following line after the simulation is done and it should write the rho field for all the simulated times:

Code:
sonicFoam -postProcess -func 'writeObjects(rho)'
Best
Tobi, acgnipper, AnnaF and 7 others like this.
pooyanni is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Flow meter Design CD adapco Group Marketing Siemens 3 June 21, 2011 09:33
rerun with same flow field, different fluid props Tim Phoenics 0 March 3, 2004 15:51
Injection of partical into flow field M.Mahendran FLUENT 2 November 24, 2002 01:54
Inviscid Drag at subsonic, subcritical Mach # Axel Rohde Main CFD Forum 1 November 19, 2001 13:19
Flow field measurement in turbomachinery! Wanlai Lin Main CFD Forum 3 September 3, 1999 13:06


All times are GMT -4. The time now is 22:57.