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

UDF for output temperature

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 17, 2017, 12:24
Default UDF for output temperature
  #1
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Hi I am attempted to use UDF to define dimensionless temperature in order to use it in post processing results I wrote it as below :

#include "udf.h"

DEFINE_ON_DEMAND(on_demand_calc)
{
Domain *d; /* declare domain pointer since it is not passed as an
argument to the DEFINE macro */
real th = 298.3899;
real tc = 297.6101;
real temp;
Thread *t;
cell_t c;
d = Get_Domain(1); /* Get the domain using Fluent utility */

/* Compute temperature function and store in user-defined memory*/
/*(location index 0) */

begin_c_loop(c,t)
{
temp = C_T(c,t);
C_UDMI(c,t,0) = (temp-tc)/(th-tc);
}
end_c_loop(c,t)

}


I interpreted it successfully but when I select execute for demand it give me the following error:

Warning: E:\\Project current year\\paper work\\output.C: line 9:
Error: received a fatal signal (Segmentation fault).

So is there problem with the UDF? any reply please?

regards,
mariam
mariam.sara is offline   Reply With Quote

Old   August 18, 2017, 06:12
Default
  #2
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 8
MayTheFlowBeWithYou is on a distinguished road
Did you allocate memory to store the UDM? Go to "User Defined" -> "Memory" and the set "Number of User-Defined Memory Locations" to 1.
__________________
MayTheFlowBeWithYou is offline   Reply With Quote

Old   August 18, 2017, 07:21
Default
  #3
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Hi Thanks for the reply. I set the memory to 1 from the user defined menu but nothing appear at display >contours>User defined memory see pict? what the problem?
Attached Images
File Type: jpg 1.jpg (113.4 KB, 26 views)
mariam.sara is offline   Reply With Quote

Old   August 18, 2017, 07:39
Default
  #4
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 8
MayTheFlowBeWithYou is on a distinguished road
User defined memory indices start at 0. Assuming to did re-run the simulation,

You can also (in Fluent) go to File > Export > Solution Data...

The set "CFD-Post Compatible" as File Type. And choose User Memory 0 in the "Quantities list" (and whatever other things you want to store). Then click write and store in somewhere you want.

The use the CFD-Post to read that file.
__________________
MayTheFlowBeWithYou is offline   Reply With Quote

Old   August 18, 2017, 08:14
Default
  #5
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
I interpreted the UDF at first then change the memory to 1 then I initialize the solution and run the case after that when I view the user memory contours nothing appears to me same as the pict I sent in my previous reply?
mariam.sara is offline   Reply With Quote

Old   August 18, 2017, 09:42
Default
  #6
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 8
MayTheFlowBeWithYou is on a distinguished road
User Memory 1 (the one you're trying to draw contours for in the picture) shouldn't even exist for your simulation. As I said, User Defined memory Indices start at 0, so you should have a User Memory 0. Can you find this or not?
__________________
MayTheFlowBeWithYou is offline   Reply With Quote

Old   August 18, 2017, 11:21
Default
  #7
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Quote:
Originally Posted by MayTheFlowBeWithYou View Post
User Memory 1 (the one you're trying to draw contours for in the picture) shouldn't even exist for your simulation. As I said, User Defined memory Indices start at 0, so you should have a User Memory 0. Can you find this or not?
Cannot find User Memory 1 ? just User Memory 0 exist and nothing appear with it? maybe my steps was wrong or my UDF not interpreted successfully? may you repeat the procedure to me step by step? Currently do I need to apply execute on demand option or not need it?
mariam.sara is offline   Reply With Quote

Old   August 18, 2017, 13:51
Default
  #8
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 8
MayTheFlowBeWithYou is on a distinguished road
Ok, so you have your UDF exactly as you posted, it is correct.

First you allocate the User Defined Memory Location (For you UDF you only need to allocate 1 memory location for UDMI(c,t,0)).

Second, you interpret (or compile, whatever you prefer) your UDF.

Third, run the code. It is a execute on command, so go to User Defined > Execute on command... then select your code and hit "execute".

Now it should be written.

Also after viewing your first post again, I see that you use Fluent to also draw the contours. You have not selected a surface for fluent to draw them on, so it wont draw anything. You'll probably want to select "Interior_surface_body".

I hope this will work for you.
__________________
MayTheFlowBeWithYou is offline   Reply With Quote

Old   August 18, 2017, 16:04
Default
  #9
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Quote:
Originally Posted by MayTheFlowBeWithYou View Post
Ok, so you have your UDF exactly as you posted, it is correct.

First you allocate the User Defined Memory Location (For you UDF you only need to allocate 1 memory location for UDMI(c,t,0)).

Second, you interpret (or compile, whatever you prefer) your UDF.

Third, run the code. It is a execute on command, so go to User Defined > Execute on command... then select your code and hit "execute".

Now it should be written.

Also after viewing your first post again, I see that you use Fluent to also draw the contours. You have not selected a surface for fluent to draw them on, so it wont draw anything. You'll probably want to select "Interior_surface_body".

I hope this will work for you.
When I go to User Defined > Execute on command
it still give me the error I mentioned at my first post i.e.

Warning: E:\\Project current year\\kefayati paper\\output.C: line 9:
Error: received a fatal signal (Segmentation fault).
mariam.sara is offline   Reply With Quote

Old   August 19, 2017, 08:22
Default
  #10
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 8
MayTheFlowBeWithYou is on a distinguished road
I assume line 9 is "real temp;", nothing seems to be wrong there at all.

What I think is going wrong now is that the thread pointer (*t) is never actually set to anything.

I will assume that you want to loop over all cells in the domain. To do this try the following code:

#include "udf.h"

DEFINE_ON_DEMAND(on_demand_calc)
{
Domain *d; /* declare domain pointer since it is not passed as an
argument to the DEFINE macro */
real th = 298.3899;
real tc = 297.6101;
real temp;
Thread *t;
cell_t c;
d = Get_Domain(1); /* Get the domain using Fluent utility */

/* Compute temperature function and store in user-defined memory*/
/*(location index 0) */

thread_loop_c(t,d) /* This will loop over all threads in the domain */
{
begin_c_loop(c,t) /* This will loop over all cells in a thread */
{
temp = C_T(c,t);
C_UDMI(c,t,0) = (temp-tc)/(th-tc);
}
end_c_loop(c,t)
}
}

Use as I described before.
__________________
MayTheFlowBeWithYou 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
UDF for Temperature Dependent Energy Source er.mkumar Fluent UDF and Scheme Programming 9 March 14, 2024 04:01
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 07:15
UDF temperature profile asal Fluent UDF and Scheme Programming 67 August 7, 2018 12:41
UDF slip and temperature jump from IFRT abir Fluent UDF and Scheme Programming 1 July 30, 2012 05:44
UDF or any approach for Bulk Temperature calculation vemps FLUENT 0 May 1, 2009 01:09


All times are GMT -4. The time now is 07:18.