CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Is there code to plot stream function from u & v velocities

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2017, 07:11
Default Is there code to plot stream function from u & v velocities
  #1
Senior Member
 
kbaker's Avatar
 
Khalid Baker
Join Date: Mar 2009
Location: IRAQ
Posts: 168
Rep Power: 17
kbaker is on a distinguished road
Hello I am searching for a code can plot stream function in terms of u & v velocity components? May somebody guide me to a similar code?

Thanks
Khalid
kbaker is offline   Reply With Quote

Old   August 5, 2017, 11:17
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 272
Rep Power: 15
leflix is on a distinguished road
Hi Kbaker,

Here is a piece of code in fortran to compute the stream function from the longitudinal U componnent of the velocity field.
Let me know if you need further details.

Leflix


C************************************************* *********
SUBROUTINE STREAM (U, DY, NI, NJ, PSI)
C************************************************* *********

IMPLICIT NONE

INTEGER NI,NJ, KX,KY, I, J
PARAMETER(KX=512,KY=512)

REAL*8 U, DY,PSI


DIMENSION U(0:KX,0:KY), PSI(0:KX,0:KY)

DO I=0,NI

PSI(I,0)=0.d0

DO J=1,NJ
PSI(I,J)= PSI(I,J-1) + U(I,J)*DY
END DO

END DO

RETURN
END
leflix is offline   Reply With Quote

Old   August 5, 2017, 12:16
Default
  #3
Senior Member
 
kbaker's Avatar
 
Khalid Baker
Join Date: Mar 2009
Location: IRAQ
Posts: 168
Rep Power: 17
kbaker is on a distinguished road
Thanks Leflix for the reply. Actually I not looking for a fortran program I want to draw the stream function in Tecplot code? Do you have experience with it?

Khalid

Quote:
Originally Posted by leflix View Post
Hi Kbaker,

Here is a piece of code in fortran to compute the stream function from the longitudinal U componnent of the velocity field.
Let me know if you need further details.

Leflix


C************************************************* *********
SUBROUTINE STREAM (U, DY, NI, NJ, PSI)
C************************************************* *********

IMPLICIT NONE

INTEGER NI,NJ, KX,KY, I, J
PARAMETER(KX=512,KY=512)

REAL*8 U, DY,PSI


DIMENSION U(0:KX,0:KY), PSI(0:KX,0:KY)

DO I=0,NI

PSI(I,0)=0.d0

DO J=1,NJ
PSI(I,J)= PSI(I,J-1) + U(I,J)*DY
END DO

END DO

RETURN
END
kbaker is offline   Reply With Quote

Old   August 5, 2017, 12:21
Default
  #4
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,152
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
That shoud be part of tecplot already... at least I recall it was. You should read the manual if that feature is not particularly immediate to reach.
sbaffini is offline   Reply With Quote

Old   August 5, 2017, 12:26
Default
  #5
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,777
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
It is very easy, you have just to activate it in the menu and then click on a point in the field to have one streamline.

http://www.tecplot.com/blog/2014/10/...article-paths/
mariam.sara likes this.
FMDenaro is offline   Reply With Quote

Old   August 5, 2017, 15:16
Default
  #6
Senior Member
 
Join Date: Aug 2011
Posts: 272
Rep Power: 15
leflix is on a distinguished road
Ok ! Yes you have to upload your velocity field in 4 columns
x y Ux Uy
................
................

Then you activate streamtrace and as Filipo mentioned it click on a point you will have a streamline there. Yiu can also trace a line along the two opoosite corner of your domain and it will display sveral streamlines. Check out the documentation of tecplot.

Leflix
leflix is offline   Reply With Quote

Old   August 5, 2017, 16:44
Default
  #7
Senior Member
 
kbaker's Avatar
 
Khalid Baker
Join Date: Mar 2009
Location: IRAQ
Posts: 168
Rep Power: 17
kbaker is on a distinguished road
Attachment 57592Thanks leflix and Filippo for the information. Leflix I already did a file with four coloums i.e. x y u v I saved it as general text file when I open it in Tecplot as a text and in order to activate streamtraces I need to do triangulation. The problem when I attempt to do 2D triangulation it give me error as the attached pict? so what the problem ?

Khalid
Attached Images
File Type: jpg 1.jpg (129.5 KB, 39 views)
kbaker is offline   Reply With Quote

Old   August 5, 2017, 16:56
Default
  #8
Senior Member
 
Join Date: Aug 2011
Posts: 272
Rep Power: 15
leflix is on a distinguished road
Is your grid structured or unstructured ?
leflix is offline   Reply With Quote

Old   August 5, 2017, 17:04
Default
  #9
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
I have same problem

Quote:
Originally Posted by leflix View Post
Is your grid structured or unstructured ?
mariam.sara is offline   Reply With Quote

Old   August 5, 2017, 17:08
Default
  #10
Senior Member
 
kbaker's Avatar
 
Khalid Baker
Join Date: Mar 2009
Location: IRAQ
Posts: 168
Rep Power: 17
kbaker is on a distinguished road
Its structured grid I use meshing code to make the mesh and solve the problem using CFX code. My geometry is a sqaure cavity.

Quote:
Originally Posted by leflix View Post
Is your grid structured or unstructured ?
kbaker is offline   Reply With Quote

Old   August 5, 2017, 17:12
Default
  #11
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,777
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Check first if the data are loaded correctly and show the grid to see if it appears structured
FMDenaro is offline   Reply With Quote

Old   August 5, 2017, 17:13
Default
  #12
Senior Member
 
Join Date: Aug 2011
Posts: 272
Rep Power: 15
leflix is on a distinguished road
so you don't need to make a triangulation. Check how to format the data for structured grid. You have to loop on j and i , the number of nodes in j direction is NJ, and NI the number of nodes in the i direction.

