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

Udm value on the walls

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes
  • 1 Post By sbaffini
  • 1 Post By sbaffini
  • 1 Post By sbaffini
  • 1 Post By sina_sls

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 27, 2017, 08:03
Default Udm value on the walls
  #1
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 8
rarnaunot is on a distinguished road
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)
}
}
rarnaunot is offline   Reply With Quote

Old   September 27, 2017, 08:33
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
You're looping over cells. Boundaries have F_UDMI and F_UDSI
sbaffini is offline   Reply With Quote

Old   September 27, 2017, 09:15
Default
  #3
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 8
rarnaunot is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
You're looping over cells. Boundaries have F_UDMI and F_UDSI
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)

}
rarnaunot is offline   Reply With Quote

Old   September 27, 2017, 11:00
Default
  #4
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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.
rarnaunot likes this.
sbaffini is offline   Reply With Quote

Old   September 28, 2017, 07:10
Default
  #5
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 8
rarnaunot is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
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.
Hello!

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...
rarnaunot is offline   Reply With Quote

Old   September 28, 2017, 10:24
Default
  #6
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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
rarnaunot likes this.
sbaffini is offline   Reply With Quote

Old   October 3, 2017, 04:51
Default
  #7
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 8
rarnaunot is on a distinguished road
Thanks a lot because my college and I didn't know this important part!!
Quote:
Originally Posted by sbaffini View Post
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.
Yes! I noticed this after writing here and I change it but the same error ocurred because of the above problem.
Quote:
Originally Posted by sbaffini View Post
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.
The code of sbaffini works perfectly to my case

I'm a little confussed with your first sentence :
Quote:
Originally Posted by sbaffini View Post
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.
I tried to write the more kindly I can and English is not my mother tongue so I try always my best in here. Sometimes I decide to write the shortest as possible in order to not make any english mistakes. So I really apologised if I express myself as an unfriendly or unpleasant person because I REALLY APRECIATE YOUR HELP THROUGH HERE!!

THANKS for your kindly help, sbaffini!!!
rarnaunot is offline   Reply With Quote

Old   October 3, 2017, 15:55
Default
  #8
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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.
rarnaunot likes this.
sbaffini is offline   Reply With Quote

Old   August 3, 2022, 07:12
Default
  #9
Member
 
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 3
sina_sls is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
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.
Hello,

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,
sina_sls is offline   Reply With Quote

Old   August 3, 2022, 07:33
Default
  #10
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Quote:
Originally Posted by sina_sls View Post
Hello,

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,
Not sure I understand, nor I will be able to check or help with any code now. But, you need to know the following, define_adjust is called at the beginning of each iteration and it is general, doesn't have any thread as input, so it is up to what you want to do in it. Yet, it is not meant to directly operate on the F_PROFILE variable (nor it actually makes sense).

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?
sbaffini is offline   Reply With Quote

Old   August 3, 2022, 07:45
Default
  #11
Member
 
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 3
sina_sls is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
Not sure I understand, nor I will be able to check or help with any code now. But, you need to know the following, define_adjust is called at the beginning of each iteration and it is general, doesn't have any thread as input, so it is up to what you want to do in it. Yet, it is not meant to directly operate on the F_PROFILE variable (nor it actually makes sense).

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?
Thank you for your response


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
sina_sls is offline   Reply With Quote

Old   August 3, 2022, 08:10
Default
  #12
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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.
sbaffini is offline   Reply With Quote

Old   August 3, 2022, 08:22
Default
  #13
Member
 
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 3
sina_sls is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
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.
Thanks

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
Attached Images
File Type: png UDS b v.png (22.1 KB, 2 views)
sina_sls is offline   Reply With Quote

Old   August 3, 2022, 09:23
Default
  #14
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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.
sbaffini is offline   Reply With Quote

Old   August 3, 2022, 09:52
Default
  #15
Member
 
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 3
sina_sls is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
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.
Thank you and i appreciate you for your time,

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 ?
sina_sls is offline   Reply With Quote

Old   August 3, 2022, 09:58
Default
  #16
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,014
Blog Entries: 29
Rep Power: 38
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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.
sbaffini is offline   Reply With Quote

Old   August 3, 2022, 10:30
Default
  #17
Member
 
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 3
sina_sls is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
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.
Thank you

in User Guide 2021 at section "Setting Up Boundary Conditions" , there isn't that Note

Thank you for your help and guidance

Regards,
sbaffini likes this.
sina_sls is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[Gmsh] Boundary Layer Mesh in GMSH Medu OpenFOAM Meshing & Mesh Conversion 1 September 1, 2021 03:43
Segmentation violation louiza FLUENT 16 June 27, 2017 15:41
Boundary-adapt refinement with interior "dummy" walls thomas. FLUENT 0 July 27, 2015 10:10
Help! Delete the UDM codes in the UDF Messi Fluent UDF and Scheme Programming 2 January 28, 2014 09:01
Enforce bounds error with heat loss boundary condition at solid walls Chander CFX 2 May 1, 2012 20:11


All times are GMT -4. The time now is 03:49.