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

UDF temperature gradient

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 29, 2015, 16:44
Default UDF temperature gradient
  #1
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Hi guys

I would like to create UDF for computing temperature gradient (in time and space). I have 2D axysimmetric model. Some tips? I havent enough experiencies with c++.
saeedsh.627 likes this.
perun333 is offline   Reply With Quote

Old   March 29, 2015, 17:45
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Fluent already has a macro for the temperature gradient: C_T_G(c,t). Read the UDF manual for details.
`e` is offline   Reply With Quote

Old   March 29, 2015, 18:07
Default
  #3
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by `e` View Post
Fluent already has a macro for the temperature gradient: C_T_G(c,t). Read the UDF manual for details.

Could you be more specific?
perun333 is offline   Reply With Quote

Old   March 29, 2015, 18:21
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Read section "3.2.3.7. Gradient (G) and Reconstruction Gradient (RG) Vector Macros" on page 221 of the ANSYS Fluent 15.0 UDF Manual (may have different page number and/or section for different versions of Fluent).
Rajkool likes this.
`e` is offline   Reply With Quote

Old   March 29, 2015, 19:03
Default
  #5
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by `e` View Post
Read section "3.2.3.7. Gradient (G) and Reconstruction Gradient (RG) Vector Macros" on page 221 of the ANSYS Fluent 15.0 UDF Manual (may have different page number and/or section for different versions of Fluent).
is it correct?

#include "udf.h"
DEFINE_ON_DEMAND(Temp_grad_ondemand)
{
Domain *d;
cell_t c;
Thread *t;
d = Get_Domain(1);

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{

C_UDMI(c,t,1) = NV_MAG(C_T_G(c,t));

}
end_c_loop(c,t)
}

}
perun333 is offline   Reply With Quote

Old   March 29, 2015, 19:25
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Your code appears correct if you want the magnitude of the temperature gradient. Have you tried compiling this UDF, and do you get expected results?
`e` is offline   Reply With Quote

Old   March 29, 2015, 19:38
Default
  #7
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by `e` View Post
Your code appears correct if you want the magnitude of the temperature gradient. Have you tried compiling this UDF, and do you get expected results?

thank you. Do you know how it looks with macro DEFINE_ADJUST?

Thanks
perun333 is offline   Reply With Quote

Old   March 29, 2015, 19:51
Default
  #8
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The code for determining the temperature gradient magnitude with a DEFINE_ADJUST macro would look very similar to your DEFINE_ON_DEMAND code. Again, have a read of the UDF manual and return if you have any precise questions.
`e` is offline   Reply With Quote

Old   March 31, 2015, 06:27
Default
  #9
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by `e` View Post
The code for determining the temperature gradient magnitude with a DEFINE_ADJUST macro would look very similar to your DEFINE_ON_DEMAND code. Again, have a read of the UDF manual and return if you have any precise questions.
I tried to use ADJUST, but didnt work. Any Idea?

# include "udf.h"
# define domain_ID 2
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;

domain = Get_Domain(domain_ID);

/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,1) = NV_MAG(C_T_G(c,t));
}
end_c_loop (c,t)
}
}
perun333 is offline   Reply With Quote

Old   March 31, 2015, 07:04
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
What are the errors and when do they occur?

