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 31, 2015, 18:40
Default
  #21
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
We're both trying to help you out here Ondrej, and have both read your problem, understood it and given guidance. I agree with pakk that these forums are for learning and troubleshooting Fluent issues, not simply doing the work for you. It appears you ignored my comment on the domain pointer solution back in this post, and I had to repeat myself before you fixed that issue. For every solution we provide in threads, I'm sure there's a number of others who stumble across the same issue and find these threads through search engines.

That being said, I think the key issue you face is that computers like to start from zero; for example, you access the fourth element of an array with x[3] and not with x[4]. Applying this logic to your C_UDMI macro: try accessing C_UDMI(c,t,0).
`e` is offline   Reply With Quote

Old   March 31, 2015, 19:19
Default
  #22
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
We're both trying to help you out here Ondrej, and have both read your problem, understood it and given guidance. I agree with pakk that these forums are for learning and troubleshooting Fluent issues, not simply doing the work for you. It appears you ignored my comment on the domain pointer solution back in this post, and I had to repeat myself before you fixed that issue. For every solution we provide in threads, I'm sure there's a number of others who stumble across the same issue and find these threads through search engines.

That being said, I think the key issue you face is that computers like to start from zero; for example, you access the fourth element of an array with x[3] and not with x[4]. Applying this logic to your C_UDMI macro: try accessing C_UDMI(c,t,0).
I know sorry for this. I tried to apply your recomendations but with the same result:

Updating solution at time level N... done.
iter energy delta_time time time/iter

Error: received a fatal signal (Segmentation fault).

Error: received a fatal signal (Segmentation fault).
Error Object: #f


This is my updated code:
#include "udf.h"

DEFINE_ADJUST(teste, domain)
{
Thread *t;
cell_t c;

thread_loop_c(t, domain)
{
begin_c_loop_all(c, t)
{
C_UDMI(c,t,0) = NV_MAG(C_T_G(c,t));
}
end_c_loop_all(c, t)
}
}



Then I tried it from another side, but with same resault:

#include "udf.h"
DEFINE_ADJUST(max_C_T_G, domain)
{
cell_t c;
Thread *ct;
real maxT;
maxT = 0.0;
thread_loop_c(ct,domain)
{
begin_c_loop(c,ct)
{
if (C_T_G(c,ct)[0] > maxT)
{
maxT = C_T_G(c,ct)[0];
}
}
end_c_loop(c,ct)
}
printf("Maximum temperature = %f \n", maxT);
}
Sorry for it.
perun333 is offline   Reply With Quote

Old   March 31, 2015, 19:27
Default
  #23
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Try emptying your DEFINE_ADJUST UDF and only have a message, for example:

Code:
#include "udf.h"
DEFINE_ADJUST(max_C_T_G, domain)
{
    Message("Hello...\n");
}
If you're not receiving the message above to your screen then you're not re-compiling the UDF correctly and should read my post on how to re-compile UDFs.

Lastly, use Message() instead of printf().
`e` is offline   Reply With Quote

Old   March 31, 2015, 19:45
Default
  #24
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
Try emptying your DEFINE_ADJUST UDF and only have a message, for example:

Code:
#include "udf.h"
DEFINE_ADJUST(max_C_T_G, domain)
{
    Message("Hello...\n");
}
If you're not receiving the message above to your screen then you're not re-compiling the UDF correctly and should read my post on how to re-compile UDFs.

Lastly, use Message() instead of printf().
I tried your example and it works, so Im compiling correctly. I think that problem is somewhere inside code...
perun333 is offline   Reply With Quote

Old   March 31, 2015, 19:52
Default
  #25
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Work through your code line by line (adding one by one from the working simple message UDF) until you determine which line is causing your error and then fix it, good luck!
`e` is offline   Reply With Quote

Old   April 1, 2015, 04:21
Question
  #26
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
Work through your code line by line (adding one by one from the working simple message UDF) until you determine which line is causing your error and then fix it, good luck!
I think thats correct:

#include "udf.h"
DEFINE_ADJUST(max_C_T_G, domain)
{
cell_t c;
Thread *ct;
real maxT;
maxT = 0.0;
thread_loop_c(ct,domain)
{
begin_c_loop(c,ct)
{
if (C_T_G(c,ct)[0] > maxT)
{
maxT = C_T_G(c,ct)[0];
}
}
end_c_loop(c,ct)
}
printf("Maximum temperature = %f \n", maxT);
}

