CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Operate on volScalarField as whole v access elements (https://www.cfd-online.com/Forums/openfoam/96162-operate-volscalarfield-whole-v-access-elements.html)

adhiraj January 14, 2012 08:19

Operate on volScalarField as whole v access elements
 
Hi all,
If I have a volScalarField that is formed by doing something (adding, dividing, taking square roots etc) of some other volScalarFields, should I do those operations element by element, or on the whole thing at one go?
I have the element by element version implemented, and was wondering if I could get a speedup by using the other option.

owayz November 29, 2012 08:25

Hi adhiraj,
Yes you can do it as a whole. For some example you can see the yPlus utility and check how yPlus is being calculated.
Can you kindly share how did you do all the operations element wise.
regards,
Awais

adhiraj November 29, 2012 12:35

Yes, I found that I can operate on the whole thing at once, too.
I did that and I don't know if it is more efficient or anything--the code is certainly cleaner and easier to read.
I did something like
Code:

A.internalField()[celli]=std::sqrt(B.internalField()[celli]);
or similar.


All times are GMT -4. The time now is 22:38.