'domain' is a pointer to the domain that the adjust function is to be applied. Typically you only have one domain and use the macro Get_Domain(1) if you require the pointer for it (but it's provided with DEFINE_ADJUST). Do you have multiple domains or are you confusing domains with cell zones?
`e` is offline   Reply With Quote

Old   March 31, 2015, 07:27
Default
  #11
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by `e` View Post
What are the errors and when do they occur?

'domain' is a pointer to the domain that the adjust function is to be applied. Typically you only have one domain and use the macro Get_Domain(1) if you require the pointer for it (but it's provided with DEFINE_ADJUST). Do you have multiple domains or are you confusing domains with cell zones?
It said receive fatal signal. My steps are:

1.Star fluet
2. Sets bounday conditions
3. Interpred program
4. Set funkcions hook =>set it in adjust
5. Star calculation and then error

Thx
Attached Images
File Type: jpg dsf.jpg (60.0 KB, 112 views)
perun333 is offline   Reply With Quote

Old   March 31, 2015, 08:12
Default
  #12
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
I'll be specific, remove the following line of code:

Code:
domain = Get_Domain(domain_ID);
If you're still getting fatal errors crashing Fluent, ensure you have enabled the user defined memory.
`e` is offline   Reply With Quote

Old   March 31, 2015, 08:25
Default
  #13
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by `e` View Post
I'll be specific, remove the following line of code:

Code:
domain = Get_Domain(domain_ID);
If you're still getting fatal errors crashing Fluent, ensure you have enabled the user defined memory.
I removed line of code and define memory 1 but still fatal error.
Attached Images
File Type: jpg sdf.jpg (51.9 KB, 52 views)
perun333 is offline   Reply With Quote

Old   March 31, 2015, 08:33
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by perun333 View Post
I removed line of code and define memory 1 but still fatal error.
Yes, you define 1 memory (so location 0) and try to store things in memory location 1! That does not work.
pakk is offline   Reply With Quote

Old   March 31, 2015, 08:36
Default
  #15
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Yes, you define 1 memory (so location 0) and try to store things in memory location 1! That does not work.
So what you recomend?
perun333 is offline   Reply With Quote

Old   March 31, 2015, 08:39
Default
  #16
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I recommend that you think about how to solve the problem.

The current situation: you use a memory location that is not defined.
The wanted situation: you use a memory location that is defined.

How would you go from the current situation to the wanted situation? There are two strategies for that.
wiki123 likes this.
pakk is offline   Reply With Quote

Old   March 31, 2015, 08:53
Default
  #17
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by pakk View Post
I recommend that you think about how to solve the problem.

The current situation: you use a memory location that is not defined.
The wanted situation: you use a memory location that is defined.

How would you go from the current situation to the wanted situation? There are two strategies for that.
Sorry I dont have much experiencies with programing in C and really dont know why I have to set this memory. I computing heat transfer in 2D axisymetric model with conditions:
- max. time gradient 20°C/h during heating
- max. time gradient 30°C/h during cooling
- max. space temperature gradient 60°C/m

I have found that I have to use type define_adjust and macro C_T_G. So I tried to use this after some upgrades:

# include "udf.h"
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,1) = NV_MAG(C_T_G(c,t));
}
end_c_loop (c,t)
}
}
perun333 is offline   Reply With Quote

Old   March 31, 2015, 09:04
Default
  #18
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by perun333 View Post
Sorry I dont have much experiencies with programing in C and really dont know why I have to set this memory. I computing heat transfer in 2D axisymetric model with conditions:
- max. time gradient 20°C/h during heating
- max. time gradient 30°C/h during cooling
- max. space temperature gradient 60°C/m

I have found that I have to use type define_adjust and macro C_T_G. So I tried to use this after some upgrades:

# include "udf.h"
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,1) = NV_MAG(C_T_G(c,t));
}
end_c_loop (c,t)
}
}
My question has nothing to do with programming in c. It has to do with reading skills and basic logic.

The current situation: you use a memory location that is not defined.
The wanted situation: you use a memory location that is defined.

How would you go from the current situation to the wanted situation? There are two strategies for that. This is really not a super-hard question.
wiki123 likes this.
pakk is offline   Reply With Quote

Old   March 31, 2015, 10:16
Default
  #19
New Member
 
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11
perun333 is on a distinguished road
Quote:
Originally Posted by pakk View Post
My question has nothing to do with programming in c. It has to do with reading skills and basic logic.

The current situation: you use a memory location that is not defined.
The wanted situation: you use a memory location that is defined.

How would you go from the current situation to the wanted situation? There are two strategies for that. This is really not a super-hard question.
Sorry, I thought that this forum helps to sort out problems. But I just only see cynic approach, sorry :/
perun333 is offline   Reply With Quote

Old   March 31, 2015, 10:24
Default
  #20
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by perun333 View Post
Sorry, I thought that this forum helps to sort out problems. But I just only see cynic approach, sorry :/
It is bad that you see it that way. The way I see it, I am trying to help you understand the problem, and help you get to a solution.

You give the impression that you don't want to understand anything, but that you just want to hear what you should do to get rid of your error. Is that what you want? In that case, you'll have to hire me, I don't do those jobs for free.
kanak_BUET_ME19 likes this.
pakk is offline   Reply With Quote

Reply


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
Temperature gradient using wall-functions chantre OpenFOAM 2 July 19, 2021 08:56
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 08:15
UDF for time-mean temperature gradient nenazarian Fluent UDF and Scheme Programming 1 November 12, 2012 04:30
UDF slip and temperature jump from IFRT abir Fluent UDF and Scheme Programming 1 July 30, 2012 06:44
UDF velocity and temperature Raj FLUENT 3 February 1, 2009 19:29


All times are GMT -4. The time now is 17:58.