|
[Sponsors] |
September 27, 2017, 09:03 |
Udm value on the walls
|
#1 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
When we save the value of a UDS on a defined UDM (code C_UDMI(c,tc,i)= C_UDSI(c,tc,i)), we obtain a UDM value equal to zero at the walls where the boundary conditions were defined. How can we fix it?
Should we use a User Defined Node Memory Location? Has anyone know how to use them in the next code? DEFINE_ADJUST(a1_adjust_udm, domain) { cell_t c; /* Cell index has its own type too */ Thread *tc; /* Threads are pointers to a structure */ /* Loop through all the cell threads in the domain */ thread_loop_c(tc,domain) {/* Loop through the cells in each cell thread */ begin_c_loop(c,tc) { C_UDMI(c,tc,0)=C_UDSI(c,tc,0)*5; } end_c_loop(c,tc) } } |
|
September 27, 2017, 10:15 |
|
#3 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
Should I do this?
DEFINE_ADJUST(a1_adjust_udm, domain) { cell_t c; /* Cell index has its own type too */ Thread *tc; /* Threads are pointers to a structure */ /* Loop through all the cell threads in the domain */ thread_loop_c(tc,domain) {/* Loop through the cells in each cell thread */ begin_c_loop(c,tc) { C_UDMI(c,tc,0)=C_UDSI(c,tc,0)*5; } end_c_loop(c,tc) } begin_f_loop(f,t) { F_UDMI(f,t,0) = F_UDSI(c,tc,0)*5; } end_f_loop(f,t) } |
|
September 27, 2017, 12:00 |
|
#4 |
Senior Member
|
That's the concept. You should obviously define f and t (as well as providing a loop on the face threads) and check that what is stored in F_UDSI actually corresponds to what you are looking for.
|
|
September 28, 2017, 08:10 |
|
#5 | |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
Quote:
I've done what you said: DEFINE_ADJUST(adjust_udm, domain) { cell_t c; /* Cell index has its own type too */ Thread *tc; /* Threads are pointers to a structure */ face_t f;/* Face index has its own type*/ /* Loop through all the cell threads in the domain */ thread_loop_c(tc,domain) {/* Loop through the cells in each cell thread */ begin_c_loop(c,tc) { C_UDMI(c,tc,0)=C_UDSI(c,tc,0)*C_R(c,tc); } end_c_loop(c,tc) } /* loops over all face threads in a domain*/ thread_loop_f(tc,domain) {/* Loop over faces in a face thread to get the information stored on faces. */ begin_f_loop(f,tc) { F_UDMI(f,tc,0)=F_UDSI(f,tc,0)*C_R(c,tc); } end_f_loop(f,tc) } } The compilation of the code work but I got "Segmentation violation" at the begining of the calculation. Is there something wrong on my code? Hope the same thread could be used for cells and faces at the same time... |
||
September 28, 2017, 11:24 |
|
#6 |
Senior Member
|
That's kind of lazy of you but, that's not actually at the same time, so there should not be any problem with that.
A first problem is that F_UDSI and F_UDMI are only available for wall and flow boundary faces. Attempts to access any other face zone will result in error. But you are looping over all face threads, including the interior one, which will give you error. Another problem is with C_R(c,tc) in the face loop. Face variables start with F_, but there is no density stored on faces. There are few options here, according to what you want to achieve. Try this (you need to get from the GUI the proper integer ID of the default-interior group of faces to put in place of YOUR_INPUT): DEFINE_ADJUST(adjust_udm, domain) { cell_t c; /* Cell index has its own type too */ Thread *tc; /* Threads are pointers to a structure */ Thread *tf; /*Note lack of laziness here*/ face_t f; /* Face index has its own type*/ Thread *t_interior = Lookup_Thread(domain,YOUR_INPUT); /*ID of the "default-interior" set of faces, from GUI -- INPUT REQUIRED HERE*/ /* Loop through all the cell threads in the domain */ thread_loop_c(tc,domain) { /* Loop through the cells in each cell thread */ begin_c_loop(c,tc) { C_UDMI(c,tc,0)=C_UDSI(c,tc,0)*C_R(c,tc); } end_c_loop(c,tc) } /* loops over all face threads in a domain*/ thread_loop_f(tf,domain) { if (tf == t_interior) continue; /*skip default-interior faces*/ tc = THREAD_T0(tf); /*unique cell thread next to boundary face thread*/ /* Loop over faces in a face thread to get the information stored on faces. */ begin_f_loop(f,tf) { c = F_C0(f,tf); /*index of cell next to given face on boundary*/ F_UDMI(f,tf,0)=F_UDSI(f,tf,0)*C_R(c,tc); /*getting the density from cell next to boundary*/ } end_f_loop(f,tc) } } I have not checked it, so you need to see if errors come out |
|
October 3, 2017, 05:51 |
|
#7 | |||
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
Thanks a lot because my college and I didn't know this important part!!
Quote:
Quote:
I'm a little confussed with your first sentence : Quote:
THANKS for your kindly help, sbaffini!!! |
||||
October 3, 2017, 16:55 |
|
#8 |
Senior Member
|
Dear rarnaunot, don't worry. What I meant is that, instead of guessing if using the same variable for two loops on two kind of threads, it would have been faster to just test it. Note my remainder of this as comment. That was ironic.
Glad it worked. |
|
August 3, 2022, 08:12 |
|
#9 | |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Quote:
How can i change UDS boundary value in a Define Adjust UDF? i mean how can i call UDS boundary value to changing in a UDF of Define Adjust? Regards, |
||
August 3, 2022, 08:33 |
|
#10 | |
Senior Member
|
Quote:
What you can do in define_adjust is to update some global variable that is later accessed in the define_profile udf of the UDS and use it there for your updated bc. Is this what you were looking for? |
||
August 3, 2022, 08:45 |
|
#11 | |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Quote:
I want to set sinusoidal value of electric potential (MHD module) for a wall, first i try expression but i faced to error : Error: wta(2nd) to string_eq Error Object: __expr__ then i try Profile and UDF profile , but agian i faced to problem , when i use them it consider the wall to insulated. Could someone help me how can i set sinusoidal value for current density ( Electric Potential MHD) ? this is my UDF profile code: #include "udf.h" #define PI 3.141592654 DEFINE_PROFILE(current_density,thread,position) { face_t f; real t = CURRENT_TIME; begin_f_loop(f,thread) { F_PROFILE(f,thread,position)=13*sin((2*PI/0.04)*t); end_f_loop(f,thread) } } This is expression : 13*sin((2*PI/0.04[s])*Time) I try Define Adjust , but it dosent work like which i want : # include "udf.h" DEFINE_ADJUST(adjust_gradient, domain) { int i = 13.; Thread *t = Lookup_Thread(domain, i); face_t f; real tt = CURRENT_TIME; begin_f_loop (f,t) { F_UDSI(f,t,0) = 0.02*tt; } end_f_loop (f,t) } but when i use Define Adjust boundary value changes wrong and weird i think boundary value didn't change and other things changes |
||
August 3, 2022, 09:10 |
|
#12 |
Senior Member
|
Ok, you certainly don't need a define_adjust to simply assign a sinusoidal time variation to a BC. As I said, it is meant for other things.
Now, your scenario is very simple, and there certainly is an UDF example with a time varying inlet bc in the manual (probably with pressure). I am no expert with expressions (which were not yet in Fluent last time I used it), but I suspect that they are exactly meant to be used for simple cases like yours, and you should be able to find a simple example in the manual as well. So, I won't check your UDF (or expression). I think you should also double check the variables you are using, as you mention MHD but use the UDS. I have no idea if this is how the MHD module works with UDF. |
|
August 3, 2022, 09:22 |
|
#13 | |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Quote:
i attached the picture that show the box where i can set value for boundary value , it shows that it is UDS part so i use UDS in Define Adjust Thank You |
||
August 3, 2022, 10:23 |
|
#14 |
Senior Member
|
I took some time and checked better. Two things:
1) Apparently, MHD module in Fluent is still based on UDF and UDS, so your findings seems coherent with the fact that MHD is based on UDS. 2) Have you read the manual? Because, in less than a minute, I just found this, well evidenced, in a section named "Setting Up Boundary Conditions" in the MHD part of the user guide: Note: Note that all boundary conditions used by the MHD model must be set in the Boundary Condition tab of the MHD Model dialog box. Customized boundary conditions of any form, such as parameters and expressions, are not supported. As the MHD module is based on UDFs, I'm pretty sure there is a way/hack to use UDF also to assign your bc but, given the above warning, it is a possibility only for an experienced user with a full knowledge of CFD and Fluent. Nothing we can distill here in few posts, unless someone else shows up here with a ready solution. |
|
August 3, 2022, 10:52 |
|
#15 | |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Quote:
i read some part of manual , you mean this part of limitation of setting BC : "You must specify the applied magnetic field directly. The alternative specification of an imposed electrical current is not supported." according to this i cant use UDF simply ? |
||
August 3, 2022, 10:58 |
|
#16 |
Senior Member
|
No, I mean the part that I reported in my previous post:
"Note: Note that all boundary conditions used by the MHD model must be set in the Boundary Condition tab of the MHD Model dialog box. Customized boundary conditions of any form, such as parameters and expressions, are not supported." which is at section 29.3.3.4 of the User Guide, named "Setting Up Boundary Conditions". The key here is "Customized boundary conditions of any form are not supported". UDF are not explicitly mentioned, but not even excluded. So, you can't use UDF or expressions or parameters to assign boundary conditions for the MHD variables. |
|
August 3, 2022, 11:30 |
|
#17 | |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Quote:
in User Guide 2021 at section "Setting Up Boundary Conditions" , there isn't that Note Thank you for your help and guidance Regards, |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Gmsh] Boundary Layer Mesh in GMSH | Medu | OpenFOAM Meshing & Mesh Conversion | 1 | September 1, 2021 04:43 |
Segmentation violation | louiza | FLUENT | 16 | June 27, 2017 16:41 |
Boundary-adapt refinement with interior "dummy" walls | thomas. | FLUENT | 0 | July 27, 2015 11:10 |
Help! Delete the UDM codes in the UDF | Messi | Fluent UDF and Scheme Programming | 2 | January 28, 2014 10:01 |
Enforce bounds error with heat loss boundary condition at solid walls | Chander | CFX | 2 | May 1, 2012 21:11 |