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

F_W(f,t) crashing inside c_face_loop

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2022, 11:26
Default F_W(f,t) crashing inside c_face_loop
  #1
New Member
 
Max
Join Date: Feb 2022
Posts: 8
Rep Power: 4
Maxxxx is on a distinguished road
Hi,


I would like to do some calculation for each cell depending on its faces. Therefore I tried to loop over all cell threads, followed by a cell loop and inside this I added the loop over all faces of a single cell. Up to this my code works fine... Also calculation of the face "IDs" and face threads. Calling functions like F_CENTROID also works quite good but if I wanna use F_W, I get some errors/segmentation faults and crashes...


Here is my code with



cc is the integer for the cells
fc is the integer for faces in cell system
ff is the integer for faces in face system
tc is the pointer to my cell threads
tf is the pointer to my face threads




Code:
DEFINE_EXECUTE_ON_LOADING(FaceLoop, libname)
{
    cell_t cc;
    face_t fc, ff;
    Thread *tc, *tf;
    Domain *d = Get_Domain(1);

    real xf[ND_ND];

    thread_loop_c(tc,d)
    {
        begin_c_loop(cc,tc)
        {
            c_face_loop(cc,tc,fc)
            {
                ff = C_FACE(cc,tc,fc);
                tf = C_FACE_THREAD(cc,tc,fc);

                if(BOUNDARY_FACE_THREAD_P(tf) != 0) // Face is part of boundary field
                {
                    F_CENTROID(xf,ff,tf);
                    //F_AREA(A,ff,tf); // Also works

                    Message("%d %d || %g %g %g || %g %g\n",ff,tf,xf[0],xf[1],xf[2],C_W(cc,tc),F_W(ff,tf));
                }
            }
        }
        end_c_loop(c,t)
    }
}
The problem I figured out is that F_W(ff,tf) crashes, while F_W(fc,tc) works but results in the incorrect results.
What I mean is, that for e.g. a simple example of 10 cells in Z-direction, 1 cell in X- and Y-direction, all boundary cells that surround my cell center should have the same value (when inlet velocity is given only in Z-direction). But the print out from message shows four different values for each face of a cell. Interesting is that over all cells, I can find each value of F_W four times, meaning there is something wrong with the order of printing/function calling.


Why do I need to use F_W as function of my cell counting system, and not as function of my face system (I expected that both should result in the same value, but one does not work and one is wrong)?


Thanks for any help in advance


Max
Maxxxx is offline   Reply With Quote

Old   June 14, 2022, 07:49
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
fc should be integer not face_t type, may be this could be the problem

if you are running in parallel message function could write 4 times in case you are using 4 cores
__________________
best regards


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

Old   June 14, 2022, 10:30
Default
  #3
New Member
 
Max
Join Date: Feb 2022
Posts: 8
Rep Power: 4
Maxxxx is on a distinguished road
Hello


and thank you for the answer. The simulation is done in serial so this can not be the problem. Also I have tried out to change fc to an integer which results in the same error. If I´m right, cell_t and face_t should be also integer just as a synonym when using fluent udf.
I also know that my output is not 100% correct since I print a pointer as an integer. This is just to see some output, removing the whole print line does not change my error.



Any other ideas?


Thanks


Max
Maxxxx is offline   Reply With Quote

Reply

Tags
c_face_loop, f_w


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
fixValues inside of a Mesh openFoam syntex Main CFD Forum 1 May 20, 2019 07:10
[snappyHexMesh] snappyHexMesh not deleting the inside cells Bdew8556 OpenFOAM Meshing & Mesh Conversion 9 May 14, 2019 11:53
regarding simulation of heat and mass transfer inside thermosyphon 1757003@kiit.ac.in ANSYS 1 May 14, 2019 03:06
Immersed Solid Momentum Sources inside function Martinw CFX 1 October 10, 2013 18:14
How to determine a point is inside a tetrahedral? G.P. Xia Main CFD Forum 16 January 12, 2000 12:15


All times are GMT -4. The time now is 17:01.