Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine certain point belongs to which element 1

Status
Not open for further replies.

wseedling

Electrical
Aug 10, 2005
8
In 2-D case, I got all the node coordinates and I also know the matrix n(i,e),where the value of n(i,e)is global node number, i is local node number, and e is the local node number. Given a point with coordinate (x,y).How to determine which element this point belongs to?
Thanks very much!
 
Replies continue below

Recommended for you

Do you mean, which element ist nearest to the given xyz coordinates?
 
i'm sorry (wait a minute, no i'm not) ...

WTF ... an element joins two nodes, it's basic. knowing where the nodes are (their co-ordinates) allows you to know where the elements are ...


???
 
I mean given a coodinate (x,y),how to determine the element number e so that (x,y) is inside this element.

And a mistake in my quesion post above. e should denote the element number,not the local node number. thx again.
 
well that does make a little more sense ...
but this sounds much like a school problem (no?)

your matrix has rows that are your nodes, and columns that are your elements; so that a node can appear on multiple elements, but each element (column) should only have two entries).

a dumm way (which i'd probably do myself) would be the plot out the connectivity and then see where your point lies. a more methodical approach would be to determine the equation of each of the elements (from their two nodes), and then you can calculate which element the point is on (which eaquation is satified by the point).
 
These question is interesting.

Here my suggestion:

nsel,all
local,100,1, x, y, z ! cylidrical coordinate sistem at
! your coordinates
etab, ecent, cent, x ! element table whith element centroids

esort, etab, ecent, 1 ! ascending sort of element table

*get, elemno, sort, 0, imin ! get the element no. whith the
! smallest distance to x, y, z

please, tell me if it works!

Alex
 
You must go before in /prep1, so:

/prep1
nsel,all
local,100,1, x, y, z
etab, ecent, cent, x
esort, etab, ecent, 1
*get, elemno, sort, 0, imin

Alex
 
Sorry, I meant /post1:

/post1
nsel,all
local,100,1, x, y, z
etab, ecent, cent, x
esort, etab, ecent, 1
*get, elemno, sort, 0, imin

Alex
 
mihaiupb - I think you're assuming that the poster is using ANSYS, but I'm not sure this is the case. Hence...

wseedling - which software are you using? We can't give you any information unless you tell us more details.




------------
See faq569-1083 for details on how to make best use of Eng-Tips.com
 
I am sorry I did not present the question clearly. I Use matlab to generate the codes.I am doing 2 dimensional case and the basic element is triangle.what rb1957 talked about is one dimensional case. using the same idea proposed by rb1957,we can determine which element the point belongs to.(for example, calculate the area of the three triangles formed by the lines connecting the certain point to three nodes in one element. If the area equal to the element triangle's area, it should be in this element ). But I have so many elements and so many points need to be determined, if using this method, it would be time consuming. So I just want to find a simpler way to solve it.
I try to understand the idea of mihaiupb, since I do not know ansys. Thanks for your kind help.
 
apologies if it's fussing, but you described the co-rodinates of the point as (x,y), not (x,y,z).

i think the same alogrithm still works, each element is defined by three nodes, there are three numbers in each column of your matrix. this defines a limited plane, which can be tested to see if the point in question is on that plane.
 
"this defines a limited plane, which can be tested to see if the point in question is on that plane."

I think the question was, how to do this.

This would get more complicated in 3D.
 
you can calculate the equation of a plane through three points ...

actually, test the distance of the arbitary point from each of the three nodes defining one of (each of) your elements. if this is greater than the distance between any pair of nodes defining the element, then it can't be on that element, this will create a short list of potential elements.

another check would be from the equation of the element (from the three corners) determine the normal (perpendicular to the plane), then the equation of the normal that passes thru the point (point, slope equation of a line), then point where this line pierces the plane, then the distance between these two points. if the distance is zero then the point is on the plane of the element, but it might be outside the element ...

but this is a school problem isn't it ? (i can't imagine anyone doing this in the real world) ... if it is real world, take your model into an FE code or an FE front end (like PATRAN, FEMAP), and it will plot the model for you; the rest is simple
 
My idea was to define a local cylindrical coordinate sistem at the (x,y) location. Then transform all the element centroid coordinates in this local coordinate sistem. That way, the centroid x coordinates are the element distances to the (x,y) point. Then sort these distances ascending. The element whith the first x-coordinate is the nearest element to (x,y). Very simple in ANSYS, a little bit more tricky in Matlab, but feasible...

regards
Alex
 
I found a build in function in matlab to solve this problem. Thank you for your kind help. I appreciate it.
 
Could you tell us, please, what the name of the function is?
Thanks!
Alex
 
I actually think this might be a bit simpler than you think. (Provided that I understand the question correctly.)

You have two nodes for a line or three for a plane. Use them to determine the equation for the line, or the plane. Any basic linear algebra book should give this if you dont know it.

Next is to check if the point belong to the element. For a 2d case, use one coordinate to compute the second and check if the point is on the line. (Or two to compute a third coordinate.)

I don't mean to be rude but what surprices me is not that you found something useful in mathlab, it's that you need mathlab for this.

Regards

Thomas
 
sorry for the ambiguity in my statement.
You can see from my privious post, I know how to solve this using the method you gave, but since too many elements and too many points need to be determined,this is a little time consuming. I want to find a simpler way to do it.

Anyway, thank all for the discussion and help.
 
FYI: Pick two nodes of the element, and find the equation for the line between them. Check if the point to be tested is above or below that line, and check the third node of the element for the same thing. Do this for all three sides of the element. If the point in question is on the same side of the three lines as the third node in each case, then it is in the element. I believe if you had a spreadsheet with the node coordinates, you could automate this rather handily.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor