# Extracting 2D velocity from the 3D velocity field

 Register Blogs Members List Search Today's Posts Mark Forums Read

April 23, 2014, 11:20
Extracting 2D velocity from the 3D velocity field
#1
Member

Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 94
Rep Power: 15
Dear foamers
I have a 3D velocity filed Ux Uy Uz and from it I need to extract the flow in the horizontal plane, namely Ux and Ux, as in Uh = (Ux, Uy, 0). I need "Uh" to be volVectorField just as the general "U" field.

First I did "foamCalc components U" in the case dir.
Thereafter I loaded Ux, Uy, Uz (each is volScalarField)
Created "volVectorField U_horizontal"
Thereafter I tried something stupid like
"U_horizontal = vector(Ux,Uy,0);", which doesnt work, likely becouse vector is not volVectorField compatible.

Do anybody know how to do this?

Cheers
JonW

P.s. you can see the whole implementation from horizontal.zip
Attached Files
 horizontal.zip (1.4 KB, 9 views)

 April 25, 2014, 00:06 #2 Senior Member     Kyle Mooney Join Date: Jul 2009 Location: San Francisco, CA USA Posts: 323 Rep Power: 14 Is your goal to be able to post-process a velocity field on a plane? If so, take a look at the 'sample' utility. There you can define a plane and set the field values you want to extract / interpolate onto it. There is an example dictionary here: Code: `/applications/utilities/postProcessing/sampling/sample/` Cheers! Kyle

 April 25, 2014, 18:06 #3 Member   Jon Elvar Wallevik Join Date: Nov 2010 Location: Reykjavik, ICELAND Posts: 94 Rep Power: 15 Thanks for the info Kyle, (and thanks for responding) This was not exactly what I had in mind. I think you approach using the interpolationScheme cellPoint; would work. But it will require me to do some re-programming in terms of analysis/post processing. So in the name of my laziness, I was hoping to make as I mentioned above, so I can use my code in its current state. But, I will use what suggest in the end, if I don't find the solution. Here is some other fatal tests, now in trying to extract the vertical velocity U_z, with a different approach (without having to use "foamCalc components U" to generate volScalarFields Ux Uy and Uz): First I generated an empty volVectorField U_z (in the same manner as U_h in the above file), thereafter I tried the following: U_z = vector(0,0,U.component(vector::Z).value()); U_z = vector(0,0,U.component(vector::Z)); U_z = vector(0,0,U.value().component(2)); .value() would never work as it is dimensionless, but anyway had to try. As I mentioned before, I think vector is not volVectorField compatible, and thus the above breaks. Cheers Jon

May 3, 2014, 10:51
#5
Member

Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 94
Rep Power: 15
It is better to have the file (of the above), so here is the download...
J.
Attached Files
 generateUxy2.zip (592 Bytes, 11 views)