CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

interfoam - maximal velocity in water phase

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 27, 2015, 22:47
Default interfoam - maximal velocity in water phase
  #1
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 22
Rep Power: 7
matejmuller is on a distinguished road
Hi!

I want to get the maximal velocities for each velocity component in the water phase in each time step and get them in the log file. I've tried:

Code:
scalar maxUx_water=0
forAll(U,celli)
{
    if (alpha1[celli]>0.5)
        {
	      if (U[celli].x() > maxUx_water)
           {
              maxUx_water = U[celli].x();
           }
        }
}
Info<< "maxUx_water= "<< maxUx_water << endl;
but something is not working correctly. The values are not right (they are too small). Any ideas how to solve this?

Thanks!

Matej
matejmuller is offline   Reply With Quote

Old   October 28, 2015, 04:25
Default
  #2
Member
 
Mattia de\' Michieli Vitturi
Join Date: Mar 2009
Posts: 45
Rep Power: 9
demichie is on a distinguished road
I think you need the absolute value here:

maxUx_water = U[celli].x()



Mattia
demichie is offline   Reply With Quote

Old   October 28, 2015, 04:52
Default
  #3
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 1,163
Rep Power: 20
akidess will become famous soon enough
Code:
Info << "maxU: " << pos(alpha1-0.5)*max(U) << endl;
or, if you want just a component:
Code:
Info << "maxU: " << pos(alpha1-0.5)*max(U.component(0)) << endl;
(as Mattia already pointed out you may want to also print the minimum or use absolute values)

How do you know your values are too small?
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Join the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oHPxcPqde7HtA2
akidess is offline   Reply With Quote

Old   October 28, 2015, 09:26
Default
  #4
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 22
Rep Power: 7
matejmuller is on a distinguished road
Hi!

Thanks for the responses.

Mattia, I need the minimal component values too, so I thought I'd use the
same code as for the maximal.

Anton, with my approach the given velocity values are smaller than obtained in postprocessing in paraView.

I don't know what the code pos(alpha1-0.5) does exactly, but the whole line

Code:
Info << "maxU: " << pos(alpha1-0.5)*max(U.component(0)) << endl;
gives a list of velocities for all cells. Weirdly, the values are eather 0, or the same value as max(U.component(0)).

regards, matej
matejmuller is offline   Reply With Quote

Old   October 28, 2015, 11:14
Default
  #5
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 1,163
Rep Power: 20
akidess will become famous soon enough
Are you looking at cell values or interpolated values in Paraview?

I made a mistake in my code - pos() will return 1 whenever the expression in the brackets is positive, otherwise negative. And it does so for every cell, which is why you got what you got. So how to fix this?


.
.
.

Info << "maxU: " << max(pos(alpha1-0.5)*U.component(0)) << endl;

Too bad I couldn't hide the answer behind a spoiler tag
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Join the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oHPxcPqde7HtA2
akidess is offline   Reply With Quote

Old   October 28, 2015, 11:48
Default
  #6
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 22
Rep Power: 7
matejmuller is on a distinguished road
I'm looking the cell values in paraView, and now they are correct! Thank you.

Although, the line above gives:

Code:
maxU: max((pos((alpha.water-0.5))*U.component(0))) [0 1 -1 0 0 0 0] 0.549513
and I need only the values like:

Code:
maxU: 0.549513
Any ideas?

Matej
matejmuller is offline   Reply With Quote

Old   October 30, 2015, 02:41
Default
  #7
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 1,163
Rep Power: 20
akidess will become famous soon enough
Yes, what you want is the value. Hence
Code:
max((pos((alpha.water-0.5))*U.component(0))).value()
should do the trick.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Join the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oHPxcPqde7HtA2
akidess is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the height of the stream in the free channel kevinmccartin CFX 10 July 9, 2015 21:36
mass conservation of solid phase violated when using groovyBC with twoPhaseEulerFoam xpqiu OpenFOAM Running, Solving & CFD 8 June 17, 2015 02:08
InterFoam average WATER velocity along a line and plot over time Nick_civ OpenFOAM Post-Processing 0 June 20, 2014 06:17
Discontinuity at water level in stratified 2 phase flow kbaker CFX 24 June 14, 2012 07:37
uptodate water distribution network fredius,magige,tanzanian,(e.a) Main CFD Forum 0 January 27, 2002 08:10


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