Tagged: cfd-udf-fleunt, define_adjust, define-source, udf
-
-
January 24, 2023 at 3:38 am
kds_ansys
SubscriberHello,
I am new to both UDF and Ansys and am currently using the following UDF code for my simulation. While the code compiles without any errors, when I try to initialize the model, I encounter an error and the simulation closes automatically.
Node 6: process 13572: received signal sigsegv.
Node 7: process 110688: received signal sigsegv.
99999: mpt_accept: error : accept failed: No error
99999: mpt_accept: error : accept failed: No error
99999: mpt_accept: error : accept failed: No error
99999: mpt_accept: error : accept failed: No error
Bad termination of one of your application processes
Rank 0 PID 99524 Running at xxx
Exit status: -1 (ffffffff)
---------------------------------------------
Here is my code
/*************************************************/
/*************************************************//*************************************************/#include "udf.h"#include "sg.h"real m_sum=0;real ar_sum=0;real m_max=0; /*mass flux at the corner of meniscus: used for thin film region*/real h_ar_int=0;real h_avg=0;DEFINE_ADJUST(Get_q_V, d){Thread *t; // thread pointerDomain *domain; // domain pointercell_t c,c0; // define cellface_t f,f2,f_face_l; //define faceThread *tf, *tf2;int n,n2; // define n and n2real S=0;int liquid_id=7; // the liquid zone's thread ID the domain ID/*real p, ps, Ts, hfg, M_bar, R_bar, M_air, p_l_sat;*///water propertiesreal ps=3167.739;real Ts= 298;real hfg= 2270e3;real M_bar=18.01;real R_bar=8314.47;real p_l_sat=0;real cp = 4181.3;int liquid_inter_id1=12; // the liquid interface at the liquid/vapor interfacereal count=0;real dr0[ND_ND]; // the vector that connects the centroid of cell c0 to the face centroidreal dr1[ND_ND]; // the vector that connects the centroid of cell c1 to the face centroidreal A[ND_ND]; // the area normal vectorreal es[ND_ND]; //the unit normal vector in the direction from cell c0 to c1real T; // define the temperaturereal temp2; // define the mass flow ratereal cent1[3],cent2[3]; // the centroid of cellreal ar; /* area of the face of the cell*/real q, temp;real q_conv;real qd=0;real ds, A_by_es; // the value A.A/A.esreal AA, B;m_sum=0;ar_sum=0;m_max=0;h_ar_int=0;domain = Get_Domain(7); // get the domain selected, put the liquid domain id insidetf= Lookup_Thread(domain, liquid_inter_id1); /* look up the face thread of the domainliquid_inter_id1 which is the liquid vapor interface */begin_f_loop (f, tf){c=F_C0(f,tf); // macros to identify adjacent facest=F_C0_THREAD(f,tf); // macros to identify adjacent faces threadT=F_T(f,tf); //get the temperature at the faceF_AREA(A,f,tf); // can be used to return the real face area vectorar=NV_MAG(A); // get the areap_l_sat=ps*exp((1/Ts-1/T)*hfg*M_bar/R_bar) ;temp2 = .03*sqrt(M_bar/(2*3.1415*R_bar))*(p_l_sat/sqrt(T) - ps/sqrt(Ts)); /*evap mass flux from the face */qd = temp2*ar*hfg;F_UDMI(f,tf,1)= temp2;S=qd/C_VOLUME(c,t); /*S is like energy source term*/if (S/hfg > m_max){m_max=S/hfg; /*highest mass source term for any cell*/}C_UDMI(c, t, 0) = S; // store or access the value of mass sourceC_UDMI(c, t, 1) = qd/(hfg*ar);F_UDMI(f,tf,2) = temp2*hfg/(T-298);C_UDMI(c,t,2) = temp2*hfg/(T-298);h_ar_int = h_ar_int + F_UDMI(f,tf,2)*ar;m_sum=m_sum+qd/hfg; /*total mass evaporated in Kg/s*/ar_sum=ar_sum+ar;count=count+1;}end_f_loop(f,tf)h_avg = h_ar_int/ar_sum;Message ("Total area of interface: %g\n", ar_sum);Message ("Total mass evaporated (kg/s): %g\n", m_sum);Message ("h integral on interface: %g\n", h_ar_int);Message ("h Average on interface: %g\n", h_avg);Message ("Total faces on the interface: %g\n", count);Message("Highest mass source term for any cell: %g\n", m_max); }DEFINE_SOURCE(Mass_liquid, c, t, dS, eqn){Thread *c_thread;face_t f;Thread *tf;int n;real S=0;//methanolreal hfg=2270e3;//water// real hfg = 2270e3;real ar;int liquid_id=7; /*liquid zone 's thread ID*/int liquid_inter_id1=12; // the interface of the domain/ liquid vapor interfacec_face_loop(c, t, n){f = C_FACE(c,t,n); // the face of the liquidtf = C_FACE_THREAD(c,t,n); // the face thread of the liquid/* looping through the face */if(THREAD_ID(tf)==liquid_inter_id1 ){S=-1*C_UDMI(c,t,0)/hfg; // store or access the value of mass source}}return S;}DEFINE_PROFILE(h_interface, thread, position){face_t f;real T_room=298;real T; /*wall temperature*/real dT;/*dT=T-T_room*/real k=0.68;real Nu,h;real hfg=2270e3;begin_f_loop (f, thread){T=F_T(f,thread);dT=fabs(T-T_room);h = F_UDMI(f, thread, 1)*hfg/dT;F_PROFILE(f,thread,position)=h;}end_f_loop (f, thread)Message("dT: %g\n",dT);Message("T :%g\n", T);Message("h :%g\n", h);} -
January 24, 2023 at 12:03 pm
Rob
Ansys EmployeeI'm not going to debug the code, but common issues include data being used that's not available and insufficient UDMs being assigned in Fluent (you do this manually).
As a more general comment, use indents to make blocks easier to read and be careful when assigning number types:
real whatever = 0 ;
isn't great,
real whatever = 0.0 ;
is more appropriate.
-
January 25, 2023 at 2:27 pm
kds_ansys
SubscriberThank you Rob for the reply. I have assigned UDM manually in Fluent. To make sure I wouldn't assign a small UDM number, I assigned a big number (100). However, I am still seeing the same error.
-
-
January 25, 2023 at 3:50 pm
Rob
Ansys EmployeeOK. Break the code down. If you don't use the source & profile what happens? Note, some single/few letter variables can clash with Fluent's built in functions: it's always best to use more descriptive variables. 100 UDMs may be a little excessive, I don't think it'll cause a problem but may result in data files that are a lot bigger than they need to be.
-
January 26, 2023 at 1:39 am
kds_ansys
SubscriberThanks Rob. It is actually working now. I divided the file into two rather than one, and it worked.
-
-
- You must be logged in to reply to this topic.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Suppress Fluent to open with GUI while performing in journal file
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Difference between K-epsilon and K-omega Turbulence Model
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- error in cfd post
-
2508
-
2064
-
1277
-
1088
-
456
© 2023 Copyright ANSYS, Inc. All rights reserved.