CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Use of F_UDMI(f,t,i) for compiled UDF (https://www.cfd-online.com/Forums/fluent/29904-use-f_udmi-f-t-i-compiled-udf.html)

Damien June 14, 2002 10:42

Use of F_UDMI(f,t,i) for compiled UDF
 
Dear Ladies and Gentlemen, I'm working hard on UDF's since last week and I get some troubles with the use of F_UDMI in UDF. I tried C_UDMI, by looping over cells in a cell thread, to store Flow Variable Macros like C_T(c,t), C_P(c,t). This works fine. But using F_UDMI, looping over faces in a face thread doesn't work... for me...

Did anybody ever tried this Utility with succes? Do you have an example?

Here is a sample of my code: -------------------------- #include "udf.h"

int id_tyre_surf[6]={1,7,8,15,17,18}; real x[ND_ND], Area[ND_ND],fx[ND_ND]; Domain* d;

DEFINE_ADJUST(test,d) { real press1; Thread *t; cell_t c; face_t f; int n,k=0;

// for(k=0; k>5; k++)

// { int j=0; t=Lookup_Thread(d,id_tyre_surf[k]); Message ("id= %d\n", id_tyre_surf[k]); begin_f_loop(f,t) { F_AREA(Area,f,t); Message ("A=%e\t%e\t%e\n", Area[0], Area[1], Area[2]); press1=F_P(f,t); Message ("press1=%f\n", press1); F_CENTROID(fx,f,t); Message("face centroid%f\t%f\t%f\n",fx[0],fx[1],fx[2]); F_UDMI(f,t,0)=press1; Message("test2%f\n",press1); } end_f_loop(f,t);

// } } ------------------------------

As you can see I print some Messages on the console window to find out where the code crashes. The console window prints " id= 1 A= value value value press1= value face centroid value value value "

And nothing more just the boring: " Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () "

Thank you in advance !

Greetings

Damien

Damien June 14, 2002 10:50

re-pasting of the UDF code
 
Sorry ! The pasting of the code made it difficult to read. So...

Here is a sample of my code: -------------------------- #include "udf.h"

int id_tyre_surf[6]={1,7,8,15,17,18}; real x[ND_ND], Area[ND_ND],fx[ND_ND]; Domain* d;

DEFINE_ADJUST(test,d) { real press1; Thread *t; cell_t c; face_t f; int n,k=0;

// for(k=0; k>5; k++)

// { int j=0; t=Lookup_Thread(d,id_tyre_surf[k]); Message ("id= %d\n", id_tyre_surf[k]); begin_f_loop(f,t) { F_AREA(Area,f,t); Message ("A=%e\t%e\t%e\n", Area[0], Area[1], Area[2]); press1=F_P(f,t); Message ("press1=%f\n", press1); F_CENTROID(fx,f,t); Message("face centroid%f\t%f\t%f\n",fx[0],fx[1],fx[2]); F_UDMI(f,t,0)=press1; Message("test2%f\n",press1); } end_f_loop(f,t);

// } } ------------------------------

Damien

Damien June 14, 2002 11:00

re-SORRY, re-re-pasting of the UDF code
 
One more time, and I give up... Ooopss I forget the Preview Message....!!!

--------------------------

#include "udf.h"

int id_tyre_surf[6]={1,7,8,15,17,18};

real x[ND_ND], Area[ND_ND],fx[ND_ND];

Domain* d;

DEFINE_ADJUST(test,d)

{

real press1;

Thread *t;

cell_t c;

face_t f;

int n,k=0;

int j=0;

t=Lookup_Thread(d,id_tyre_surf[k]);

Message ("id= %d\n", id_tyre_surf[k]);

begin_f_loop(f,t)

{

F_AREA(Area,f,t);

Message ("A=%e\t%e\t%e\n", Area[0], Area[1], Area[2]);

press1=F_P(f,t);

Message ("press1=%f\n", press1);

F_CENTROID(fx,f,t);

Message("face centroid%f\t%f\t%f\n",fx[0],fx[1],fx[2]);

F_UDMI(f,t,0)=press1;

Message("test2%f\n",press1);

}

end_f_loop(f,t);

}

------------------------------

I hope it succeeded this time...

Damien


keilmeyer June 16, 2002 22:31

Re: re-SORRY, re-re-pasting of the UDF code
 
In my experiences, some macros don't seems to be defined in your code. Please try the following loop. --

thread_loop_f(t, d) { begin_f_loop(f,t) { YOUR CODE }end_f_loop(f,t) }

-- And if you are using a PC-Windows, the "Domain* d" doesn't work. So you have to replace "Domain* d" to Domain *domain = Get_Domain(1)".

Best regards,

keilmeyer June 16, 2002 22:36

SORRY, I've mistaken.
 
Hi,

The loops is the following.

---

thread_loop_f(t, d)

{

begin_f_loop(f,t)

{

YOUR CODE

}end_f_loop(f,t)

}

---

Damien June 17, 2002 11:23

Re: SORRY, I've mistaken.
 
Thanks for reply, I tried my code (without thread_loop_f(t, d)) by stopping trying to use the F_UDMI(f,t,i) (because, this is what is the problem, crashing the calculations)

The loops are running as wanted.

When starting as you preconise, the first itération never stops............................. Aaaaahhhhhh.... stop, stop, stop, ctrl+alt+del, was the only solution, :))

I didn't expect that,... that's strange, there is some things not easy to understand immediatly with FLUENT. Is that the black box effect? That's not so cool...

Sometime, I would like to make a comment like that: Software companies, I understand that you keep secrets for protecting your copyright, but keeping secrets about the use of the most advanced tools of your codes will kill your users...

I mean, If we use so much time finding out the possibilities of the code, our companies will say: "CFD is too expensive (Software, hardware, human ressources...)" And then "finito". OK some companies are very rich... No problem... Life's hard...

Greg Perkins June 17, 2002 21:25

Re: F_UDMI
 
Hi

I'm not a fan of using the F_UDMI macros to store face value information. In fact, in general its not a great idea.

Why?

Well Fluent is a Finite Volume code, so its stores values at cell centres. You'll find that if you store infomation in F_UDMI it may not be saved with your case and data file and when you read it back in you won't be able to continue iterating from the same position as when you saved.

I used it in the past but I think a better approach if you're wanting to save face information of a boundary thread, is to store the information in the adjacent cell to the thread.

You can do this by using the macros described in the udf manual. F_C0 etc.

This way, info is not lost when you save and reload.

If you want to store information on interior faces this basically doesn't make sense. Fluent only stores information at cell centres and face data are reconstructed from cell centre data. So, you should be following the same principles.

Whether thess conceptual ideas help you fix your code is perhaps another matter, but good luck. Greg

Damien June 18, 2002 08:50

Re: F_UDMI
 
Hi Greg !

Thank you very much for your explaination and your share of experience.

In fact as the F_UDMI doesn't work in my code I am shifting my strategy by taking the value in the neighboring cells and handle them to make the job needed.

I didn't think about all the consequences and advantages it can have in comparison to F_UDMI...

Once more, thank you Greg, and please greets the koalas for me... is there koalas in Australia?

Kind Regards

Damien


Greg Perkins June 18, 2002 08:55

Re: F_UDMI
 
Yeah I have one as a pet at home!!!!

(Only joking!)

Hope it goes well....

Greg


All times are GMT -4. The time now is 03:41.