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

Density gradient UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 29, 2022, 04:43
Default Density gradient UDF
  #1
Member
 
thedal's Avatar
 
Thamilmani M
Join Date: Sep 2017
Location: IIT Bombay, Mumbai
Posts: 52
Rep Power: 9
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.


Code:
# 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;
}
__________________
Always
Thedal
thedal is offline   Reply With Quote

Reply

Tags
density, fluent, gradient, udf, uds


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


All times are GMT -4. The time now is 00:44.