Need ur help
Dear Foamers,
i have a volScalarField (say X) whose value at the patches and cells depends on the cell values of another volScalarField (sayY). i am able to change the value of X at the cells using forAll(X, celli) { if (Y[celli] ==0) {X[celli] =a;} else {X[celli]=b;}} however i am unable to do the same for the patches of X i.e if Y[celli] =0 where celli is any boundary cell then X[patchi] should be set to 'a' else it should be set to 'b'.something like this forAll(X.boundaryField(), patchi) { //if (Y[celli] ==0) ,this represents any boundary cell value of field Y {X.boundaryField()[patchi] =a;} else {X.boundaryField()[patchi]=b;}} can someone can give a detailed code to accomplish this task? i m new to openfoam. any kind of help is greatly appreciated. thanks in advance. 
I would do this:
Code:
forAll(X.boundaryField(), patchi)

Hi Adhiraj
thanks a lot for your kind help .i will just try it out .and yes i had typo in the if loop. thanks alot. regards mandeep 
Hi Adhiraj,
I tried it and worked great.in my actual code the x field is assigned value 'a' if 0<y<1 and 'b' if y=1. so the issue of 0 didn't comeup.once again thanks alot for ur kind help regards mandeep 
Good that it worked. :)
The issue is not with zero in particular; two doubles should not be compared directly like this Code:
x==y Code:
abs(xy)<=epsilon 
All times are GMT 4. The time now is 06:10. 