A new page

From CAELinuxWiki
Revision as of 03:18, 17 August 2010 by JMB (Talk | contribs) (Initial draft)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Topics under construction

Creating Mesh Groups Using a TUI

Why use a TUI?

Salome node and element grouping methods using the GUI (Graphical User Interface) are good but inadequate for many situations. Here we will show some rapid ways to group nodes or elements using Python scripts (TUI - Text User Interface) that are much faster (10 times or more) and more flexible compared to using the GUI methods. In fact there are situations where a GUI method has failed for medium to large sized meshes because Salome goes into a severe disk thrashing mode resulting in a locked up PC, to be relieved only by a reboot! In such cases learning to use the TUI method can be the difference between going to bed and hoping the grouping will be done along with the sun rising, or waiting for a few minutes for the TUI script to do its work. The difference is that significant, as experienced by the author.

Grouping nodes on a planar face:

In a part it is easier to define mesh groups by planes than by faces (imported from geompy) if the nodes (or elements) you want to group lie on defined planes. Create a plane ('TopPl') and add it to the study using geompy.addToStudy.  Then create a group by finding the nodes that lay on this plane. For this one can use the SMESH.Filter.Criterion function. In order to understand how this function works we need to know its parameters which are listed below: To demonstrate creating groups using a TUI in action, let us import a simple quadrangle meshed cube (100 mm3) and select all the elements belonging to the XY plane that is at z=100 mm using the following Python script. The process of creating this meshed cube is left to the reader.

import salome,geompy,smesh, SMESH
([Box], status) = smesh.CreateMeshesFromMED('/home/.../Box.med')
PT = geompy.MakeVertex(0, 0, 100)
Z_Axis = geompy.MakeVectorDXDYDZ(0, 0, 1)
SelectionPlane = geompy.MakePlane(PT, Z_Axis, 2000)
# Get all Elements touching the plane at Z= 100
aCriterion = SMESH.Filter.Criterion(20,32,0,'SelectionPlane',,32,32,1e-06,SMESH.VOLUME,-1)

If you want to select all the elements belonging to a sphere of radius 40 mm the additional lines below should do it:

Ball = geompy.MakeSphereR(40)
aCriterion = SMESH.Filter.Criterion(20,32,0,'Ball',,32,32,1e-06,SMESH.VOLUME,-1)

Logical filter 'AND'

Next we have the relevant portion of a python script that uses the logical 'AND' operation in the filter, using both the plane and sphere s selection criteria:

aFilterManager = smesh.CreateFilterManager()
Filter = aFilterManager.CreateFilter()
aCriteria = []
aCriterion = SMESH.Filter.Criterion(20,32,0,'SelectionPlane','SelectionPlane',32,30,1e-07,SMESH.VOLUME,-1)
LyingOnSelectionPlane = aFilterManager.CreateLyingOnGeom()
aCriterion = SMESH.Filter.Criterion(20,32,0,'Ball','Ball',32,32,1e-07,SMESH.VOLUME,-1)
LyingOnBall = aFilterManager.CreateLyingOnGeom()
LogicalAND = aFilterManager.CreateLogicalAND()

The Group

A display of the resulting group 'andGRP' is shown here LogicalAND.png


This page was made possible by the help and advice of several individuals on the Salome Forum in particular: Christophe BOURCIER, Pete HALVERSON and Kees WOUTERS. If I have missed mentioning somebody whose name should be added, please let me know or edit this section since it is a Wiki that anybody can add to, or correct. A new page