CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   power of vectorField (https://www.cfd-online.com/Forums/openfoam-programming-development/140609-power-vectorfield.html)

matthias August 19, 2014 08:52

power of vectorField
 
Hi,

I need the element-wise power of a vectorField (or a volVectorField), e.g.

vectorField V;
pow(V, 0.7)

with pow(V.X(), 0.7) , pow(V.Y(), 0.7) and pow(V.Z(), 0.7).

A possible way could be to use the component method as

Code:

scalarField x = pow(V.component(vector:X), 0.7);
scalarField y = pow(V.component(vector:Y), 0.7);
scalarField z = pow(V.component(vector:Z), 0.7);

and to create a new vector Field and to set the single components

Code:

vectorField tmp = x*vector(0,0,0);

tmp.component(0) = x;
tmp.component(1) = y;
tmp.component(2) = z;


All in all, it is working but I think there must be a better way to do that or has OF already such function?

Best regards

Matthias


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