But problem is maybe with axisymetric definition.
perun333 is offline   Reply With Quote

Old   April 1, 2015, 04:59
Default
  #27
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The problem could be that your temperature gradient is not yet defined. Is this on the first iteration? If so, let your simulation run for a few time steps before you use this UDF.

And a minor detail: replace
Code:
printf("Maximum temperature = %f \n", maxT);
by
Code:
Message("Maximum temperature gradient = %f K/m.\n", maxT);
pakk is offline   Reply With Quote

Old   April 1, 2015, 16:57
Default
  #28
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
The problem could be that your temperature gradient is not yet defined. Is this on the first iteration? If so, let your simulation run for a few time steps before you use this UDF.

And a minor detail: replace
Code:
printf("Maximum temperature = %f \n", maxT);
by
Code:
Message("Maximum temperature gradient = %f K/m.\n", maxT);
Hi Pakk,

I tried your opinions:
-change the line for message in udf
-run transient calculate >>calculation converget
-compiled upgraded udf
-Adjust hook
-calculate
-error:
Updating solution at time level N... done.
iter energy delta_time time time/iter
! 45 solution is converged
45 5.6044e-07 1.0000e+01 1.3000e+02 0:00:02 20

Error: received a fatal signal (Segmentation fault).

Error: received a fatal signal (Segmentation fault).
Error Object: #f
perun333 is offline   Reply With Quote

Old   April 2, 2015, 05:05
Default
  #29
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Hmm, then I don't know...

You could try to see if the gradient is the problem by replacing C_T_G(c,ct)[0] by C_T(c,ct). But if the gradient is really the problem, I would not know how to solve that.

If C_T(c,ct) also does not work, the axisymmetry might be the problem. But then, I also would not know how to solve that.
pakk is offline   Reply With Quote

Old   April 2, 2015, 05:32
Default
  #30
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
Hmm, then I don't know...

You could try to see if the gradient is the problem by replacing C_T_G(c,ct)[0] by C_T(c,ct). But if the gradient is really the problem, I would not know how to solve that.

If C_T(c,ct) also does not work, the axisymmetry might be the problem. But then, I also would not know how to solve that.
With maximal temperature macro C_T it works
perun333 is offline   Reply With Quote

Old   April 12, 2015, 16:45
Default
  #31
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
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.
Hi pakk,

I try to compiled and adjusted udf (which have to work) from ansys forum.
Here is code:
#include "udf.h"
DEFINE_ADJUST(total_dissipation, domain)
{
cell_t c;
Thread *ct;
real total_diss;

total_diss = 0.0; /* Initialise total_diss before the loop */

thread_loop_c(ct,domain)
{
begin_c_loop(c,ct)
{
total_diss += C_D(c,ct) * C_VOLUME(c,ct); /* Use += to sum up values */
}
end_c_loop(c,ct)
}
Message("Volume integral of turbulent dissipation = %f \n", total_diss);
}



And I have still same resault:

fatal error (segmentation fault)

I tried to compiled simple udf which contains only hello world and it works. Have you any idea where is problem?
perun333 is offline   Reply With Quote

Old   May 9, 2016, 11:36
Default
  #32
New Member
 
Join Date: Jul 2014
Posts: 10
Rep Power: 12
bmahnic is on a distinguished road
Hi!

I think that the solution to your problem is defining the thread value as equal to DT_THREAD(dt).
The reason is in the fact that you are using the dynamic mesh. In that case normal thread definition does not work. Consequentially, your face looping macro aborts the simulation.

Regards, Marko.
bmahnic is offline   Reply With Quote

Old   July 9, 2021, 15:03
Default
  #33
New Member
 
wiki
Join Date: Jun 2021
Posts: 8
Rep Power: 5
wiki123 is on a distinguished road
@OP.

Actually what was being conveyed to you was that by default the first memory location is 0 in Ansys fluent. You defined one memory means you defined 0 serial number memory. It starts with 0.

But you were storing the gradient in the user defined memory 1 which was not existing.
wiki123 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 15:09.