CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   How to manipulat a volScalarField like this... (http://www.cfd-online.com/Forums/openfoam/77429-how-manipulat-volscalarfield-like.html)

masspec June 22, 2010 17:38

How to manipulat a volScalarField like this...
 
Hey there,

I get a volScalarField A,and another volScalarField B. And B is dependent on A as follows:

if the value of a particular element in A is larger than a threshold,
then the corresponding value of that element in B is a function of A as f1.

else the value of B is a function of A as f2.

I do not know how can I manipulate the volScalarField to attain such objective, and looking for some help......

Thanks a lot.:)

tiddlycorona June 22, 2010 20:29

I think what you need is just how to have access to the field value at a cell, judge it and accordingly made modification to another field.

forAll (A, celli) {

if (A[celli]) > Threshold)
B[celli] = f1(A[celli]);
else
B[celli] = f2(A[celli]);

}


Not sure if it is right. Hope more experienced Foamers can tell us how to do it.


All times are GMT -4. The time now is 00:28.