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

interfoam - maximal velocity in water phase

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 27, 2015, 21:47
Default interfoam - maximal velocity in water phase
  #1
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 14
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, 03:25
Default
  #2
Member
 
Mattia de\' Michieli Vitturi
Join Date: Mar 2009
Posts: 50
Rep Power: 17
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, 03:52
Default
  #3
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

Old   October 28, 2015, 08:26
Default
  #4
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 14
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, 10:14
Default
  #5
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

Old   October 28, 2015, 10:48
Default
  #6
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 14
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, 01:41
Default
  #7
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

Old   November 6, 2020, 06:49
Question does this work in parallel?
  #8
Member
 
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8
JM27 is on a distinguished road
Hi,

Thanks for the interesting post. I have tested this code on the depthCharge tutorial and it works perfectly when running in serial. However it does not work in parallel, and crashes after the first time-step without writing the max velocity in the liquid. I am using scotch for decomposition.

Have you also tried this code in parallel and has it worked for you?
JM27 is offline   Reply With Quote

Old   November 6, 2020, 07:42
Default
  #9
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 14
matejmuller is on a distinguished road
Hi, for me it works also in parallel (I also use scotch):

for max Ux:

Code:
max(pos(alpha1-0.5)*U.component(0)).value()
best regards, Matej
matejmuller is offline   Reply With Quote

Old   November 6, 2020, 08:45
Default
  #10
Member
 
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8
JM27 is on a distinguished road
Hi Matej,

Thanks for the response especially on a not so recent post. May I ask which OF version you are using?

I am using v5. Just trying to understand what could be causing the issue as I never had trouble with coded function objects in parallel until now.

This is the error I get when running in parallel:

Code:
maxU: Fatal error in MPI_Recv: Message truncated, error stack:
MPI_Recv(224).....................: MPI_Recv(buf=0x7ffd14e0b6b0, count=8, MPI_BYTE, src=1, tag=1, MPI_COMM_WORLD, status=0x7ffd14e0b620) failed
MPIDI_CH3U_Receive_data_found(131): Message from rank 1 and tag 1 truncated; 5816 bytes received but buffer size is 8
I suspect max might be causing the issue in parallel, but still testing.
JM27 is offline   Reply With Quote

Old   November 6, 2020, 09:08
Default
  #11
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 14
matejmuller is on a distinguished road
I actually didn't use this in the coded function object (i don't think that was an option back then). I've compiled a new solver and put the code somewhere at the end of interFoam.C

best regards, m
matejmuller is offline   Reply With Quote

Old   November 6, 2020, 11:57
Smile resolved
  #12
Member
 
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8
JM27 is on a distinguished road
Hi Matej,

That must explain why you did not run into this issue when running in parallel.

As I suspected, the MPI error arises due to the max keyword inside Pstream (for those using coded function object). For others who might encounter this issue: I have resolved this by rewriting some of the code, similar to that described in this post:

coded function object in parallel

Thanks again Matej for your input
JM27 is offline   Reply With Quote

Old   November 12, 2020, 08:24
Default
  #13
Member
 
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8
JM27 is on a distinguished road
Hi,

I am now trying to use a similar code to calculate the largest negative value of Uy in the liquid phase. However, I have so far been unable to do this.

I have tried replacing max with min, but this will print the minimum positive/absolute value rather than the largest negative value of Uy:

Code:
min(pos(alpha1-0.5)*U.component(1)).value()
using the above code, the minimum value is not the largest negative value I can see in paraview.

Any ideas of how to do this?

p.s. I've also tried changing pos with neg but I understand this would mean that the maximum being calculated is that of alpha2 and not alpha1.
JM27 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
Setting the height of the stream in the free channel kevinmccartin CFX 12 October 13, 2022 21:43
[swak4Foam] mass conservation of solid phase violated when using groovyBC with twoPhaseEulerFoam xpqiu OpenFOAM Community Contributions 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 07:10


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