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

UDF_For_Storage

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 4, 2009, 06:08
Default UDF_For_Storage
  #1
Leverkin
Guest
 
Posts: n/a
I have written this simple code above for storaging the elements of the array PRE_EXP[], that I read from a file, in a C_UDMI.

I loop over all threads and then all cells and i store the value 10. Then I pick the thread i need (Lookup_Thread(d, ID) and store there the elements of PRE_EXP in the particular cells. Unfortunately it puts everywhere 10, even in the thread that i want to put the elements of PRE_EXP.

Thanks in advance.

My code is:

#include <stdio.h> #include "udf.h"

FILE* Point; FILE* Point2;

DEFINE_ADJUST(Exp_Pre,d) { float PRE_EXP[58]; cell_t c; Thread *t; face_t f; Thread *f_thread; int ID=8; int i=0; Thread *c_thread; cell_t c0; Thread *p;

Point = fopen("Initial_Solution","r"); Point2 = fopen("I","w");

p = Lookup_Thread(d, ID);

for (i=0; i<58; i++) {

fscanf(Point,"%f\n",&PRE_EXP[i]); }

thread_loop_c(t,d) {

begin_c_loop_all(c,t)

{

C_UDMI(c,t,0) = 10.0;

}

end_c_loop_all(c,t) }

c_thread = Lookup_Thread(d, ID);

begin_c_loop(c,c_thread)

{

C_UDMI(c,c_thread,0) = PRE_EXP[c];

}

end_c_loop(c,c_thread)

thread_loop_c(t,d)

{

/* loop over all cells */

begin_c_loop_all(c,t)

{

fprintf(Point2,"%f\n",C_UDMI(c,t,0));

}

end_c_loop_all(c,t)

}

fclose(Point); fclose(Point2); }

  Reply With Quote

Old   February 4, 2009, 12:09
Default Re: UDF_For_Storage
  #2
Leverkin
Guest
 
Posts: n/a
Did it!
  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



All times are GMT -4. The time now is 20:06.