CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Extracting 2D velocity from the 3D velocity field

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 23, 2014, 11:20
Default Extracting 2D velocity from the 3D velocity field
  #1
Senior Member
 
Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 103
Rep Power: 19
JonW will become famous soon enough
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
File Type: zip horizontal.zip (1.4 KB, 9 views)
JonW is offline   Reply With Quote

Old   April 25, 2014, 00:06
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 17
kmooney is on a distinguished road
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
kmooney is offline   Reply With Quote

Old   April 25, 2014, 18:06
Default
  #3
Senior Member
 
Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 103
Rep Power: 19
JonW will become famous soon enough
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
JonW is offline   Reply With Quote

Old   May 1, 2014, 14:40
Default
  #4
Senior Member
 
Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 103
Rep Power: 19
JonW will become famous soon enough
To do the stuff as explained above, I wrote a simple bash scrip, which uses awk, tail, head and grep. This file is very specific for my case, and thus have to be changed for your case. You should have some rudimentary understanding of U set-up before trying this at home. I hope this will be helpful for some, as a template. I call the script for "generateUxy.sh" and consists of the following:

# --------------------------------------------------------------------
#!/bin/sh
# --------------------------------------------------------------------
# Usually, don't have to change header1.
header1=22
header2=`expr $header1 + 1`
# In my case, I read the tailer1 number from line 21 in U:
tailer1=1060080
# tailer1=554736
tailer2=`expr $tailer1 + 1`
# --------------------------------------------------------------------
echo "---------------------------------------------------------" && \
echo " Starting transformation: [Ux,Uy,Uz] -> [Ux,Uy,0] ..." && \
head --lines=+$header1 U > Uxy1.tmp && \
sed 's/object U;/object Uxy;/g' Uxy1.tmp > Uxy2.tmp && \
tail --lines=+$header2 U > Uxy3.tmp && \
head --lines=+$tailer1 Uxy3.tmp > Uxy4a.tmp && \
tail --lines=+$tailer2 Uxy3.tmp > Uxy4b.tmp && \
awk '{print $1, $2, $3*0+99999999}' Uxy4a.tmp > Uxy5.tmp && \
sed 's/99999999/0)/g' Uxy5.tmp > Uxy6.tmp && \
cat Uxy2.tmp Uxy6.tmp Uxy4b.tmp > Uxy
echo " ...done!" && \
# --------------------------------------------------------------------
echo " Cleaning temporary data..." && \
for FILE1 in *.tmp
do
rm "$FILE1"
done
echo " ...done!" && \
echo "---------------------------------------------------------"
# --------------------------------------------------------------------


Cheers
Jon
JonW is offline   Reply With Quote

Old   May 3, 2014, 10:51
Default
  #5
Senior Member
 
Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 103
Rep Power: 19
JonW will become famous soon enough
It is better to have the file (of the above), so here is the download...
J.
Attached Files
File Type: zip generateUxy2.zip (592 Bytes, 13 views)
JonW is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 91 December 21, 2022 04:50
A Question About Setting Whole Velocity Field Using "Proflie" in FLUENT adsl17754 FLUENT 5 July 31, 2018 04:29
Initial Velocity Field - 2D Turbulence in a Periodic Box AHutchison OpenFOAM Running, Solving & CFD 0 May 28, 2013 00:18
accessing another velocity field in bc daviderzen OpenFOAM 0 April 20, 2011 06:24
velocity of massless particles and velocity of flow field in same coordinate payam_IUST FLUENT 0 October 18, 2009 23:24


All times are GMT -4. The time now is 04:47.