write(1,*)'zone i=',NI,', j=', NJ,', F=POINT'

do j=1,NJ
do i=1,NI
write(1,*) Xc(i,j), Yc(i,j), U(I,J), V(I,J)
end do
end do
FMDenaro and mariam.sara like this.
leflix is offline   Reply With Quote

Old   August 5, 2017, 17:15
Default
  #13
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,777
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
leflix is correct, the first line is the header, the you can activate directly the streamtracer without triangulation
FMDenaro is offline   Reply With Quote

Old   August 5, 2017, 17:23
Default
  #14
Senior Member
 
kbaker's Avatar
 
Khalid Baker
Join Date: Mar 2009
Location: IRAQ
Posts: 168
Rep Power: 17
kbaker is on a distinguished road
I am really not sure about the type of mesh structured or not? I uploaded some picts for it?


Quote:
Originally Posted by leflix View Post
so you don't need to make a triangulation. Check how to format the data for structured grid. You have to loop on j and i , the number of nodes in j direction is NJ, and NI the number of nodes in the i direction.

write(1,*)'zone i=',NI,', j=', NJ,', F=POINT'

do j=1,NJ
do i=1,NI
write(1,*) Xc(i,j), Yc(i,j), U(I,J), V(I,J)
end do
end do
Attached Images
File Type: jpg 1.jpg (181.5 KB, 19 views)
File Type: jpg 2.jpg (141.9 KB, 15 views)
kbaker is offline   Reply With Quote

Old   August 5, 2017, 18:22
Default
  #15
Senior Member
 
Join Date: Aug 2011
Posts: 272
Rep Power: 15
leflix is on a distinguished road
It is definetely a structured grid. You can access to every nodes with 2 indices i and j.

Leflix
leflix is offline   Reply With Quote

Old   August 6, 2017, 02:13
Default
  #16
Senior Member
 
kbaker's Avatar
 
Khalid Baker
Join Date: Mar 2009
Location: IRAQ
Posts: 168
Rep Power: 17
kbaker is on a distinguished road
Dear Leflix As I think the part of program you sent it is in Fortran? right? I need to ask in order to apply it to the data I need to save the data in a file then call it by open? my question is do I need separate file for x,y,u and v or I store all of it in one file (as I stored it now see attached dat file which I arrange starting from left x,y,u,v)?
What part of program should be written before this statement:

write(1,*)'zone i=',NI,', j=', NJ,', F=POINT'



Quote:
Originally Posted by leflix View Post
It is definetely a structured grid. You can access to every nodes with 2 indices i and j.

Leflix
Attached Files
File Type: txt stream.txt (171.3 KB, 25 views)

Last edited by kbaker; August 6, 2017 at 04:53.
kbaker is offline   Reply With Quote

Old   August 6, 2017, 07:20
Default
  #17
Senior Member
 
Join Date: Aug 2011
Posts: 272
Rep Power: 15
leflix is on a distinguished road
Hi Kbaker,

You should write all the data in the same file
x, y, U, V

just at the begining of the file write this:
VARIABLES= "X","Y", "U","V"
zone i= 100, j= 100 , F=POINT

assuming you have 100 grid nodes in i direction and 100 grid nodes in j direction. (this should be automatized when generatin the file in your code)

and then write
x,y, U,V as you did in your file.

name the file with .plt as extension rather than .txt so that Tecplot can recognise it and open it directly. Name it velocity.plt seems not bad.
leflix is offline   Reply With Quote

Old   August 6, 2017, 07:51
Default
  #18
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Is this code need to be programed in Fortran language?
mariam.sara is offline   Reply With Quote

Old   August 6, 2017, 07:57
Default
  #19
Senior Member
 
kbaker's Avatar
 
Khalid Baker
Join Date: Mar 2009
Location: IRAQ
Posts: 168
Rep Power: 17
kbaker is on a distinguished road
I am really confused about the program. Now I am started with writing a program to just reading the variable in a one matrix and print it as below:

IMPLICIT none
real X
integer i,j
DIMENSION X(5000,4)
open (unit = 1, file = "f:\velo.txt")
open(unit = 2 , file = "d:\fortran programing\res1.txt")
do i=1,4624
do j=1,4
Read(1,*) X(I,J)
enddo
enddo
do i=1,4624
write(2,*) (X(I,j),j=1,4)
enddo
stop
end



I just want to test the program validity in printing the variables but it tell me error: run time error F6501: Read(F:\velo.txt)
-end of file encountered

What the problem with my data? I attached the dat file?

Quote:
Originally Posted by leflix View Post
Hi Kbaker,

You should write all the data in the same file
x, y, U, V

just at the begining of the file write this:
VARIABLES= "X","Y", "U","V"
zone i= 100, j= 100 , F=POINT

assuming you have 100 grid nodes in i direction and 100 grid nodes in j direction. (this should be automatized when generatin the file in your code)

and then write
x,y, U,V as you did in your file.

name the file with .plt as extension rather than .txt so that Tecplot can recognise it and open it directly. Name it velocity.plt seems not bad.
Attached Files
File Type: txt velo.txt (171.3 KB, 13 views)
kbaker is offline   Reply With Quote

Old   August 6, 2017, 08:06
Default
  #20
Senior Member
 
Join Date: Aug 2011
Posts: 272
Rep Power: 15
leflix is on a distinguished road
First how many points do you have in x direction (i) and in y direction (j) ?
leflix 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
[blockMesh] Errors during blockMesh meshing Madeleine P. Vincent OpenFOAM Meshing & Mesh Conversion 51 May 30, 2016 10:51
Simple stream function vorticity formulation for flow past a rectangle [Matlab] a99 Main CFD Forum 2 March 5, 2016 04:04
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 14:00


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