basic question with 'ForAll' loop
Hi all,
Strange things happen in my forAll loop. I have those two variables 'n' and 'somme_E' that are reinitialized at the end of each iteration of the for loop (which is confirmed by using the 'info' command), but when those same variables are re-used inside the forAll loop (at the next iteration) they keep their previous value (before they were reinitialized) . I wonder why. I have no error message just the wrong output. Can anybody help me? Thank you very much, Pascal Code:
scalar coord_z = 0.0; |
Quote:
I would suspect something else is going wrong with your logic. However, why are you reinitializing things anyhow instead of just using scoped variables? For example (as pseudo-code, without ANY promise that it does what you really want - or even if it compiles), Code:
scalar plan_xy = 1./128.; |
Did you get this problem solved? I am having exactly the same issue. The forAll loop does not update the variable at all.
|
Hello Yanxiang,
That make a long time ago :) I think it was a simple error in my if statement: Code:
if (diff <= 0.00002) Code:
if (abs(diff) <= 0.00002) |
Thanks, Pascal. Now it looks like I have a different issue. So I have the following code
Code:
forAll (beta, celli) yanxiang |
Hi,
Your sample of code seems all right. Could you post the entire code? It will be easier for others to give help. Pascal |
Hi Pascal,
Basically I am modifying the twoPhaseEulerFoam code, adding a couple of lines to the alphaEqn.H. Here is what I have. The above code is at the end. Thanks a lot for your help in advance Code:
{ |
Hi!
I think that this line of code : Code:
beta.correctBoundaryConditions(); Pascal |
Hi Pascal,
I tried your suggestions and I also ommented out that line. Nothing really changes. I still got negative values and I think that's the reason why the solution is not stable and blows up at some point. Thanks, yanxiang |
Yanxiang,
I don't understand why you need to do this as a loop over all cells. Can't you take advantage of the 'field operations' part of FOAM and just do a max() on beta as in: beta = max(beta, 0.0); Have you tried this instead? Should do the same thing but with one line of code. Also, have you looked at where in the domain your negative values are occurring? I guess alphas is alpha_solid (and not alphas as defined in mpEF which is 0*alpha1 + 1*alpha2 + 2*alpha3 + ... (n-1)*alphan)? If you are getting negative values of beta, that means that alpha+alphas is > 1 in places. I see that you have also changed the solution scheme and are not using MULES::explicitSolve. Note that MULES has a limiter built in to keep the sum of volume fractions equal to 1. With out this it is not surprising you are getting inaccurate solution of your phase fraction fields. This was important change in the development of mpEF. As to how to fix it here...not sure I can help there. If you indeed need to keep three volume fractions, perhaps mpEF needs another look. |
Quote:
Quote:
Thanks, yanxiang |
All times are GMT -4. The time now is 06:06. |