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

Get Cell by Coordinates in Fluent 15.0.0

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 3 Post By Manathan
  • 1 Post By jiangzili

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 9, 2015, 09:12
Default Get Cell by Coordinates in Fluent 15.0.0
  #1
New Member
 
Join Date: Feb 2015
Posts: 2
Rep Power: 0
haggis is on a distinguished road
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!
}
haggis is offline   Reply With Quote

Old   February 11, 2015, 04:30
Default
  #2
Member
 
Join Date: Nov 2014
Posts: 31
Rep Power: 11
maverick123 is on a distinguished road
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.
maverick123 is offline   Reply With Quote

Old   February 14, 2015, 10:14
Default Solution with DPM_Locate_Point
  #3
New Member
 
Join Date: Feb 2015
Posts: 2
Rep Power: 0
haggis is on a distinguished road
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();
haggis is offline   Reply With Quote

Old   February 16, 2015, 04:44
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Thank you Haggis for posting the solution you found.
It might help somebody in the future!
pakk is offline   Reply With Quote

Old   February 16, 2015, 09:52
Default
  #5
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 12
upeksa is on a distinguished road
Quote:
Originally Posted by haggis View Post
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.
upeksa is offline   Reply With Quote

Old   April 8, 2015, 07:39
Default
  #6
New Member
 
Join Date: Apr 2015
Posts: 28
Rep Power: 11
Manathan is on a distinguished road
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();
wond, daire6 and by1704116 like this.
Manathan is offline   Reply With Quote

Old   June 23, 2019, 23:02
Smile
  #7
New Member
 
alvin
Join Date: Aug 2018
Location: HONGKONG
Posts: 5
Rep Power: 7
jiangzili is on a distinguished road
Quote:
Originally Posted by haggis View Post
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
jie12345 likes this.
jiangzili is offline   Reply With Quote

Reply

Tags
cell, coordinates, point, search


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
UDF: Given coordinates, How to identify the cell? Zhang Fluent UDF and Scheme Programming 26 August 15, 2022 05:54
working in cylindrical coordinates in fluent Randheer Yadav FLUENT 2 January 18, 2015 16:25
Two dimensional simulation of a PEMFC in Fluent fuel cell module A CFD free user FLUENT 0 October 17, 2014 06:59
[Workbench] Creation of Cell Zones for processing in FLUENT kailingkk ANSYS Meshing & Geometry 0 October 5, 2013 05:09
?? How to get cell center coordinates? erica FLUENT 0 May 11, 2005 22:02


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