CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

UDF FOR UNSTEADY TIME STEP

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2006, 09:52
Default UDF FOR UNSTEADY TIME STEP
  #1
mayur
Guest
 
Posts: n/a
i have a 100 different velocities which i need to input into a 100 time steps but im having great difficulty writing a correct udf.I have written the following but not sure where im going wrong?

#include "udf.h"

#define FLUID_ID 1 #define vel1 2.75 #define vel2 2.75 #define vel3 2.75 #define vel4 2.75 #define vel5 2.75 #define vel6 2.75 #define vel7 2.75 #define vel8 2.50 #define vel9 2.25 #define vel10 2.1 #define vel11 2.0 #define vel12 1.8 #define vel13 1.7 #define vel14 1.6 #define vel15 1.5 #define vel16 1.45 #define vel17 1.4 #define vel18 1.3 #define vel19 1.2 #define vel20 1.0 #define vel21 1.1 #define vel22 1.2 #define vel23 1.5 #define vel24 2.5 #define vel25 3.5 #define vel26 6.0 #define vel27 8.5 #define vel28 14.0 #define vel29 19.5 #define vel30 27.0 #define vel31 29.5 #define vel32 28.5 #define vel33 27.0 #define vel34 22.0 #define vel35 19.5 #define vel36 19.5 #define vel37 19.0 #define vel38 17.5 #define vel39 15.5 #define vel40 14.0 #define vel41 13.0 #define vel42 12.0 #define vel43 11.0 #define vel44 10.5 #define vel45 9.5 #define vel46 8.5 #define vel47 6.0 #define vel48 3.5 #define vel49 1.2 #define vel50 -1.2 #define vel51 -2.0 #define vel52 -1.5 #define vel53 0 #define vel54 0.2 #define vel55 0.5 #define vel56 1.25 #define vel57 1.5 #define vel58 1.75 #define vel59 1.9 #define vel60 2.0 #define vel61 2.25 #define vel62 2.5 #define vel63 2.75 #define vel64 2.9 #define vel65 4.0 #define vel66 3.75 #define vel67 3.6 #define vel68 3.5 #define vel69 3.5 #define vel70 3.4 #define vel71 3.2 #define vel72 3.0 #define vel73 2.9 #define vel74 2.8 #define vel75 2.75 #define vel76 2.5 #define vel77 2.2 #define vel78 1.8 #define vel79 1.5 #define vel80 1.25 #define vel81 1.5 #define vel82 1.75 #define vel83 1.9 #define vel84 2.5 #define vel85 2.8 #define vel86 3.0 #define vel87 3.0 #define vel88 3.0 #define vel89 3.0 #define vel90 3.0 #define vel91 3.0 #define vel92 3.0 #define vel93 3.0 #define vel94 3.0 #define vel95 3.0 #define vel96 3.0 #define vel97 3.0 #define vel98 3.0 #define vel99 3.0 #define vel100 3.0

DEFINE_PROFILE(fixed_vel,t,i) { cell_t c; real x[ND_ND]; real r;

begin_c_loop(c,t)

{

C_CENTROID(x,c,t);

r =x[1]; } end_c_loop(c,t) }

  Reply With Quote

Old   August 9, 2006, 10:07
Default Re: UDF FOR UNSTEADY TIME STEP
  #2
Daniele Scatolini
Guest
 
Posts: n/a
Try this: write your velocity datas into a simple .dat file, say "velocities.dat" with notepad or any editor,one data for each row.Save it in the directory where you open fluent! Within your DEFINE_PROFILE udf, use the macro CURRENT_TIMESTEP (see udf manual...) in this way:

DEFINE_PROFILE.... {..... ..... int ct,i,...; real vel; FILE *fp; fp=fopen("velocities.dat","r"); ct=CURRENT_TIMESTEP; for(i=0;i<ct;i++) fscanf(fp,"%g\n",&vel); /*now into vel there is the right row of velocity*/ fclose (fp); .... ..../*use your vel variable, maybe as follows!!!*/

F_PROFILE (c,t,i)=vel;

} /* great success, i hope! */
  Reply With Quote

Old   August 9, 2006, 10:13
Default Re: UDF FOR UNSTEADY TIME STEP
  #3
Daniele Scatolini
Guest
 
Posts: n/a
i don't know if it has appeared completely my previous post. howhever, pay attention to CURRENT_TIMESTEP ,because it sends a real value, you'll have to make it an integer before using it in the for loop. If the previous post wasn't complete,please tell me. It was my first post in this forum: is there a space limit for posts? Cheers from Roma.
  Reply With Quote

Old   August 9, 2006, 10:19
Default Re: UDF FOR UNSTEADY TIME STEP
  #4
Daniele Scatolini
Guest
 
Posts: n/a
Sorry! Don't use CURRENT_TIMESTEP, but do use N_TIME, that i suppose to return the integer number of the actual step; i hope it doesn't return the total number of time steps that you initialized! In the worst case, if you use CURRENT_TIME and divide it per the lenght of your time step, and make it integer, you'll know the actual number of the step!
  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
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM Running, Solving & CFD 8 March 28, 2016 11:08
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 05:36
Full pipe 3D using icoFoam cyberbrain OpenFOAM 4 March 16, 2011 09:20
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 14:09
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07


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