CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Density gradient UDF

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

LinkBack Thread Tools Search this Thread Display Modes
Old   June 29, 2022, 03:43
Default Density gradient UDF
thedal's Avatar
Thamilmani M
Join Date: Sep 2017
Location: IIT Bombay, Mumbai
Posts: 52
Rep Power: 8
thedal is on a distinguished road
I have written this code to get the Density gradient in a pressure-based solver by switching ON UDS for density. But it gives SIGSEGV error.

This is based on the UDF Example available in Fluent Manual for getting Temperature gradient. I changed it to Density. Since face values are not available for density, I interpolated and calculated it.

# 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_UDSI(c, t, 0) = C_R(c, t);
        end_c_loop(c, t)

    thread_loop_f(t, domain)
        if (THREAD_STORAGE(t, SV_UDS_I(0)) != NULL)
            begin_f_loop(f, t)
            F_UDSI(f, t, 0) = (C_R(F_C0(f, t), THREAD_T0(t)) + C_R(F_C1(f, t), THREAD_T1(t))) / 2;
        end_f_loop(f, t)

DEFINE_SOURCE(gradient_source, c, t, dS, eqn)
    real source;

    source = C_UDSI_G(c, t, 0)[1];

    dS[eqn] = 0;
    return source;
thedal is offline   Reply With Quote


density, fluent, gradient, udf, uds

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
temperature gradient problem in udf Souviktor Fluent UDF and Scheme Programming 6 March 10, 2019 05:48
How to calculate number density in breakup rate UDF? masoud.ravan Fluent UDF and Scheme Programming 0 April 4, 2018 03:56
UDF for Density Priyank Mehta Fluent UDF and Scheme Programming 19 December 6, 2017 07:07
UDF to Access Wall Normal Concentration Gradient Daniel Tanner Fluent UDF and Scheme Programming 4 February 18, 2015 14:35
REAL GAS UDF brian FLUENT 6 September 11, 2006 08:23

All times are GMT -4. The time now is 20:35.