CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

temperature difference from different zones using UDF

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

LinkBack Thread Tools Search this Thread Display Modes
Old   May 18, 2023, 08:45
Post temperature difference from different zones using UDF
New Member
Join Date: Sep 2022
Posts: 12
Rep Power: 3
Selawe97 is on a distinguished road
Hello Dears,

My problem is I am using a UDF code to collect temperature values at different cell zones (solid region and fluid region). I am saving temperature values in arrays (as shown in the code) by looping over them and using them later to get the temperature difference to use it in a formula for the fluid cell zone.

in (c0_array[n]) and (c1_array[n]) the data was saved as I want in the first two loops


, and they saved correctly, but when I loop them inside the third loop

(begin_c_loop(c, t))
to receive the data saved in the first two loops the values of (c0_array[n]) in the third loop are saved correctly as I want, but for (c1_array[n]) the data became chaotic and disorganized! so why do I get something like that?

knowing both zones are coincided and have the same number of cells. and I have to use the define profile macro.

#include "udf.h"
#include "mem.h"

DEFINE_PROFILE(HTC, t, position) 
    Domain* domain = Get_Domain(1);
    Thread* ft1 = Lookup_Thread(domain, 2);
    Thread* ft2 = Lookup_Thread(domain, 4);
    cell_t c, c01, c02;
    Thread* t01, t02;
    int n;
    real c0_array[10000], c1_array[10000];

    n = 0;
    begin_c_loop(c01, ft1) 
        C_UDMI(c01, ft1, 0) = C_T(c01, ft1);
        c0_array[n] = C_T(c01, ft1);
		C_UDMI(c01, ft1, 1) = c0_array[n];
    end_c_loop(c01, ft1)

    n = 0;
    begin_c_loop(c02, ft2) 
        C_UDMI(c02, ft2, 2) = C_T(c02, ft2);
        c1_array[n] = C_T(c02, ft2);
		C_UDMI(c02, ft2, 3) = c1_array[n];
    end_c_loop(c02, ft2)

    n = 0;
    begin_c_loop(c, t)
        C_UDMI(c, t, 4) = c0_array[n]; // or C_UDMI(c,t,2)= c0_array[n] - c1_array[n]; 
        C_UDMI(c, t, 5) = c1_array[n];

        C_PROFILE(c, t, position) = C_UDMI(c, t, 4)-C_UDMI(c, t, 5);
        C_UDMI(c, t, 6) = C_PROFILE(c, t, position);
    end_c_loop(c, t)
Your help is appreciated,
Selawe97 is offline   Reply With Quote


array, cell zones, collect data, temperature difference

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Saturation temperature UDF for evaporation-condensation obiscolly50 Fluent UDF and Scheme Programming 1 June 20, 2021 10:08
Heat flux as a function of wall temperature using UDF Piquero FLUENT 2 May 7, 2021 12:02
UDF problem- time dependent temperature at inlet kaeran FLUENT 1 June 16, 2015 21:48
UDF for variable temperature with time CaglarCoskun Fluent UDF and Scheme Programming 8 January 15, 2014 09:15
Inlet won't apply UDF and has temperature at 0K! tccruise Fluent UDF and Scheme Programming 2 September 14, 2012 06:08

All times are GMT -4. The time now is 19:02.