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

Multiple DEFINE_ADJUST in a running time

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 4, 2023, 07:06
Default Multiple DEFINE_ADJUST in a running time
  #1
New Member
 
Canh Doan
Join Date: Sep 2023
Posts: 12
Rep Power: 3
canh.dv@seoultech.ac.kr is on a distinguished road
Hi everyone,

I am running a problem with 2 DEFINE_ADJUST.
1st DEFINE_ADJUST collects data and assigns it to a global variable array.
2nd DEFINE_ADJUST takes the data from the global variable array and assigns it to fluent.

Code:
DEFINE_ADJUST(adjust_absorb_coe_to_global_matrix_bb, d)
{
	cell_t c;
	Thread *t;
	face_t f;
	real xc[ND_ND];
	real xx, yy;
	int i,j,m,n, count;
	d = Get_Domain(1);
	thread_loop_c(t,d)
			{
			if(THREAD_ID(t) == 2)
			{
				begin_f_loop(f,t)
				{
					F_CENTROID(xc,f,t);
					xx = xc[0];
					yy = xc[1];
					m = (xx+0.05)/0.001;
					n = yy/0.001;
					count = 24*m+n;
					BB[count] = C_ABS_COEFF(c,t);
					printf("Global array BB[%d] = %f\n", count, BB[count]);
				}
			end_f_loop(f,t)
			}
		}
}

DEFINE_ADJUST(adjust_cal_intensity_depend_on_bb, d)
{
	int i,j,m,n, count;
	i = 0;
    for(j = 0; j<25; j++)
    {
        AA[24*i+j] = 1000;
        printf("AA[%d] = %f\n", 24*i+j, AA[24*i+j]);
    }
    for(i = 0; i<100; i++)
    {
        for(j = 0; j<25; j++)
        {
            if(i == 0)
            {
                AA[24*i+j] = AA[24*i+j];
                printf("AA[%d] = %f\n", 24*i+j, AA[24*i+j]);
            }
            else
            {
                AA[24*i+j] = AA[24*(i-1)+j] * (1 - BB[24*(i-1)+j]);
                printf("AA[%d] = %f\n", 24*i+j, AA[24*i+j]);
            }
        }
    }
}
To get the precise result, the first DEFINE_ADJUST must run first and assign all the data to the global variable array, then the second DEFINE_ADJUST will get the data from the global variable array.

I found that these two functions run as follows: ADJUST-1 run, assign ~150 values, and then ADJUST-2 run. This process repeats 17 times.

I cannot understand why this happened. What I expect is ADJUST-1 runs one time, assign 2500 value, and then ADJUST-2 run one time and get data.
canh.dv@seoultech.ac.kr is offline   Reply With Quote

Old   December 5, 2023, 02:22
Default
  #2
New Member
 
Canh Doan
Join Date: Sep 2023
Posts: 12
Rep Power: 3
canh.dv@seoultech.ac.kr is on a distinguished road
The problem is solved.

The loop ran 16 times because I set the parallel solver as 16. After that my system worked well.
canh.dv@seoultech.ac.kr is offline   Reply With Quote

Reply

Tags
define_adjust, loop over cells, udf


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
laplacianFoam with source term Herwig OpenFOAM Running, Solving & CFD 17 November 19, 2019 14:47
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 03:50
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58
mixerVesselAMI2D's mass is not balancing sharonyue OpenFOAM Running, Solving & CFD 6 June 10, 2013 10:34


All times are GMT -4. The time now is 22:10.