|
[Sponsors] |
Find_Cell_With_Point does not work well on complex geometries? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 7, 2022, 02:40 |
Find_Cell_With_Point does not work well on complex geometries?
|
#1 |
New Member
Join Date: Nov 2022
Posts: 10
Rep Power: 4 |
Hey all, I have a CSV file containing x,y,z points. I want to get those x,y,z points and then find the cell nearest to that point. I found that using Find_Cell_With_Point allows me to do that. Using that function on a simple geometry like a rectangle does not have any problems, but I'm having a lot of trouble when I use it on complex geometries. What could be the problem here? Here's my code:
Code:
#include <udf.h> #include <cxndsearch.h> #include <stdio.h> #include <stdlib.h> #include <string.h> static ND_Search *domain_table = NULL; DEFINE_ON_DEMAND(find_cells2) { cell_t c; Thread *t; CX_Cell_Id *cx_cell; int cell_ID; real cVolume; real P[3]; real P_Cell[3]; FILE *fp; char line[1024]; int rayID, side, prevID, nextID, surfID; double x,y,z; fp = fopen("udf_csv.csv","r"); if(fp == NULL){ printf("Trouble reading file\nAborting.."); fclose(fp); abort(); } domain_table = CX_Start_ND_Point_Search(domain_table,TRUE,-1); while(fgets(line,1024,fp)){ sscanf(line,"%d,%lg,%lg,%lg,%d,%d,%d,%d",&rayID,&x,&y,&z,&side,&prevID,&nextID,&surfID); P[0] = x; P[1] = y; P[2] = z; cx_cell = CX_Find_Cell_With_Point(domain_table,P,0.0); if(cx_cell){ c = RP_CELL(cx_cell); t = RP_THREAD(cx_cell); cell_ID = C_ID(c,t); C_CENTROID(P_Cell,c,t); cVolume = C_VOLUME(c,t); Message("\n %d %g \t %g \t %g \t %g",cell_ID,P_Cell[0],P_Cell[1],P_Cell[2],cVolume); }else{ Message("\nCannot find cell using point [%g,%g,%g]",P[0],P[1],P[2]); } } domain_table = CX_End_ND_Point_Search(domain_table); fclose(fp); } Code:
2510,-0.184337,6.45695,0.191743,1,2509,0,3 2517,-0.00135845,6.08666,0.25398,1,2516,0,5 2521,-0.207771,6.04,0.0328325,1,2520,0,5 2524,0.184953,6.626,0.0102348,1,2523,0,4 2527,0.250984,6.07845,0.00956254,1,2526,0,5 2531,0.0969752,6.626,0.212096,1,2530,0,4 2534,-0.211653,6.04,-0.0855774,1,2533,0,5 2537,0.0661434,6.04,0.179724,1,2536,0,5 2543,0.147094,6.04,-0.126483,1,2542,2544,5 2552,-0.00681696,6.07177,-0.13546,1,2551,0,3 2555,0.0201342,6.04,0.200304,1,2554,0,5 2559,0.188615,6.04,-0.0341838,1,2558,0,5 2565,0.00556855,6.07901,0.135919,1,2564,0,3 2568,-0.0382014,6.0825,0.134891,1,2567,0,3 Code:
Cannot find cell using point [-0.184337,6.45695,0.191743] 2907897 -0.00285511 6.08873 0.253857 1.19582e-08 2669898 -0.20529 6.04087 0.0322238 1.10349e-08 206464 0.184174 6.62675 0.0118884 1.24341e-08 2320551 0.250745 6.08027 0.00939368 1.30901e-08 213033 0.0964352 6.62675 0.213118 1.44972e-08 2455386 -0.211253 6.0408 -0.0856087 6.03395e-09 2481309 0.0666147 6.04097 0.180317 1.20944e-08 2484411 0.145721 6.0409 -0.127359 1.4037e-08 1817709 -0.00758865 6.0714 -0.134713 1.53618e-09 2618335 0.0231374 6.04087 0.201707 1.73295e-08 2482991 0.188002 6.041 -0.0346246 1.26253e-08 Cannot find cell using point [0.00556855,6.07901,0.135919] 1797769 -0.0381706 6.08214 0.133913 1.14033e-09 |
|
December 8, 2022, 02:25 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you've just said, that macro works fine on some geometries
probably, the problem is in your specific case actually, the reason, why are you reading coordinates of cells from file is not clear
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Tags |
find cell, udf and programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Salome] problem with work flow: freeCAD => Salome => cfMesh | mmohaqeqf | OpenFOAM Meshing & Mesh Conversion | 3 | February 22, 2023 05:00 |
MultiRegion SnappyHexMesh Workflow for complex geometries | Dicanic | Main CFD Forum | 3 | March 3, 2022 19:18 |
First CFD consulting Job for wind turbine - What would be a good cost for my work? | erickmartinez | Main CFD Forum | 0 | May 8, 2021 20:32 |
[ANSYS Meshing] Meshing complex geometries | Pavan07 | ANSYS Meshing & Geometry | 0 | March 19, 2020 05:18 |
Complex FFT for real data | Hisham | Main CFD Forum | 0 | November 12, 2011 15:53 |