(844) 825-5971   Contact Us SimuTech Group’s YouTube Channel SimuTech Group on Facebook

Get Our Latest Tips & Tricks

Receive the latest updates to our popular Tips & Tricks articles and videos by subscribing to our Monthly Newsletter and Subscribe to the SimuTech Group YouTube channel channel.
For even more advanced ANSYS instruction, check out our consulting and training services. Or simply contact us to discuss any of your ANSYS needs.

Detecting Hybrid Meshing with an APDL Commands Object for a Body in ANSYS® Workbench Mechanical

ANSYS Hybrid Mesh 1

Figure 1: Hybrid Mesh with Structural SOLID186 Pyramid and SOLID187 Tetrahedron Elements in One Solid Volume

 

Introduction

ANSYS Mechanical (Workbench) supports the presence of APDL commands in the Outline so that user-programmed commands will act on a model at the Body, Connection, Solver or Postprocessing stage of an ANSYS job running from the ds.dat file generated by the Mechanical SOLVE command.

This article illustrates how to detect and act on the two element types found in a hybrid-meshed body such as can result with a Hex-Dominant meshing method, a Multizone meshing method or Inflation.

Hybrid Meshing

Workbench has meshing methods that create a hybrid mesh in selected bodies. A hybrid mesh could contain solid elements with a mix of hexahedral (brick shape with 6 quadrilateral faces), pyramid (four-sided base with four three-sided faces), and tetrahedral (four three-sided faces) elements. Mesh methods producing hybrid meshes include Hex-Dominant, Multizone with certain Details settings, and Inflation. The hexahedral elements share the same element type as the pyramid elements, while the tetrahedral elements get their own element type number, yet share the same MATID material number in a given body. A tetrahedral 10 node element derived from first principles use less storage than a 20-node brick degenerated to a 10-node tetrahedral shape, resulting in less model memory and storage use, plus faster solving, so the separate element type is appropriate.

APDL Commands Objects can be inserted at the Geometry body level to change material properties, attributes of elements in a part, KEYOPT settings, or to change the element type. APDL coding can detect whether any given part has hybrid meshing, and act accordingly on the two element types. Two examples are presented next.

Two Example APDL Commands Objects that Detect Hybrid Meshing

In the Workbench Mechanical Outline, desired required element changes can be introduced by a Commands Object at each body in the Geometry section. The following example looks for the presence of SOLID186 and SOLID187 elements in a body. Changes can be made according to whether the element types are discovered. Note the use of commented out lines with “xxxx”, “yyyy” and “zzzz”, which are not defined in this prototype example:


! Detect SOLID186
! Detect SOLID187
!
cm,dummyelem,elem                        ! All elements currently selected
esel,r,mat,,MATID                        ! Elements of material “MATID” only
! Act on any SOLID186 elements
esel,r,ename,,186
*GET,howmanyelem,ELEM,,COUNT             ! any 186 elements?
*if,howmanyelem,ne,0,then
   *GET,elemmin,ELEM,,NUM,MIN
   *GET,typeattr,ELEM,elemmin,ATTR,TYPE  ! what element type attribute was assigned
   ! et,typeattr,xxxx                    ! change element type if desired
   ! KEYOPT,typeattr,yyyy,zzzz           ! change KEYOPTS if desired
*endif
cmsel,s,dummyelem                        ! select the component again
esel,r,mat,,MATID                        ! Elements of material “MATID” only
! Act on any SOLID187 elements
esel,r,ename,,187
*GET,howmanyelem,ELEM,,COUNT             ! any 187 elements?
*if,howmanyelem,ne,0,then
   *GET,elemmin,ELEM,,NUM,MIN
   *GET,typeattr,ELEM,elemmin,ATTR,TYPE  ! what element type attribute was assigned
   ! et,typeattr,xxxx                    ! change element type if desired
   ! KEYOPT,typeattr,yyyy,zzzz           ! change KEYOPTS if desired
*endif
!
cmsel,s,dummyelem    ! recover original element choice
cmdele,dummyelem     ! delete component definition
!
! Make any material changes with MP and/or TB if appropriate using MATID
! MP,xxxx,MATID,xxxx
!


