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

Access the value in UDMI

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 3, 2023, 05:10
Default Access the value in UDMI
  #1
New Member
 
Canh Doan
Join Date: Sep 2023
Posts: 12
Rep Power: 2
canh.dv@seoultech.ac.kr is on a distinguished road
Hi everyone,

I am using UDMI to save the value of temperature at cell 1 as "C_UDMI(c,t,0) = C_T(c,t)".

However, I want to bring this value to a different cell for example cell 2.

How can I do it? I am working in Windows so I cannot use the read/write file.

Thank you.
canh.dv@seoultech.ac.kr is offline   Reply With Quote

Old   December 4, 2023, 01:35
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
your question doesn't make any sense
to use
Code:
C_UDMI(c,t,0) = C_T(c,t)
you should define c and t (cell and thread)
the way you define it could give you temperature at 1 specific cell (finite volume) or at the whole domain (in case you are using cell/thread loop)

Code:
I am working in Windows so I cannot use the read/write file.
this doesn't make any sense at all, you can use read/write in windows

read ansys fluent customization manual to get more info on cell/thread structure, you may find there examples of udf
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 4, 2023, 02:23
Default
  #3
New Member
 
Canh Doan
Join Date: Sep 2023
Posts: 12
Rep Power: 2
canh.dv@seoultech.ac.kr is on a distinguished road
Thank you Alexander for your reply,

I found it in the UDF guide book, they said "DEFINE_RW_FILE cannot be used in UDFs that are executed on Windows systems." https://www.afs.enea.it/project/nept...udf/node29.htm
canh.dv@seoultech.ac.kr is offline   Reply With Quote

Old   December 4, 2023, 02:39
Default
  #4
New Member
 
Canh Doan
Join Date: Sep 2023
Posts: 12
Rep Power: 2
canh.dv@seoultech.ac.kr is on a distinguished road
I had another question, this is my code:
#include "udf.h"

double AA[2500];

DEFINE_ADJUST(adjust_intensity_to_global_value_2, d)
{
cell_t c;
Thread *t;
face_t f;
real xc[ND_ND];
real xx, yy;
int i,j,m,n, count;

for(i = 0; i<100; i++)
{
for(j = 0; j<25; j++)
{
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(xc,c,t);
xx = xc[0];
yy = xc[1];
m = (xx+0.05)/0.001;
n = yy/0.001;

if(m == i && n == j)
{
count = 24*i+j;
AA[count] = 1000*(1-i*0.01);
printf("adjust %d\n", count);
}
}
end_c_loop(c,t)
}
}
}
}

DEFINE_DOM_SOURCE(dom2,c,t,ni,nb,emission,in_scatt ering,abs_coeff,scat_coeff)
{
Domain *d;
face_t f;
real xc[ND_ND];
real xx, yy;
int i,j,m,n,count;
d = Get_Domain(1);
C_CENTROID(xc,c,t);
xx = xc[0];
yy = xc[1];
m = (xx+0.05)/0.001;
n = yy/0.001;
count = 24*m+n;
C_STORAGE_R_XV(c,t,SV_DO_IRRAD,0) = AA[count];
printf("dom2\n");
}

and this is my domain with the 2D mesh of 25 rows and 100 columns, total 2500 cells:


I tried to use a DEFINE_ADJUST to assign the intensity to a global variable matrix AA[24*i+j], and after that, I used a DEFINE_DOM_SOURCE to assign the value from global matrix AA[24*(i-1)+j] to the current intensity.

The problem I face now is when running the simulation, I found that Fluent runs a few cells in "DEFINE_ADJUST" and next run to DEFINE_DOM_SOURCRE and return. Totally 17 times and it is not follow the order of i and j. (I checked by print out "adjust" when run DEFINE_ADJUST and "dom" when run DEFINE_DOM_SOURCE).

As you see in my code, Fluent should run the DEFINE_ADJUST first, assign intensity to 2500 values in AA array first. After that it will run the DEFINE_DOM_SOURCE to take the data from AA array.

Can you guide me to overcome this? I want to finish looping over 2500 cells in DEFINE_ADJUST first and next is run the DEFINE_DOM_SOURCE.
canh.dv@seoultech.ac.kr is offline   Reply With Quote

Old   December 4, 2023, 02:40
Default
  #5
New Member
 
Canh Doan
Join Date: Sep 2023
Posts: 12
Rep Power: 2
canh.dv@seoultech.ac.kr is on a distinguished road
Quote:
Originally Posted by canh.dv@seoultech.ac.kr View Post
I had another question, this is my code:
#include "udf.h"

double AA[2500];

DEFINE_ADJUST(adjust_intensity_to_global_value_2, d)
{
cell_t c;
Thread *t;
face_t f;
real xc[ND_ND];
real xx, yy;
int i,j,m,n, count;

for(i = 0; i<100; i++)
{
for(j = 0; j<25; j++)
{
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(xc,c,t);
xx = xc[0];
yy = xc[1];
m = (xx+0.05)/0.001;
n = yy/0.001;

if(m == i && n == j)
{
count = 24*i+j;
AA[count] = 1000*(1-i*0.01);
printf("adjust %d\n", count);
}
}
end_c_loop(c,t)
}
}
}
}

DEFINE_DOM_SOURCE(dom2,c,t,ni,nb,emission,in_scatt ering,abs_coeff,scat_coeff)
{
Domain *d;
face_t f;
real xc[ND_ND];
real xx, yy;
int i,j,m,n,count;
d = Get_Domain(1);
C_CENTROID(xc,c,t);
xx = xc[0];
yy = xc[1];
m = (xx+0.05)/0.001;
n = yy/0.001;
count = 24*m+n;
C_STORAGE_R_XV(c,t,SV_DO_IRRAD,0) = AA[count];
printf("dom2\n");
}

and this is my domain with the 2D mesh of 25 rows and 100 columns, total 2500 cells:


I tried to use a DEFINE_ADJUST to assign the intensity to a global variable matrix AA[24*i+j], and after that, I used a DEFINE_DOM_SOURCE to assign the value from global matrix AA[24*(i-1)+j] to the current intensity.

The problem I face now is when running the simulation, I found that Fluent runs a few cells in "DEFINE_ADJUST" and next run to DEFINE_DOM_SOURCRE and return. Totally 17 times and it is not follow the order of i and j. (I checked by print out "adjust" when run DEFINE_ADJUST and "dom" when run DEFINE_DOM_SOURCE).

As you see in my code, Fluent should run the DEFINE_ADJUST first, assign intensity to 2500 values in AA array first. After that it will run the DEFINE_DOM_SOURCE to take the data from AA array.

Can you guide me to overcome this? I want to finish looping over 2500 cells in DEFINE_ADJUST first and next is run the DEFINE_DOM_SOURCE.
https://prnt.sc/u7YLPk_estnB[/IMG]
canh.dv@seoultech.ac.kr is offline   Reply With Quote

Reply

Tags
access udmi value, udf, udmi


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
[DesignModeler] DesignModeler Scripting: How to get Full Command Access ANT ANSYS Meshing & Geometry 53 February 16, 2020 15:13
Why is access to turbulence fields provided as const? mrishi OpenFOAM Programming & Development 3 January 23, 2020 12:51
UDMI and DEFINE_EXECUTE_AT_END MsRuby Fluent UDF and Scheme Programming 2 July 2, 2018 02:43
Is there a way to access the gradient limiter in Fluent ? CFDYourself FLUENT 1 February 16, 2016 05:49
How to access first derivative of Udmi??? Asghari FLUENT 1 October 23, 2006 06:23


All times are GMT -4. The time now is 00:48.