CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to evaluate a surfaceScalarField face by face? (https://www.cfd-online.com/Forums/openfoam/120829-how-evaluate-surfacescalarfield-face-face.html)

Zheng.Zhi July 15, 2013 15:25

How to evaluate a surfaceScalarField face by face?
 
rhoPhi is defined as

surfaceScalarField rhoPhi
(
IOobject
(
"rhoPhi",
runTime.timeName(),
mesh
),
dimensionedScalar("0",dimensionSet(1,0,-1,0,0),0)
);

and it is updated after alphaEqn solved.

Now I want to create a new surfaceScalarField rhoPhi2 ,which is a function of rhoPhi, so I define

surfaceScalarField rhoPhi2
(
IOobject
(
"rhoPhi2",
runTime.timeName(),
mesh
),
dimensionedScalar("0",dimensionSet(1,0,-1,0,0),0)
);

and evaluate rhoPhi2 face by face :

forAll (rhoPhi2 , facei)
{
rhoPhi2[facei] = rhoPhi[facei];
}

but it doesn't work as same as

rhoPhi2 = rhoPhi;

Is there any mistake in my testing code? And How to evaluate a surfaceScalarField face by face?

Thanks!

l_r_mcglashan July 15, 2013 18:03

Have a look at what operator= does for fields in GeometricField.C

You need to also loop over boundaries. I would question why you need to loop though.


All times are GMT -4. The time now is 07:53.