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

Any Differences in Parallel UDF going from 2D to 3D?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By blackmask

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 8, 2013, 08:57
Default Any Differences in Parallel UDF going from 2D to 3D?
  #1
Member
 
Christopher Hershey
Join Date: Feb 2012
Location: East Lansing, Michigan
Posts: 41
Rep Power: 14
Hershey is on a distinguished road
I have currently been working on my 2D simulations and my parallel UDF work quite well. Are there any compiler directives that need to be included when working in 3D?

I am only using two DEFINE_PROPERTY UDFs and one DEFINE_ADJUST UDF.

Thank you.
Hershey is offline   Reply With Quote

Old   July 8, 2013, 22:30
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
There would be differences between 2D and 3D simulations, e.g., the area for 2d axisymmetric and 3d might differ. But as far as I am concerned, there is no parallel-specific difference.
blackmask is offline   Reply With Quote

Old   July 8, 2013, 22:35
Default
  #3
Member
 
Christopher Hershey
Join Date: Feb 2012
Location: East Lansing, Michigan
Posts: 41
Rep Power: 14
Hershey is on a distinguished road
Thank you. Yes, my UDF are not specific to the actual dimension of the problem, just the boundary threads.

I seem to recall seeing a compiler directive #if RP_3D at some point and was not sure what it would be for. I guess your statement in dimensional dependent UDFs might explain its use.
Hershey is offline   Reply With Quote

Old   July 14, 2013, 12:39
Default
  #4
New Member
 
kornetka's Avatar
 
Join Date: Jun 2013
Posts: 15
Rep Power: 13
kornetka is on a distinguished road
Hi
I have problem with different results for UDF computed in serial and parallel modes. I use parallel mode in order to utilize multicore processor on a single machine, if it makes any difference.
Attached mesh picture is 2D section of the middle plane of the canal - the case is 3D. Two other pictures presents distribution of the same UDM quantity in this middle plane. Both serial and parallel cases were computed with identical starting conditions, compiled UDF file is also exactly the same.
I have no idea why it is happening and how to deal with it. Can somebody explain it? Should I add some more information? Thanks in advance.
Regards,
kornetka
Attached Images
File Type: png Mesh.png (93.9 KB, 10 views)
File Type: png Serial.png (24.1 KB, 17 views)
File Type: png Parallel.png (30.3 KB, 13 views)
kornetka is offline   Reply With Quote

Old   July 14, 2013, 14:46
Default
  #5
Member
 
Christopher Hershey
Join Date: Feb 2012
Location: East Lansing, Michigan
Posts: 41
Rep Power: 14
Hershey is on a distinguished road
Quote:
Originally Posted by kornetka View Post
Hi
I have problem with different results for UDF computed in serial and parallel modes. I use parallel mode in order to utilize multicore processor on a single machine, if it makes any difference.
Attached mesh picture is 2D section of the middle plane of the canal - the case is 3D. Two other pictures presents distribution of the same UDM quantity in this middle plane. Both serial and parallel cases were computed with identical starting conditions, compiled UDF file is also exactly the same.
I have no idea why it is happening and how to deal with it. Can somebody explain it? Should I add some more information? Thanks in advance.
Regards,
kornetka
You may want to post your UDF to the thread. The problem may be that you are not properly passing information between the cores if you are saying that the UDF is identical in parallel as it is in serial.

I use a UDF that does the same calculation in parallel, but it is parallelized to do so. Have you done this with your UDF?
Hershey is offline   Reply With Quote

Old   July 14, 2013, 15:34
Default
  #6
New Member
 
kornetka's Avatar
 
Join Date: Jun 2013
Posts: 15
Rep Power: 13
kornetka is on a distinguished road
Thank you for your answer. As a matter of fact, up to now I had no idea about any parallelization so my UDF is probably not adjusted at all.
I think I'll read some manual and try to fix it myself for now. I'll come back here if (when ) I face some more troubles.
Regards,
kornetka
kornetka is offline   Reply With Quote

Old   July 19, 2013, 05:07
Default
  #7
New Member
 
kornetka's Avatar
 
Join Date: Jun 2013
Posts: 15
Rep Power: 13
kornetka is on a distinguished road
Hi, unfortunately I'm back.
I've read the part of the UDF manual about parallelization, but I wasn't able to locate solution to my problem. As you can see, my UDF loops over a cell fluid cell thread and inside every cell does a loop over all faces. In the face loop it is supposed to take values from the adjacent cells (dudux1, ...) and perform simple operation (SRT1, Sface - still inside the face loop). The result of the face loop is tensor DS, but it's broken - the distribution of DS[0][0] is attached to my previous post, other elements of the DS tensor have the same problem.
I suppose the fishy part is the taking values from the adjacent cells? As stated earlier, due to the type of the tasks done by this code I'm not able see the problem in the parallelization itself, though the problem clearly exists. What am I overlooking? Or could it be some problem with the hardwawre/firewall/etc?
Regards, kornetka

