|
[Sponsors] |
Accessing a inlet face stored UDM value at the outlet face. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 9, 2023, 12:31 |
Accessing a inlet face stored UDM value at the outlet face.
|
#1 |
New Member
Join Date: Oct 2023
Posts: 5
Rep Power: 3 |
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. |
|
October 10, 2023, 05:58 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
__________________
best regards ****************************** press LIKE if this message was helpful |
|
October 10, 2023, 06:26 |
|
#3 |
New Member
Join Date: Oct 2023
Posts: 5
Rep Power: 3 |
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. |
|
October 10, 2023, 06:59 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
show your code
__________________
best regards ****************************** press LIKE if this message was helpful |
|
October 10, 2023, 07:29 |
|
#5 |
New Member
Join Date: Oct 2023
Posts: 5
Rep Power: 3 |
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. |
|
October 10, 2023, 07:30 |
|
#6 |
New Member
Join Date: Oct 2023
Posts: 5
Rep Power: 3 |
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. |
|
October 11, 2023, 01:20 |
|
#7 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Quote:
use real instead of double
__________________
best regards ****************************** press LIKE if this message was helpful |
||
October 11, 2023, 05:09 |
|
#8 |
New Member
Join Date: Oct 2023
Posts: 5
Rep Power: 3 |
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. |
|
Tags |
face, inlet, outlet, thread, udm |
|
|
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 |