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

Fluent error while executing UDF

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 5, 2025, 07:01
Default Fluent error while executing UDF
  #1
New Member
 
Raj
Join Date: Dec 2025
Posts: 3
Rep Power: 2
Raj123 is on a distinguished road
I'm trying to simulate the periodic heat transfer where outlet temperature of fluid should be taken as upstream bulk temperature for next repeat. So this way continuous heat loss to the boundary solid walls maintained at constant wall temperature for varying thermal properties including density for helium flow. Please check the code, im facing the segmentation error and fluent is closing itself.

/* periodic_bulkT_UDF.c
- Works for flow in negative Z direction
- Outlet periodic face zone id = 15
- Uses Fluent-provided T-dependent properties (rho, cp, k, mu)
- Mass-weighted bulk temp computed on outlet faces each timestep (adjust)
- Relaxation applied to avoid oscillations
- Profile UDF returns the scalar bulk temp to Periodic Bulk Temperature
*/

#include "udf.h"

#define OUTLET_ZONE_ID 9
/* relaxation: 0 < alpha <= 1. 0.3 is typical starting value */
#define RELAX_ALPHA 0.30

/* global storage */
static real T_bulk_outlet = 300.0;
static int initialized = 0;

/* ADJUST UDF: compute mass-weighted outlet bulk temperature each timestep */
DEFINE_ADJUST(compute_outlet_bulkT, domain)
{
Thread *t_out;
face_t f;
real mdot_sum = 0.0;
real Tm_sum = 0.0;

t_out = Lookup_Thread(domain, OUTLET_ZONE_ID);

begin_f_loop(f, t_out)
{
cell_t c0 = F_C0(f, t_out);
Thread *tc0 = THREAD_T0(t_out);

/* Temperature at the face */
real Tface = F_T(f, t_out);

/* density from cell adjacent to face (Fluent updates rho(T) automatically) */
real rho = C_R(c0, tc0);

/* face w-velocity (z component). For negative z flow use -w */
real w_face = F_W(f, t_out);

/* face area vector and magnitude */
real area_vec[ND_ND];
F_AREA(area_vec, f, t_out);
real Af = NV_MAG(area_vec);

/* mass flow through face (positive for flow in -Z, so use -w_face) */
real mdot = rho * (-w_face) * Af;

if (mdot > 0.0)
{
mdot_sum += mdot;
Tm_sum += mdot * Tface;
}
}
end_f_loop(f, t_out);

if (mdot_sum > 1e-20)
{
real T_new = Tm_sum / mdot_sum;

if (initialized)
T_bulk_outlet = RELAX_ALPHA * T_new + (1.0 - RELAX_ALPHA) * T_bulk_outlet;
else
{
T_bulk_outlet = T_new;
initialized = 1;
}
}
/* else keep previous value */
}

/* PROFILE UDF: supply bulk temperature to periodic inlet Bulk Temperature field */
DEFINE_PROFILE(periodic_bulkT_profile, thread, position)
{
face_t f;

begin_f_loop(f, thread)
{
/* set the profile value (Fluent expects this scalar) */
F_PROFILE(f, thread, position) = T_bulk_outlet;
}
end_f_loop(f, thread)
}
Raj123 is offline   Reply With Quote

Old   December 11, 2025, 05:43
Default
  #2
New Member
 
Thore
Join Date: Nov 2023
Posts: 9
Rep Power: 4
Thore850 is on a distinguished road
Hello,

without knowing more details about your setup its hard to tell why a segmentation error ocurrs. Normally these errors appear if a Macro tries to access something it is not supposed to access.

Are you using a multiphase formulation? If yes, this could be the problem. In that case you currently provide the mixture domain oulet id, and try to access the temperature and density of the species, which in the case of a multiphase formulation is to be found in a sub-domain, leading to a segmentation error.

Best regards

Thore
Thore850 is offline   Reply With Quote

Old   December 11, 2025, 05:50
Default
  #3
New Member
 
Raj
Join Date: Dec 2025
Posts: 3
Rep Power: 2
Raj123 is on a distinguished road
No I'm not using multiphase, I'm trying to simulate helium flow through offset fin geometry with thermophysical properties varying with temperature. I'm having constant wall temperature boundary condition of 80K and inlet helium temperature at 300 K. Basically I'm trying to simulate the cool down of helium gas from 300 K, using periodic boundary conditions along the flow for offset fin geometry.

I have doubt, can we use periodic boundary conditions along the streamwise direction for variable density flows due to temperature ? In fluent I'm getting a warning saying that
"periodic boundary conditions with non zero mass flow rate / pressure gradient is not valid for variable density flows"
Raj123 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
FLUENT UDF for parallelization Cooper24 FLUENT 0 August 27, 2021 12:55
Fluent UDF for moving laser heating of a solid block Cooper24 Fluent UDF and Scheme Programming 7 July 9, 2021 06:56
Problem running fluent with udf on batch tobi b. Fluent UDF and Scheme Programming 3 April 14, 2016 14:54
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 11:16


All times are GMT -4. The time now is 06:10.