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

SEGMENTATION fault while using DEFINE_PROPERTY macro

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   January 24, 2018, 08:57
Post SEGMENTATION fault while using DEFINE_PROPERTY macro
  #1
New Member
 
Leonard
Join Date: Dec 2017
Posts: 4
Rep Power: 8
leo1993 is on a distinguished road
Dear all,

I am relatively new to programming in c, and completely new in writing UDF's for Fluent. Now, I want to write an UDF that defines the thermal conductivity for the primary phase and the secondary phase. I am using the DEFINE_PROPERTY macro to do this. I have tried this in the following way:
Code:
/*********************************************************************
   UDF that simulates the correlation for the conductivity proposed by Shen et al.                                    
**********************************************************************/
#include "udf.h"

DEFINE_PROPERTY(cell_conductivity,cell,thread)
{
	/* Variable fluid properties for water-vapor subcooling @353.15 K as defined by Mills */
        real T_SAT 						= 373.15;
	real k_v 						= 24.8e-3;
	real k_l						= 0.674;
	real ktc_;
	/* Enhancement factor n, as proposed by Shen. Enhances the energy transportation in the two-phase region. */
	real n 							= 1.;
	
	Domain *subdomain_gas;
	Domain *subdomain_liq;
	int phase_domain_index_gas; 		
	int phase_domain_index_liq;
	Thread *gas;
	Thread *liq;
	real temp;
	
	subdomain_gas 					= Get_Domain(2);										/* retrieve pointer to primary phase domain */
	subdomain_liq 					= Get_Domain(3);										/* retrieve pointer to secondary phase domain */
	phase_domain_index_gas 			        = PHASE_DOMAIN_INDEX(subdomain_gas);				
	phase_domain_index_liq 			        = PHASE_DOMAIN_INDEX(subdomain_liq);
        gas 						= THREAD_SUB_THREAD(thread, phase_domain_index_gas);
        liq 						= THREAD_SUB_THREAD(thread, phase_domain_index_liq); 
	temp 					        = C_T(cell,thread);


  
	if (temp >= T_SAT){
		ktc_ = C_VOF(cell,liq) * k_l + C_VOF(cell,gas) * k_v;
	}
	else {
		ktc_ = C_VOF(cell,liq) * k_l + n * C_VOF(cell,gas) * k_v;
	}
	return ktc_;
}
The problem is the following. I am able to compile the code and to load it, but when I specify the user defined conductivity in the material properties, I receive a segmentation fault.
I would be very happy if someone could help me. Also, feel free to give any tips on programming if you like.

Cheers!
leo1993 is offline   Reply With Quote

 

Tags
define_property, segmentaion fault, udf


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 21:59
Segmentation fault in SU2 V5.0 ygd SU2 2 March 1, 2017 04:38
Segmentation fault when running in parallel Pj. OpenFOAM Running, Solving & CFD 3 April 8, 2015 08:12
Segmentation Fault w/ compiled OF 2.2.0 - motorBike example sudo OpenFOAM Running, Solving & CFD 3 April 2, 2013 17:27
segmentation fault when installing OF-2.1.1 on a cluster Rebecca513 OpenFOAM Installation 9 July 31, 2012 15:06


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