Hi Everyone,
I wish to obtain the surface normal vector at a given coordinate (preferably at a given node) using python script. I tried using the following syntax but gives error. Could someone please elaborate by giving a small example. I believe the ‘surface’ object is creating trouble.
Moreover, in the above syntax, how may decimal places do I need to include while passing the coordinates ?
Secondly, how to know if the normal is the outward normal or inward normal for a given curved surface ? I am particularly interested in the outward vector only.
Thirdly, is there a function that simply return the surface normal vector at a node id irrespective of the surface to which the node belongs ?
You have to have a Surface object to work on first. You can do that with the surface method. It takes the id of an existing surface. For example,
s = cubit.surface(25)
There is no node object. You can get the nodal coordinates with
coord = cubit.get_nodal_coordinates(95)
where 95 would be the node id.
Combining the two you can get the normal at the location on the surface s.
normal = s.normal_at(coord)
All floating point values in CubitInterface are double precision. The return value in the variable normal would look like (-0.9665517094956546, 0.2393232310814618, 0.0922072878668329).
The input values of functions that take floating point numbers are always converted into double precision values. In the case of the normal_at method, if the input is [0,0,0] that will be converted to double precision zeros prior to the computation. The number of decimal places will affect the value of the normal slightly especially in a complex spline surface. You need to decide the level of accuracy needed.
The surface orientation is a function of the surface. If the surface is part of a volume and the surface is not merged, the orientation will always be outward. If the surface is merged (shared between two volumes) this becomes a little more difficult. Let me know if that is a problem.
You can visually display the normal of any surface with the draw surface normal command. For example, draw surface 18 normal length 1
The length is optional but it sometimes helps to see the normal arrow if draw it at a longer length.
There is no single method to return the surface at a node id. The surface normal is a property of the surface and you must give a location on the surface.