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

SIGSEGV error when running UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By tricha122

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 24, 2020, 07:25
Default SIGSEGV error when running UDF
  #1
Member
 
Tyler Richardson
Join Date: Jun 2017
Posts: 30
Rep Power: 8
tricha122 is on a distinguished road
Hi,

I'm trying to calculate the heat transfer coefficient at the interface between my solid and fluid mesh (simple pipe, CHT)

The following code seems to fail every time with a SIGSEGV error. In fact, it wont even print out my messages within begin_f_loop. The output i get is "Begin F loop" (as i message out), and then the SIGSEGV error. I originally thought this was due to trying to loop along some solid faces, so i put a little if statement to omit any threads other than the one i am interested in.

I am totally lost. any help would be greatly appreciated.

Thanks!

Code:
#include "udf.h"
#include "sg.h"
#include "mem.h"


DEFINE_ON_DEMAND(on_demand_calc)
{

   /* Initialize face data */
   real kt, dTx, dTy, dTxRG, dTyRG, dTr, dTrRG;


	/* Initialize heat Transfer Coefficient*/
	real whtc, whtcRG;

   /* Initialize Temp, Q */

   real TWall, TBulk, QWall, QWallRG, TWadj;

   Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */
   Thread *t, *t0;
   cell_t c0;
   face_t f;

   d = Get_Domain(1);
   /* Loop over all boundary zones in the domain */
   thread_loop_f(t,d)
   {
   	Message ("Cell Thread %d \n", t);
      Message (THREAD_NAME(t));
      if (strcmp(THREAD_NAME(t),"pipe_fluid")!=0)
      {
         Message ("skipping thread \n");
         continue;
         /* break; */
      }
   	/* function that returns TRUE if Thread *t is a boundary face thread */
   	if (BOUNDARY_FACE_THREAD_P(t)) /* (WALL_THREAD_P(t))*/
      {
            Message ("Begin F loop \n");
            /* Loop over all faces */
            begin_f_loop(f,t)
            {
               if (f==0)
               {
                  Message ("Beginning face loop \n");
               }
               /* c0 and t0 identify the adjacent cell */
               c0 = F_C0(f, t);
               t0 = THREAD_T0(t);

      			/* Properties */
      			kt = C_K_L(c0,t0);
               Message ("kt = %g \n",kt);

               /* Cell Gradients */
               dTx = C_T_G(c0,t0)[0]; /* returns the x-component of the cell temperature gradient vector */
               dTy = C_T_G(c0,t0)[1]; /* returns the x-component of the cell temperature gradient vector */

               Message ("dTx = %g \n",dTx);
               Message ("dTy = %g \n",dTy);

               dTxRG = C_T_RG(c0,t0)[0]; /* returns the x-component of the cell temperature gradient vector */
               dTyRG = C_T_RG(c0,t0)[1]; /* returns the x-component of the cell temperature gradient vector */

               Message ("dTxRG = %g \n",dTxRG);
               Message ("dTyRG = %g \n",dTyRG);

               dTr = pow(pow(dTx,2)+pow(dTy,2),0.5);
               dTrRG = pow(pow(dTxRG,2)+pow(dTyRG,2),0.5);

               Message ("dTr = %g \n", dTr); 
               Message ("dTrRG = %g \n",dTrRG);

               QWall = -kt*dTr;
               QWallRG = -kt*dTrRG;

               Message ("Qwall = %g \n", QWall);
               Message ("QwallRG = %g \n",QWallRG);


      			/* Retrieve bulk temperature & Wall Adjacent Temperature */
      			TBulk = RP_Get_Real("ref/temperature");
               TWadj = F_T(f,t);

               Message ("TBulk = %g \n",TBulk); 
               Message ("TWadj = %g \n",TWadj);


               /* Calculate heat transfer coefficient */

               whtc = QWall/(TWadj-TBulk);
               whtcRG = QWallRG/(TWadj/TBulk);

               /* TWall = QWall/(-kt*dTr) + TWadj */

               Message ("Store data \n");

               C_UDMI(c0,t0,0) = whtc;
               F_UDMI(f,t,0) = whtc;

               C_UDMI(c0,t0,1) = QWall;
               F_UDMI(f,t,1) = QWall;

               C_UDMI(c0,t0,2) = QWallRG;
               F_UDMI(f,t,2) = QWallRG;

               C_UDMI(c0,t0,3) = TBulk;
               F_UDMI(f,t,3) = TBulk;

               C_UDMI(c0,t0,4) = TWadj;
               F_UDMI(f,t,4) = TWadj;

               C_UDMI(c0,t0,5) = whtcRG;
               F_UDMI(f,t,5) = whtcRG;


      		}
            end_f_loop(f,t)
      }
   }
}

Cell Thread 89742640
pipe_solid-non-overlappingskipping thread
Cell Thread 89581616
pipe_fluid-non-overlappingskipping thread
Cell Thread 89420592
pipe_interface-wall1-1-1skipping thread
Cell Thread 89903664
pipe_interface-wall1-1-1-shadowskipping thread
Cell Thread 86909472
interior-fluidskipping thread
Cell Thread 87070496
inletskipping thread
Cell Thread 87231520
outletskipping thread
Cell Thread 87392544
pipe_fluidBegin F loop
Cell Thread 88369344
interior-solidskipping thread
Cell Thread 88518224
wall-solidskipping thread
Cell Thread 88667104
pipe_solidskipping thread
Cell Thread 88828128
htfx_bcskipping thread

================================================== ============================

Node 0: Process 381551: Received signal SIGSEGV.

================================================== ============================
The fluent process could not be started.
tricha122 is offline   Reply With Quote

Old   November 24, 2020, 13:18
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Do you get the same if you replace

kt = C_K_L(c0,t0);

By

kt = 0.0;

?
pakk is offline   Reply With Quote

Old   November 26, 2020, 10:27
Default
  #3
Member
 
Tyler Richardson
Join Date: Jun 2017
Posts: 30
Rep Power: 8
tricha122 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Do you get the same if you replace

kt = C_K_L(c0,t0);

By

kt = 0.0;

?
Thanks for looking into this!

Turns out the problem was as follows:

1) I was retrieving gradient data (C_T_G) and that is only stored if you request it
2) I was storing calculations to UDMI_F() on an interface… you can only store face values to walls and boundaries….
pakk and Aj_45 like this.
tricha122 is offline   Reply With Quote

Reply

Tags
htc, sigsegv, 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
Error SIGSEGV for a simulation with UDF francescolab Fluent UDF and Scheme Programming 1 July 10, 2019 03:50
Problems running icoFoam: sigSegv with 4x mesh resolution SUBHANKAR OpenFOAM Running, Solving & CFD 4 December 29, 2016 22:53
Problem running fluent with udf on supercomputer(batch system) Sept24 Fluent UDF and Scheme Programming 3 October 15, 2015 12:50
UDF running three times each iteration marauder Fluent UDF and Scheme Programming 1 August 4, 2014 09:37
A Loop problem when running UDF in the batch mode Jun Geng FLUENT 3 July 16, 2008 08:34


All times are GMT -4. The time now is 21:19.