CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Get Cell by Coordinates in Fluent 15.0.0 (https://www.cfd-online.com/Forums/fluent-udf/148320-get-cell-coordinates-fluent-15-0-0-a.html)

haggis February 9, 2015 09:12

Get Cell by Coordinates in Fluent 15.0.0
 
Hi Everybody,
I'm working with Fluent 15.0.0 and need to find the cell of the domain that contains a certain point (specified by its coordinates).
My approaches so far:
  • "SV_locate_point" of the "dpm.h": always gives me "Received signal SIGSEGV". Does that happen when the point is outside of the domain? Is there a way to check if the given point is inside the domain? What does the returned "int" stand for?
  • "CX_Find_Cell_With_Point" of the "cxndsearch.h": runs without any messages but when I try to access the cell then I get the same failure as mentioned above. Does anybody know the meanings of the parameters (for "CX_Start_ND_Point_Search" as well)?
Am I doing something wrong or does anyone know another solution? Any help is much appreciated!

My Code:

#include "dpm.h"
#include "cxndsearch.h"

CX_Cell_Id *cx_cell;
double x[ND_ND];
int i;
ND_Search *search;
for (i = 0; i < ND_ND; i++)
{
x[i] = 0.0;
}

Message("sv_locat_point: %d\n", SV_locate_point(x, cx_cell)); //fails!

search = CX_Start_ND_Point_Search(search, 1, 0);
cx_cell = CX_Find_Cell_With_Point(search, x, 0);
search = CX_End_ND_Point_Search(search);
if (NULL != cx_cell)
{
Message("check\n");
Message("cx_find_cell id: %d\n", RP_CELL(cx_cell)); //fails!
}

maverick123 February 11, 2015 04:30

Hi,

Could you please explain a bit more what exactly you want to do? As per mesh terminology fluent has, information about cells,their faces,centroids are accessible but I am not sure about point in cell.

haggis February 14, 2015 10:14

Solution with DPM_Locate_Point
 
Hi,
if finally found a solution for the problem using DPM_Locate_Point. As apparently nobody knows how to use it I'm going to answer my own question in case someone finds it interesting.

#include "udf.h"

CX_Cell_Id cx_cell;
double x[ND_ND], A[ND_ND], center[ND_ND];
Thread *ft;
face_t f;
cell_t c;
Thread *ct;
domain = Get_Domain(1);
DPM_Init_Oct_Tree_Search();
//for more than one point start the loop here
for (i = 0; i < ND_ND; i++)
{
x[i] = 0.0;
}
cx_cell.ct.c = 0;
cx_cell.ct.t = NULL;
DPM_Locate_Point(x,&cx_cell,0.0,0);
if (NNULLP(cx_cell.ct.t))
{
c = RP_CELL(&cx_cell);
ct = RP_THREAD(&cx_cell);
}
else
Message("point not in domain\n");
//stop point loop here
DPM_End_Oct_Tree_Search();

pakk February 16, 2015 04:44

Thank you Haggis for posting the solution you found.
It might help somebody in the future! :)

upeksa February 16, 2015 09:52

Quote:

Originally Posted by haggis (Post 531843)
Hi,
if finally found a solution for the problem using DPM_Locate_Point. As apparently nobody knows how to use it I'm going to answer my own question in case someone finds it interesting.

#include "udf.h"

CX_Cell_Id cx_cell;
double x[ND_ND], A[ND_ND], center[ND_ND];
Thread *ft;
face_t f;
cell_t c;
Thread *ct;
domain = Get_Domain(1);
DPM_Init_Oct_Tree_Search();
//for more than one point start the loop here
for (i = 0; i < ND_ND; i++)
{
x[i] = 0.0;
}
cx_cell.ct.c = 0;
cx_cell.ct.t = NULL;
DPM_Locate_Point(x,&cx_cell,0.0,0);
if (NNULLP(cx_cell.ct.t))
{
c = RP_CELL(&cx_cell);
ct = RP_THREAD(&cx_cell);
}
else
Message("point not in domain\n");
//stop point loop here
DPM_End_Oct_Tree_Search();


I think the code is still incomplete. Is that a DEFINE_ON_DEMAND macro or what kind of macro are you using?

Regards.

Manathan April 8, 2015 07:39

If you are using this code outside of the macro DEFINE_ON_DEMAND, you need to correct the Get_Domain(1) line, because it doesn't know where to apply it. I've done the following modifications and it worked in the DEFINE_DPM_BC() macro :


#include "udf.h"

CX_Cell_Id cx_cell;
double x[ND_ND], A[ND_ND], center[ND_ND];
Thread *ft;
face_t f;
cell_t c;
Thread *ct;

Domain *domain; //Domain is declared as a variable
domain = Get_Domain(1); //Returns fluid domain pointer

DPM_Init_Oct_Tree_Search();
//for more than one point start the loop here
for (i = 0; i < ND_ND; i++)
{
x[i] = 0.0;
}
cx_cell.ct.c = 0;
cx_cell.ct.t = NULL;
DPM_Locate_Point(x,&cx_cell,0.0,0);
if (NNULLP(cx_cell.ct.t))
{
c = RP_CELL(&cx_cell);
ct = RP_THREAD(&cx_cell);
}
else
Message("point not in domain\n");
//stop point loop here
DPM_End_Oct_Tree_Search();

jiangzili June 23, 2019 23:02

Quote:

Originally Posted by haggis (Post 531085)
Hi Everybody,
I'm working with Fluent 15.0.0 and need to find the cell of the domain that contains a certain point (specified by its coordinates).
My approaches so far:
  • "SV_locate_point" of the "dpm.h": always gives me "Received signal SIGSEGV". Does that happen when the point is outside of the domain? Is there a way to check if the given point is inside the domain? What does the returned "int" stand for?
  • "CX_Find_Cell_With_Point" of the "cxndsearch.h": runs without any messages but when I try to access the cell then I get the same failure as mentioned above. Does anybody know the meanings of the parameters (for "CX_Start_ND_Point_Search" as well)?
Am I doing something wrong or does anyone know another solution? Any help is much appreciated!

My Code:

#include "dpm.h"
#include "cxndsearch.h"

CX_Cell_Id *cx_cell;
double x[ND_ND];
int i;
ND_Search *search;
for (i = 0; i < ND_ND; i++)
{
x[i] = 0.0;
}

Message("sv_locat_point: %d\n", SV_locate_point(x, cx_cell)); //fails!

search = CX_Start_ND_Point_Search(search, 1, 0);
cx_cell = CX_Find_Cell_With_Point(search, x, 0);
search = CX_End_ND_Point_Search(search);
if (NULL != cx_cell)
{
Message("check\n");
Message("cx_find_cell id: %d\n", RP_CELL(cx_cell)); //fails!
}

hi,haggis,did you sovle this problem?I meet the problem also,can you give me some suggetions?thanku


All times are GMT -4. The time now is 16:41.