CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   DEFINE_ON_DEMAND UDF: How to declare A[ND_ND], etc (http://www.cfd-online.com/Forums/fluent/32452-define_on_demand-udf-how-declare-nd_nd-etc.html)

jx November 5, 2003 13:34

DEFINE_ON_DEMAND UDF: How to declare A[ND_ND], etc
 
Hi, all,

I am trying to implement a UDF to calculate the mean temperature at the downstream boundary of a periodic boundary pairs.

First I'll explain reasons why I need to use this UDF:

1. It is not suitable to monitor an exist surface (I don't like this term as it confused me a bit at the beginning. In FLUENT, it can be a two-dimensional surface, a point, or a line, or even a three-dimensional geometry! May I here suggest FLUENT to use some other term, like "monitored zone", "monitored geometry", "monitored item", or something else less confused?), because the exist periodic boundary pair contains two boundaries but I am just interest in the downstream one.

2. It is not possible to create a new surface (a plane co-planed the downstream boundary), because in my case, I have both solid and fluid portions within that plane. The available approach to create a plane surface (or quadric surface) will result in a plane covered both the solid and fluid portions. Well, although I actually need the mean temperature at that plane, the actual calculations for mean temperature would be different from fluid to solid (facet average for solid and mass-weighted average for fluid). Hence I should create seperate plane surfaces to monitor them if I go this way, which is practically impossible. (at least I am not aware of. If somebody has an idea, please let me know. thanks!)

3. It is not good to use other DEFINE macros like DEFINE_EXCUTE_AT_END, because I only need to compute the mean temperature after convergence, not at every iteration step. Additionally if I use the surface monitor technique above-mentioned, I always get redundant information at every iteration step. Not a big problem though.

Therefore I choose to use the excute-on-demand UDF to do the job.

As the domain id and boundary face id are not passed by the solver to the UDF. I need to initialize them in the UDF. My questions here come:

1. How can I get boundary face id within the UDF? I know I can get the domain id with Get_Domain(1) function. Is there a similiar function for boundary surface?

2. How should I declare the facet area vector? I don't see a sample in FLUENT manuals. I tried "real A[ND_ND]" to declare it but I got "segmentation violation" error when excuting the UDF.

That's all for the moment. And many thanks for your suggestions.

jx

jx November 6, 2003 17:23

Re: DEFINE_ON_DEMAND UDF: How to declare A[ND_ND],
 
I actually searched the archive of this forum, and just after I posted this, I found some UDF samples using "real A[ND_ND]" to declare the area vector. So I get the answer for my second question somehow. The segmentation violation error must be caused by something else.

But the first question remains unanswered.

I tried the following:

1.

d=Get_Domain(a);

thread_loop_f(f,d)

{

begin_f_loop(f, t)

{

/*judge if the face is the boundary facet and do some calculations in this loop*/

}

end_f_loop

}

2.

d=Get_Domain(1);

thread_loop_c(t,d)

{

begin_f_loop(f, t)

{

/*judge if the face is the boundary facet and do some calculations in this loop*/

}

end_f_loop

}

However, both the above attempts failed and I found only the interior facets were taken into account in above UDF loops. So how I can make the boundary facet identifiers available in excute-on-demand UDF?

In addition, I see DEFINE_PROFILE UDF receives the boundary identifier passed by the solver. But this is the case only after I hook the UDF to a specific boundary. So it is not a good solution for me. Natuarally I set my boundarys periodic and let FLUENT handle the job, otherwise I have to mess around with all interpolations (my mesh would later be all tetrahedral).

Anybody has a suggestion, please?

Thanks,

jx



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