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

UDM segmentation fault.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 23, 2017, 10:39
Default UDM segmentation fault.
  #1
Member
 
sebastian bergman
Join Date: Mar 2017
Location: seattle
Posts: 52
Rep Power: 9
Tushar_Telmasre is on a distinguished road
I am trying to learn the use of UDMs.
I read through ansys help and tried to execute define on demand udm.

the code is
/************************************************** ********************
UDF to calculate temperature field function and store in
user-defined memory. Also print min, max, avg temperatures.
************************************************** *********************/
#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 tavg = 0.;
real tmax = 0.;
real tmin = 0.;
real temp,volume,vol_tot;
Thread *t;
cell_t c;
d = Get_Domain(1); /* Get the domain using ANSYS Fluent utility */

/* Loop over all cell threads in the domain */
thread_loop_c(t,d)
{

/* Compute max, min, volume-averaged temperature */

/* Loop over all cells */
begin_c_loop(c,t)
{
volume = C_VOLUME(c,t); /* get cell volume */
temp = C_T(c,t); /* get cell temperature */

if (temp < tmin || tmin == 0.) tmin = temp;
if (temp > tmax || tmax == 0.) tmax = temp;

vol_tot += volume;
tavg += temp*volume;

}
end_c_loop(c,t)

tavg /= vol_tot;

printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

/* 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-tmin)/(tmax-tmin);
}
end_c_loop(c,t)

}
}


This is the same as given in the ansys help.

further i defined a memory location in fluent.

solved the following problem.
A Square aluminium block of lenght 1mm. properties as given in fluent.
left boundry: 600K temperature.
Right boundry: 100K temperature.
solved the problem with time step of 1e-5 for 100 time steps.

now when i am trying to execute on demand the function it is giving me a
segmentation fault. what is wrong here.

As far as i know segmentation fault occurs when code tries to access undefined memory location. I defined 1 user defined memory slot. still it is not working.
what needs to be done.
Please help.
Tushar_Telmasre is offline   Reply With Quote

Old   March 24, 2017, 06:45
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
You are correct that this error indicates that you are trying to access a memory location that does not exist. The next step is to identiy where in your code this happens.

It could be in three places: C_UDMI(c,t,0), C_VOLUME(c,t), C_T(c,t)

If you remove the line with C_UDMI(c,t,0), do you still get this error?
If you replace C_VOLUME(c,t) by 0.1, do you still get this error?
If you replace C_T(c,t) by 300, do you still get this error?

If the error disappears, you know which line causes the error. And then think about why it could be. If C_T is the problem, are you sure that all cells have a temperature associated?
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
Segmentation fault when running dieselFoam or dieselEngineFoam in parallel francesco OpenFOAM Bugs 4 May 2, 2017 22:59
Segmentation fault in SU2 V5.0 ygd SU2 2 March 1, 2017 05:38
UDF with UDM Error: segmentation fault dj1210 Fluent UDF and Scheme Programming 4 November 24, 2016 10:44
Segmentation fault when running in parallel Pj. OpenFOAM Running, Solving & CFD 3 April 8, 2015 09:12
segmentation fault when installing OF-2.1.1 on a cluster Rebecca513 OpenFOAM Installation 9 July 31, 2012 16:06


All times are GMT -4. The time now is 05:41.