|
[Sponsors] |
October 27, 2015, 22:47 |
interfoam - maximal velocity in water phase
|
#1 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
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; Thanks! Matej |
|
October 28, 2015, 04:25 |
|
#2 |
Member
Mattia de\' Michieli Vitturi
Join Date: Mar 2009
Posts: 51
Rep Power: 17 |
I think you need the absolute value here:
maxUx_water = U[celli].x() Mattia |
|
October 28, 2015, 04:52 |
|
#3 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Code:
Info << "maxU: " << pos(alpha1-0.5)*max(U) << endl; Code:
Info << "maxU: " << pos(alpha1-0.5)*max(U.component(0)) << endl; 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. |
|
October 28, 2015, 09:26 |
|
#4 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
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; regards, matej |
|
October 28, 2015, 11:14 |
|
#5 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
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. |
|
October 28, 2015, 11:48 |
|
#6 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
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 Code:
maxU: 0.549513 Matej |
|
October 30, 2015, 02:41 |
|
#7 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Yes, what you want is the value. Hence
Code:
max((pos((alpha.water-0.5))*U.component(0))).value()
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
November 6, 2020, 07:49 |
does this work in parallel?
|
#8 |
Member
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8 |
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? |
|
November 6, 2020, 08:42 |
|
#9 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
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() |
|
November 6, 2020, 09:45 |
|
#10 |
Member
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8 |
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 |
|
November 6, 2020, 10:08 |
|
#11 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
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 |
|
November 6, 2020, 12:57 |
resolved
|
#12 |
Member
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8 |
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 |
|
November 12, 2020, 09:24 |
|
#13 |
Member
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8 |
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() 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. |
|
|
|
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 22:43 |
[swak4Foam] mass conservation of solid phase violated when using groovyBC with twoPhaseEulerFoam | xpqiu | OpenFOAM Community Contributions | 8 | June 17, 2015 03:08 |
InterFoam average WATER velocity along a line and plot over time | Nick_civ | OpenFOAM Post-Processing | 0 | June 20, 2014 07:17 |
Discontinuity at water level in stratified 2 phase flow | kbaker | CFX | 24 | June 14, 2012 08:37 |
uptodate water distribution network | fredius,magige,tanzanian,(e.a) | Main CFD Forum | 0 | January 27, 2002 08:10 |