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

Accessing a inlet face stored UDM value at the outlet face.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 9, 2023, 12:31
Default Accessing a inlet face stored UDM value at the outlet face.
  #1
New Member
 
Join Date: Oct 2023
Posts: 5
Rep Power: 3
plotr is on a distinguished road
Hello,

I am trying to write a UDF with two separate EXECUTE_AT_END functions. A value computed for the inlet EXECUTE_AT_END function must be accessed in the outlet EXECUTE_AT_END function.

I thought the best way to do this was using UDMs, however since the UDMs are stored per inlet face, I cannot access the data at the outlet faces.

Does anyone know of a way I can practically do this?
I also thought about defining and updating a global variable, but then the code returns zeros, which I presume is due to the parallelization.

Another option I'm looking at is transferring the data from the inlet face to the inlet cells and applying that value to all the cells in the entire flow domain. And then accessing the data again at the outlet faces from the outlet cells. But I am not sure how to do this properly.

Hopefully someone can help me out.
plotr is offline   Reply With Quote

Old   October 10, 2023, 05:58
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
how to connect inlet and outlet
__________________
best regards


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

Old   October 10, 2023, 06:26
Default
  #3
New Member
 
Join Date: Oct 2023
Posts: 5
Rep Power: 3
plotr is on a distinguished road
But these posts state exactly the problem I currently have:
"You cannot transfer UDMs. Each boundary has its own thread and UDMs are identified using indices. The solution is to interpolate."
and then 1-1 mapping is only possible when there is an equal number of faces on both inlet and outlet. This is not the case for me.

I saw your reply to the other post with the following:
"if you want to apply some average value, you can create some global variable inside UDF to store and transfer pressure value between macros."

I tried doing this, by defining a global variable at the top of the code. However, the code kept returning zeros, so the variable was not updated at all. Could you perhaps give an example? That would be immensely helpful.
plotr is offline   Reply With Quote

Old   October 10, 2023, 06:59
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
show your code
__________________
best regards


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

Old   October 10, 2023, 07:29
Default
  #5
New Member
 
Join Date: Oct 2023
Posts: 5
Rep Power: 3
plotr is on a distinguished road
I'll provide some parts that are mainly pertaining to the issue I believe, because the code is very long.

I define this global variable at the beginning:
static double im_pressure;

Then I define various UDMs for both the inlet and outlet:
DEFINE_INIT(init_UDMs, domain)
{
Thread* thread_inlet = Lookup_Thread(domain, inlet);
face_t f;
/*Initialize the user defined functions*/
begin_f_loop(f, thread_inlet)
/* loop over all faces of the inlet domain */
{
F_UDMI(f, thread_inlet, 0) = 0;

F_UDMI(f, thread_inlet, 10) = 0;
}
end_f_loop(f, thread_inlet)


Thread* thread_outlet = Lookup_Thread(domain, outlet);
/*Initialize the user defined functions*/
begin_f_loop(f, thread_outlet)
/* loop over all faces of the inlet domain */
{
F_UDMI(f, thread_outlet, 11) = 0;

F_UDMI(f, thread_outlet, 18) = 0;
}
end_f_loop(f, thread_inlet)
}

within the first EXECUTE_AT_END, I have the following code:

begin_f_loop(f, thread)
{
function( one of the outputs is Pim)

F_UDMI(f, thread, 6) = Pim

im_pressure = Pim

}
end_f_loop(f, thread)

//Then the im_pressure (the value I want transferred) is called again within the second EXECUTE_AT_END function (also within a f-loop):

Pimt5 = im_pressure



If I print im_pressure in the first EXECUTE_AT_END function it does give me the correct value. But when I print it in the second function, zeros are returned. I feel like this might be caused due to parallelization.

Last edited by plotr; October 10, 2023 at 10:28.
plotr is offline   Reply With Quote

Old   October 10, 2023, 07:30
Default
  #6
New Member
 
Join Date: Oct 2023
Posts: 5
Rep Power: 3
plotr is on a distinguished road
Another option I had in mind was doing it in the following manner:
void store_data_from_inlet_face_to_outlet_face(Domain* domain)
{
cell_t c, c0;
face_t f;
Thread* t, * t0, * ct;

/* Loop over all faces on inlet and transfer the face data to cell data */
t = Lookup_Thread(domain, thread_inlet);

begin_f_loop(f, t)
{
c0 = F_C0(f, t);/* c0 and t0 identify the adjacent cell and thread */
t0 = THREAD_T0(t);
C_UDMI(c0, t0, 34) = F_UDMI(f0, t0, 34);
}
end_f_loop(f, t)

t = Lookup_Thread(domain, thread_inlet); // should this be the flow domain?

/* Loop through all cell threads in the domain */
thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
C_UDMI(c, t, 0) = ???; // Set UDM variable to the uniform value
}
end_c_loop(c, t)
}

/* Loop over all faces on outlet */
t = Lookup_Thread(domain, thread_outlet);

begin_f_loop(f, t)
{
c0 = F_C0(f, t);/* c0 and t0 identify the adjacent cell and thread */
t0 = THREAD_T0(t);
F_UDMI(f0, t0, 34) = C_UDMI(c0, t0, 34);
}
end_f_loop(f, t)
}
It is not finished yet for I do not know how to give every cell in the domain the same value.
plotr is offline   Reply With Quote

Old   October 11, 2023, 01:20
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
static double im_pressure;
why is it static?
use real instead of double
__________________
best regards


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

Old   October 11, 2023, 05:09
Default
  #8
New Member
 
Join Date: Oct 2023
Posts: 5
Rep Power: 3
plotr is on a distinguished road
I thought static would ensure the value is retained between the use of both EXECUTE_AT_END functions.

I tried your recommendation but, unfortunately, I still get zeros returned for im_pressure at the second EXECUTE_AT_END function. Whilst at the first EXECUTE_AT_END function im_pressure does have the correct value.

I still believe it is due to the parallelization.

Last edited by plotr; October 11, 2023 at 07:14.
plotr is offline   Reply With Quote

Reply

Tags
face, inlet, outlet, thread, udm


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
[OLAFLOW] The OLAFLOW Thread Phicau OpenFOAM Community Contributions 459 September 12, 2024 12:47
using outlet velocity profile as inlet for next set of iterations tricha122 FLUENT 0 November 22, 2020 10:40
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 10:56
[Gmsh] Import problem ARC OpenFOAM Meshing & Mesh Conversion 0 February 27, 2010 11:56
VOF Outlet boundary condition in cfd - ace JM Main CFD Forum 0 December 15, 2006 09:07


All times are GMT -4. The time now is 13:23.