пятница, 20 июля 2012 г.

CX_Find_Cell_With_Point and 3ddp (Fluent)

There is a function CX_Find_Cell_With_Point. It's not listed in official documentation but it works well when you need to find a cell which contains specified point. Otherwise one must use very slow dumb search or develop  some sofisticated search algorithms. But there is a glitch with its use. As it's undocumented, there is no guarantee that it even compiles.
`CX_Find_Cell_With_Point' does not work with double precision (3ddp) Fluent solver!
That's true for Fluent 6.2.16 on lnamd64 (at least). With 3ddp it always returns NULL.

And if you're here for example, here is a code:

#include "udf.h"
#include "surf.h"
#include "para.h"
 
void some_function()
{
    cell_t c;
    Thread *t;
    CX_Cell_Id cx_cell;
    CX_Cell_Id *cx_cell_ptr;
    real pt[3];
 
    CX_Start_ND_Point_Search(); /* call this before actual search */
                                /* perhaps it'll do some initializations */
    for (k = 0; k < 1000; k ++) {
        /* fill pt[3] with data */
        pt[0] = 0.0; pt[1] = 0.0; pt[2] = k / 1000.0;
 
        /* perform search */
        cx_cell_ptr = CX_Find_Cell_With_Point(pt);
        if (cx_cell_ptr) {   /* function can return NULL if no cell was found */
            cx_cell = *cx_cell_ptr;
            c = RP_CELL(&cx_cell);  /* get cell number */
            t = RP_THREAD(&cx_cell);  /* get cell thread */
 
            /* ... do your calculations ... */
 
        } else {
            /* no cell was found */
        }
 
    }
 
    /* It's a good practice to clean up */
    CX_End_ND_Point_Search();
}
 

Комментариев нет:

Отправить комментарий