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

Error while using C_CENTROID

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 8, 2022, 06:20
Default Error while using C_CENTROID
  #1
Member
 
Chris
Join Date: Dec 2020
Posts: 45
Rep Power: 5
Pyrokrates is on a distinguished road
Hey,


I´m trying to order my cells inside each thread by coordinates. Therefore I have

Code:
cell_t cIDs_t0[50], cIDs_t1[50]; // Cell ID arrays of each thread
 cell_t *cIDs[Nt] = {cIDs_t0, cIDs_t1}; // Pointer to all cell IDs of all threads
which means, that I can access the cell IDs for each cell by cIDs[thread][cell].

These arrays contain the IDs in a sorted order (e.g. 0,5,4,3,2,1,6,7,...).

Now I have a problem using C_CENTROID function:

Code:
const int Nt = 2; // Number of threads
int tIDs[Nt] = {6, 7}; // Thread IDs
int Nct[Nt] = {50, 50}; // Number of cells in each thread


cell_t c;
Thread *t;
Domain *d = Get_Domain(1);


for(int i=0; i<Nt; i++) // Loop over all threads
{
    t = Lookup_Thread(d,tIDs[i]);

    for(int j=0; j<Nct[i]; j++)
    {
        //begin_c_loop(c,t)
        //{
        //    if(c == j)
        //    {
        C_CENTROID(pt,cIDs[i][j],t);
        //        Message("%d %d %g %g %g\n",t,cIDs[i][j],pt[0],pt[1],pt[2]);
        //    }
        //}
        //end_c_loop(c,t)  
    }
}

The problem is, if I use my function like this, the program crashes with segmentation fault error but if I use the commented out lines with the c_loop and if statement (if statement is only for a reduced message output, also works without the if), than the program works and give me my expected output. Confusing for me is that my C_CENTROID and my message lines do not contain c in any case.

Does anybody know, whats the problem here? The code is inside a DEFINE_ON_LOADING function.

Here is my error file:

Code:
Node 999999 Fatal signal raised sig = Segmentation fault
 b0fec6b0 CX_Primitive_Error
 7f67bd50 seh_filter_exe
 b108d290 logical_right_shift
 6485ec50 _C_specific_handler
 81ec1ee0 _chkstk
 81e8a740 RtlRaiseException
 81ec0c40 KiUserExceptionDispatcher
 74e90000 Ordinal0
 b06214b0 Open_UDF_Library
 af65e330 cx_strdup
 b1078840 eval
 b1078840 eval
 b1078840 eval
 b1078840 eval
 b1079ea0 set_cc
 b107a650 eval_errprotect
 b1078840 eval
 b1078840 eval
 b1078840 eval
 b1078840 eval
 b1079ea0 set_cc
 b107a650 eval_errprotect
 b0fed5c0 CX_Interpret_String
 af7288d0 rpgetvar_errprotect
 b108d290 logical_right_shift
 81b97c10 BaseThreadInitThunk
 81e8d700 RtlUserThreadStart

Error [node 999999] [time 6/8/22 11:8:48] Abnormal Exit!
Thanks in advance


Chris
Pyrokrates is offline   Reply With Quote

Old   June 9, 2022, 07:17
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Confusing for me is that my C_CENTROID and my message lines do not contain c in any case.
this line represents c (cell ID) which you are using in C_Centroid
Code:
cell_t *cIDs[Nt] = {cIDs_t0, cIDs_t1}; // Pointer to all cell IDs of all threads
you code should work properly if you remove message macro
thread (t) is not integer, so you are not able to use %d to plot it
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
c_centroid, segmentation fault


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



All times are GMT -4. The time now is 04:54.