Check normal orientation and, eventually, reverse it if doesn't fit with the need
Good afternoon All,
I have a cilindrical body meshed in shell (in a component with a fixed name) and I need that the orientatio of the normal is in fixed direction (normals have to pint the central axis of the cylinder). This is in order to do other computation and apply certain load.
Is there a mode to check this and control in an automatic way?
It's a long time I'm struggling with this topic but I am not able to get out of it.
thanks a lot all for your help.
Regards,
Fabio
Answers
-
I couldn't think of a great way to do this but here are some tools/ideas that will hopefully help you come up with a solution you like.
First, the following is the help page for a command that adjusts the normals.
https://2022.help.altair.com/2022.1/hwdesktop/hwd/topics/reference/hm/_normalsadjust2.htm
The are several settings but you can use it to adjust to a specific element. So if you have 1 element that you know is aligned in the right direction you can use that to adjust the others.
Along those lines you can get the normal coordinates of a shell element with hm_getvalue like this:
set elemXnormal [hm_getvalue elem id=$elemID dataname=normalx]
set elemYnormal [hm_getvalue elem id=$elemID dataname=normaly]
set elemZnormal [hm_getvalue elem id=$elemID dataname=normalz]
You can also get the center using dataname=centerx, centery and centerz.
You can use a list of ids or a mark like so (though this might not me useful in your case):
set listXnormal [hm_getvalue elem user_ids=$elemList dataname=normalx]
set listYnormal [hm_getvalue elem mark=1 dataname=normaly]
Like I said this certainly isn't a solution but hopefully gives you some resources to find a good solution.
Happy coding!
0 -
Hi, FaForno
FYI
package require hwat
*createmarkpanel comps 1 "Please select comp"
*createmark solids 1 {*}[hm_getmark comps 1]
lassign [hm_getboundingbox solids 1 0 0 0] x_min y_min z_min x_max y_max z_max
set x_mid [expr {$x_min+$x_max}]
set y_mid [expr {$y_min+$y_max}]
set z_mid [expr {$z_min+$z_max}]
*createmark elems 1 "displayed"
*createmark elems 2 "by config" quad4 tria3
*markintersection elems 1 elems 2
set elem_list [hm_getmark elems 1]
foreach elem_id $elem_list {
set cx [hm_getvalue elems id=$elem_id dataname=centerx]
set cy [hm_getvalue elems id=$elem_id dataname=centery]
set cz [hm_getvalue elems id=$elem_id dataname=centerz]set nx [hm_getvalue elems id=$elem_id dataname=normalx]
set ny [hm_getvalue elems id=$elem_id dataname=normaly]
set nz [hm_getvalue elems id=$elem_id dataname=normalz]set dx [expr {$x_mid - $cx}]
set dy [expr {$y_mid - $cy}]
set dz [expr {$z_mid - $cz}]
set vector1 [::hwat::math::VectorNormalize [list $dx $dy $dz]]
set vector2 [list $nx $ny $nz]
set dotProduct [::hwat::math::VectorDotProduct $vector1 $vector2]
if {$dotProduct<0} {
*createmark elems 1 $elem_id
*normalsreverse elements 1 20
}
}
#end1 -
Dear All,
This doesn't work properly.
I am using shell elems on a cylindrical surface, as per the below image:
In order to do other computation I need of a fix direction and, specifically in the center of my cylinder (opposite to the one ion the image).
Thanks a lot for your help.
Regards,
Fabio
0 -
FaForno said:
Dear All,
This doesn't work properly.
I am using shell elems on a cylindrical surface, as per the below image:
In order to do other computation I need of a fix direction and, specifically in the center of my cylinder (opposite to the one ion the image).
Thanks a lot for your help.
Regards,
Fabio
Not sure I understand what you are asking but if you just need them in the other direction you can use *normalsreverse or if you are using Nagahashi's code above you can comment that command out or reverse it in the else part of that if command.
0 -
Hello.
I had an idea and I created a Tcl-macro.
This macro uses the API to calculate the moment of inertia and center of gravity, so it is necessary to set the Material (mass density) and Shell thickness (Thickness) before executing the macro.
When multiple Components are selected for execution, the normal direction is organized within each Component.
I have not tested it with various patterns, so there is a possibility of malfunction if the mesh shape is very complex.Regards,
K,Tsujimoto
1