Code:
DEFINE_ADJUST(adj_turb_var, domain) 
{
    int ii,jj,kk,n;
    real dudx,dudy,dudz,dvdx,dvdy,dvdz,dwdx,dwdy,dwdz;    
    real dudx1,dudy1,dudz1,dvdx1,dvdy1,dvdz1,dwdx1,dwdy1,dwdz1;

    real SRT[3][3], SRT1[3][3], Sface[3][3];
    real DS[3][3];


    #if !RP_Host
    face_t f=-1;
    cell_t c,c1=-1;
    Thread *t,*t1=NULL,*tf=NULL;

/*    ID=2 is fluid zone    */
    t = Lookup_Thread(domain, 2);


    thread_loop_c (t, domain) 
        begin_c_loop(c,t)
        {
/*    Strain rate tensor in cell centre    */
            dudx = C_U_G(c,t)[0]; 
            dudy = C_U_G(c,t)[1];
            dudz = C_U_G(c,t)[2];
            dvdx = C_V_G(c,t)[0];
            dvdy = C_V_G(c,t)[1];
            dvdz = C_V_G(c,t)[2];
            dwdx = C_W_G(c,t)[0];
            dwdy = C_W_G(c,t)[1];
            dwdz = C_W_G(c,t)[2];

            SRT[0][0] = 0.5*(dudx + dudx);
            SRT[0][1] = 0.5*(dudy + dvdx);
            SRT[0][2] = 0.5*(dudz + dwdx);

            SRT[1][0] = 0.5*(dvdx + dudy);
            SRT[1][1] = 0.5*(dvdy + dvdy); 
            SRT[1][2] = 0.5*(dvdz + dwdy);

            SRT[2][0] = 0.5*(dwdx + dudz);
            SRT[2][1] = 0.5*(dwdy + dvdz);
            SRT[2][2] = 0.5*(dwdz + dwdz);

            c_face_loop(c,t,n)
            {
                f = C_FACE(c,t,n);
                tf = C_FACE_THREAD(c,t,n);

/*    Strain rate tensor in adjacent cell, if it exists    */
                if PRINCIPAL_FACE_P(f,tf)
                {
                    if (!BOUNDARY_FACE_THREAD_P(tf))
                    {
/* Get cell on other side of face */
                        c1 = F_C1(f,tf); 
                        t1 = F_C1_THREAD(f,tf);

                        dudx1 = C_U_G(c1,t1)[0];
                        dudy1 = C_U_G(c1,t1)[1];
                        dudz1 = C_U_G(c1,t1)[2];
                        dvdx1 = C_V_G(c1,t1)[0];
                        dvdy1 = C_V_G(c1,t1)[1];
                        dvdz1 = C_V_G(c1,t1)[2];
                        dwdx1 = C_W_G(c1,t1)[0];
                        dwdy1 = C_W_G(c1,t1)[1];
                        dwdz1 = C_W_G(c1,t1)[2];
  
                        SRT1[0][0] = 0.5*(dudx1 + dudx1);
                        SRT1[0][1] = 0.5*(dudy1 + dvdx1);
                        SRT1[0][2] = 0.5*(dudz1 + dwdx1);

                        SRT1[1][0] = 0.5*(dvdx1 + dudy1);
                        SRT1[1][1] = 0.5*(dvdy1 + dvdy1); 
                        SRT1[1][2] = 0.5*(dvdz1 + dwdy1);

                        SRT1[2][0] = 0.5*(dwdx1 + dudz1);
                        SRT1[2][1] = 0.5*(dwdy1 + dvdz1);
                        SRT1[2][2] = 0.5*(dwdz1 + dwdz1);

/*    Strain rate tensor on the face    */
                        Sface[0][0] = 0.5*(SRT[0][0] + SRT1[0][0]);
                        Sface[0][1] = 0.5*(SRT[0][1] + SRT1[0][1]);
                        Sface[0][2] = 0.5*(SRT[0][2] + SRT1[0][2]);

                        Sface[1][0] = 0.5*(SRT[1][0] + SRT1[1][0]);
                        Sface[1][1] = 0.5*(SRT[1][1] + SRT1[1][1]);
                        Sface[1][2] = 0.5*(SRT[1][2] + SRT1[1][2]);

                        Sface[2][0] = 0.5*(SRT[2][0] + SRT1[2][0]);
                        Sface[2][1] = 0.5*(SRT[2][1] + SRT1[2][1]);
                        Sface[2][2] = 0.5*(SRT[2][2] + SRT1[2][2]);
                    }
                    else
                    {
                        Sface[0][0] = 0.0;
                        Sface[0][1] = 0.0;
                        Sface[0][2] = 0.0;

                        Sface[1][0] = 0.0;
                        Sface[1][1] = 0.0;
                        Sface[1][2] = 0.0;

                        Sface[2][0] = 0.0;
                        Sface[2][1] = 0.0;
                        Sface[2][2] = 0.0;
                    }

/*    Numerator for some other formula    */
                for(ii=0; ii<3; ii++)
                    for(jj=0; jj<3; jj++)
                    {
                        DS[ii][jj] += Sface[ii][jj];
                    }
                }    
            }    /*    Here ends the face loop    */
        }
        end_c_loop(c,t)
    #endif
}
kornetka is offline   Reply With Quote

Old   July 19, 2013, 05:26
Default
  #8
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Please explicitly initialize the DS array, otherwise the results of DS is undefined after the function call.
kornetka likes this.
blackmask is offline   Reply With Quote

Old   July 19, 2013, 13:32
Default
  #9
New Member
 
kornetka's Avatar
 
Join Date: Jun 2013
Posts: 15
Rep Power: 13
kornetka is on a distinguished road
Thank you. I added the initialization at the beggining of the cell loop and it works now.
Regards, kornetka
kornetka is offline   Reply With Quote

Reply


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
"Define_Profile" UDF for parallel solver Antoine Fluent UDF and Scheme Programming 9 February 29, 2016 07:09
Differences of parallel UDF for Fluent 6.3 and 13 didiean Fluent UDF and Scheme Programming 9 March 25, 2013 22:37
UDF Error with Parallel affter several step trantoan2008 Fluent UDF and Scheme Programming 0 January 7, 2013 08:33
Parallel UDF Error Andrew FLUENT 2 March 30, 2007 12:11
UDF in parallel version of fluent yobee FLUENT 2 August 5, 2004 01:36


All times are GMT -4. The time now is 18:20.