Note above that the MATID is shared by all of the elements in a body. 

The above APDL commands consider whether a body contains SOLID186 and/or SOLID187 elements. *GET commands can detect any of the attributes MAT, TYPE, REAL, ESYS, or SECN. Suitable commands can change these attributes as well as KEYOPT values.

Alternative commands can detect whether two more arbitrary element types have been meshed into a body. This could happen if hybrid meshing is used in a structural model, returning SOLID186 and SOLID187 elements with the same MATID, or with SOLID90 and SOLID87 elements in a thermal model, again sharing a MATID for that body. In the future, SOLID226 and SOLID227 multiphysics elements might be created when hybrid meshing is active.

Note that while there is a pyramid form for low-order 8-node hex thermal SOLID70 elements, low-order 8-node structural SOLID185 elements do not have a pyramid form, and so are not used in bodies with a hybrid mesh. (A SOLID285 3-D 4-Node Tetrahedral Structural Solid with Nodal Pressures might be considered in specialized nonlinear models. It is unusual and not generally recommended to use SOLID185 elements in tetrahedral form. There is no low-order pyramid for structure models.)

Here is example APDL coding that discovers the element names for two element types found in one body after hybrid meshing. Changes can be made according to the element types. If only one element type is discovered, the second possibility is skipped. This prototype example does not make changes:


cm,dummyelem,elem                           ! All elements currently selected
esel,r,mat,,MATID                           ! Elements of material “MATID” only
*GET,elemmin,ELEM,,NUM,MIN                  ! Lowest # currently selected element
*GET,typeattr,ELEM,elemmin,ATTR,TYPE        ! what element type attribute
! Element type name (e.g. 186 means SOLID186) for element type attribute number
*GET,elem_name,ETYP, typeattr,ATTR,ENAM     ! Number assigned to the attribute ENAM
!
! Use *IF on elem_name to make suitable desired changes to elements, for example,
! if elem_name is one of 186 or 187 change accordingly, given etype_num and elem_name
!    place commands here
!
! Select the second element type, if any
cmsel,s,dummyelem
esel,r,mat,,MATID
esel,u,ename,,elem_name
*GET,elemcount,ELEM,,COUNT                  ! any elements from hybrid meshing?
*if,elemcount,gt,0,then
   *GET,elemmin,ELEM,,NUM,MIN               ! Lowest # currently selected element
   *GET,typeattr,ELEM,elemmin,ATTR,TYPE     ! what element type attribute
   *GET,elem_name,ETYP, typeattr,ATTR,ENAM  ! Number assigned to the attribute ENAM
   ! Use *IF on elem_name to make suitable desired changes to elements
   ! e.g. if elem_name is 187 or 186 change accordingly, given etype_num and elem_name
   !    place commands here
*endif
!
cmsel,s,dummyelem    ! recover original element choice
cmdele,dummyelem     ! delete component definition
!
! Make any material changes with MP and/or TB if appropriate using MATID
! MP,xxxx,MATID,xxxx

 


Conclusions

Workbench supports APDL Commands Objects that act on bodies in the Geometry section. Some solid bodies may have been meshed with hybrid elements containing two element types that share the same MATID material number.

Statements in an APDL commands object can detect the presence of a second element type in a body. When the APDL commands act on a body, suitable changes to element attributes, KEYOPT values, or re-definition of the element type to one of the same topology (such as changing SOLID186 into SOLID226) could be performed. When hybrid meshing produces two element types in one body, APDL coding can be used to detect this, and programmed to change each of the two element types as appropriate. When general purpose APDL Commands Objects used on Bodies in Geometry are intended to modify KEYOPT settings, element attributes, or element types, they should be programmed to treat the possibility of hybrid meshing so that models behave as expected. This leaves analysts free to choose whichever meshing technique is desired without worrying about APDL Commands Object side effects.

This article has illustrated two techniques—one acts directly on SOLID186 and SOLID187 elements, while the other discovers the element names of the two elements types, leaving it to the user to program changes according to the element name that is discovered.