interfoam - maximal velocity in water phase
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 Thanks! Matej |
I think you need the absolute value here:
maxUx_water = U[celli].x() Mattia |
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? |
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 |
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 ;) |
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 |
Yes, what you want is the value. Hence
Code:
max((pos((alpha.water-0.5))*U.component(0))).value() |
does this work in parallel?
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? |
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() |
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: |
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 |
resolved
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: https://www.cfd-online.com/Forums/op...tml#post719879 Thanks again Matej for your input :) |
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. |
All times are GMT -4. The time now is 04:17. |