Model.tetmesh#

Model.tetmesh(collection1, mode1, collection2, mode2, string_array, graphicsDB=0)#

A general single tetra mesh operation can involve a function block consisting of zero or more calls to Model.tetmesh_set_input() followed by one call to Model.tetmesh(). Model.tetmesh() can take up to two different entity input/selections and Model.tetmesh_set_input() supplies additional entity selections (up to four more) to Model.tetmesh().

The following discussion applies to the entire tetra mesh function block.

In the function argument list each couple collection{n}, mode{n} with \(n \in {1,2}\) specifies a set of entity input that either define a part of the boundary of the meshing volumes or the element size control boxes.

An entity input with empty collection{n} mode{n}=-1 is considered an inactive input. Inactive inputs are ignored inside the functions. However, for an inactive input, the collection{n} should containt a valid entity name. An input can be empty and still active. An empty active input with mode{n}=6 will be auto filled internally.

If there are inputs with mode{n}=2 or mode{n}=3, the resulting mesh is called a CFD mesh. Otherwise, it is called a non-CFD mesh.

Also, note that not all combinations of the couple values (collection{n}, mode{n}) are valid. The general rules for all active entity inputs and the internal handling of these inputs are as follows and all must be satisfied:

  • Must have at least one active input.

  • Up to 7 inputs can be used but, each active mode value can appear no more than once.

  • Modes 0, 1, 2, 3 and 6 are for boundary inputs of the meshing volumes. For these modes, input collection{n} with entity types as elements or components are boundary inputs by elements; inputs with entity type as solids or surfs are boundary inputs by geometries (surfaces or solids). All boundary inputs must be either all by elements or all by geometries (surfaces or solids).

    • For an input by elements with mode{n} 0, 2 and 3, all elements other than 2D elems are ignored.

    • For an input with mode{n}=1, both 1D (plotel) and 2D elems are acceptable. In this case, 1D elems specify the elem edges that must appear in the final mesh.

    • For an input with mode{n}=6, all elems other than 3D elems are ignored.

  • For inputs by geometries, all surfaces without a pre-existing mesh are treated as float regardless of the mode{n} of input. Internally, these surfaces are auto-meshed with the 2D meshing parameters passed in through the string_array argument.

  • There can be no more than one input collection{n} with entity type as solids. That is, if there is one solids input, all other boundary inputs must have collection{n} with entity type as surfaces. It is further required that all these surfaces selections are on the selected solids (other surfs are silently ignored).

  • For mode{n}=4, entity type in collection{n} must be components. The selected entities must be the specially constructed components for size control boxes (others are silently ignored).

  • For mode{n}=5, entity type in collection{n} must be nodes. The nodes that are too close to other anchor nodes or that are outside of the meshing volumes or too close to the boundary of the meshing volumes are ignored.

  • For an input with mode{n}=6, all boundary inputs must be by elements. All other boundary inputs are considered as 2D baffles (and 1D constraints). An empty input with mode{n}=6 will be auto filled internally by the inputs of baffles (modes 0, 1, 2 and 3), size control boxes (mode{n}=4) and anchor nodes (mode{n}=5). Otherwise, all entities with input modes 0-5 that fall outside of the 3D selection or too close to the boundary of the 3D selection are ignored.

  • If a single function has two active entity inputs, the collection{n} must be different.

  • Inputs with different modes are allowed to have overlapping selections. The overlaps are resolved inside the function. The general rule is that the input in an earlier function has the higher priority; while within a function the later input has the priority. If an input has entity type solids, it always has the lowest priority regardless its position in the input order.

Parameters:
  • collection1 (Collection) – The collection containing the entities. Valid entity types are nodes, elements, components, surfaces and solids.

  • mode1 (int) –

    -1 - Ignored (inactive input)

    0 - Float without boundary layer

    1 - Fixed without boundary layer

    2 - Float with boundary layer

    3 - Fixed with boundary layer

    4 - Size control boxes

    5 - Anchor nodes

    6 - 3D re-mesh

    7 - 3D re-mesh with free boundary swappable-float.

    8 - 3D re-mesh with free boundary remeshable-float.

    9 - Remeshable-float without BL

    10 - Remeshable-float with BL

    11 - Element input for fluid volume selection. Either touched (or normal pointed into) are fluid volumes.

    Note

    If one of the float inputs is set to remeshable by either a mode{n} listed above or by the “shell_remesh” parameter in the “pars:…” string, all float inputs are set to remeshable. Otherwise, all floats are swappable only except for the non-BL input that receives BL imprinting.

  • collection2 (Collection) – The collection containing the entities. Valid entity types are nodes, elements, components, surfaces and solids.

  • mode2 (int) –

    -1 - Ignored (inactive input)

    0 - Float without boundary layer

    1 - Fixed without boundary layer

    2 - Float with boundary layer

    3 - Fixed with boundary layer

    4 - Size control boxes

    5 - Anchor nodes

    6 - 3D re-mesh

    7 - 3D re-mesh with free boundary swappable-float.

    8 - 3D re-mesh with free boundary remeshable-float.

    9 - Remeshable-float without BL

    10 - Remeshable-float with BL

    11 - Element input for fluid volume selection. Either touched (or normal pointed into) are fluid volumes.

  • string_array (hwStringList) –

    The string array that contains the array of meshing parameters. Each argument can be either space or comma separated. There are 6 types of strings which can be passed, as indicated below. Different combinations of these strings can be passed, based on the specific meshing requirements.

    Options for checking the validity of the input mesh:

    "shchk: mode prox_tol angle_tol".

    At least one of the two entity inputs needs to be filled. The check functionality takes only elements or components as input and only shell elemements are considered. If only one input is filled, the check is a “self” check, that is, all elements causing interference are collected. If both inputs are non-empty, the check is a “mutual” check, that is, an interference pair is collected only if it involves both inputs. The message bar provides a brief view of what is detected. For example:

    32790 elems:x=34698 pairs, prx=168@0.001/min1.91e-7, angle=3@0.5, dups=0 on 0

    32790 elems - Input has 32790 shell elements

    x=34698 pairs - Found 34689 self-intersecting element pairs

    prx=168@0.001/min1.91e-7 - Found 168 proximiy element pairs for threshold distance 0.001 with the worst being 1.91e-7

    angle=3@0.5,min0.01 - Found 3 element pairs having dihedral angle < 0.5 degrees, with the worst being 0.01 degrees

    dups=45 on 10 - Found 45 duplicated shell element pairs involving a total of 10 shell elements

    • mode <value> - Tetra mesh options.

      Bit values are used and the value is calculated as (Bit0_Bit1 + 16*Bit4 + 32*Bit5). Valid Bit options are:

      Bit0_Bit1

      Volume analysis. Valid values are:

      0 - Reserved

      1 - Do per-volume check after analyzing volumes using inward-positive orientation (inside is positive). It is an error if the input does not form volumes. For proximity, proximities on the positive side are collected. For dihedral angle, as orientation is used, an angle “A” is distinct from “360-A” ( as opposed to without orientation value=3, “A” is equivalent to “360-A”).

      2 - Do not analyze volumes, but element normal is used. To have the orientation meaningful, user needs to adjust the input to a consistent normal before doing the check here (for orientation effect, see the per-volume check above).

      3 - Do not analyze volumes and do not use orientation . Two sides of each element are treated equally.

      Bit4

      Collection options. Valid values are:

      ^err_x_elems - Elements having self-intersections

      ^err_prx_elems - Elements having failing proximity (no self-intersection)

      ^err_agl_elems - Elements having failing dihedral angle

      Note

      Each component or set can only collect the same element once. That is, all pair info are lost.

      Valid values are:

      0 - Detected elements are duplicated in specially named components (red color)

      1 - Detected elements are pladed in specially named sets

      Bit5

      Group-by cluster options. Valid values are:

      0 - Do not further classify detections by cluster

      1 - Further classify detections by clusters. A cluster is a set of elements related by adjacency and interference pairing. With this option, each cluster has its own component or set having the name appended with _<cluster_id> (for example, ^err_x_elems_2.

    • prox_tol <value> - A threshold value for proximity detection. Input elements having a distance to other input elements less than this value are collected in comps or sets depending on mode. Two elems may have proximity only if they do not share an edge, and at least one is in the forward (or backward) cone of the other. The shape of the cone is defined internally.

      < 0.0 - Proximity detection is disabled

      = 0.0 - Detect only self-intersection

      > 0.0 - Detect both self-intersection and proximity

    • angle_tol <value> - A threshold value for dihedral angle detection. Input elements having a dihedral angle to other adjacent input elements less than this value are collected in components or sets depending on mode.

      < 0.0 - Angle detection is disabled.

    Tetra meshing parameters that control the tetra core part of the mesh

    This is required for all meshing types:

    "tet: tet_opts growth_rate uniform_layers max_size qt_ratio min_size"

    or

    "tet: tet_opts growth_rate uniform_layers max_size qt_ratio min_height"

    • tet_opts <value> - Tetra mesh options.

      Bit values are used and the value is calculated as (Bit0_Bit1_Bit2 + Bit5_Bit6_Bit7 + 256*Bit8 + 1024*Bit10). Valid Bit options are:

      Bit0_Bit1_Bit2

      Core tetra mesh and optimization method. Valid values are:

      0 - Unused.

      1 - Normal.

      2 - Optimize for performance.

      3 - Optimize for quality.

      4 - Generate boundary layer only. Valid only if there are boundary layer inputs.

      Bit5_Bit6_Bit7

      Quad transition settings. Used only if there are fixed quad inputs. Valid values are:

      0 - Keep quads as-is. Only valid for BL only mode.

      32 - Build a layer of 1 pyramid per quad transition.

      64 - Build a layer of 5 pyramids and 2 tetras per quad transition.

      96 - BL hexas are split into prisms for all layers.

      128 - BL elems are split into tetras for all layers.

      Bit8

      Elemements-to-geometry flag. Effective only for non-CFD meshes with inputs by geoms. For CFD mesh, the elems are always placed in fixed comps with special names. For all other cases, elements go to the current component. Valid values are:

      0 - Elements to current component.

      1 - Elements to geometry component.

      Bit10

      Fix midnodes flag. The method of optimizing the midnode of 2nd order tets that are on surfaces. Valid values are:

      0 - Surface midnodes are allowed to move to an optimized location.

      1 - Surface midnodes will be made fixed (no relocation).

    • growth_rate <value> - The tetra mesh elem size growth rate for the boundary (typical 1.2, range >1.0).

    • uniform_layers <value> - The number of tetra layers that are to have uniform elem sizes (typical 2.0, range >0).

    • max_size <value> - The limit on the max elem size. A value of 0.0 means no limit (typical 0.0).

    • qt_ratio <value> - Affect only the quad transition layer. This determines the layer height as a fraction of the local 2D element size (typical 0.8).

    • min_size <value> - The nominal lower bound for the element size. A value of 0.0 means not bounded (typical 0.0).

    • min_height <value> - The minimal element height. A value of 0.0 means not bounded (typical 0.0). If not specified, the function behaves as if this capability was not implemented.

    CFD boundary layer meshing parameters

    This is only required if one or more boundary selections are of mode{n}=2 or mode{n}=3 :

    "cfd: cfd_opts bl_thick0 bl_thicktotal bl_growthrate size_trans_flag"

    • cfd_opts <value> - Flags for smooth/native boundary layer meshes.

      Bit values are used and the value is calculated as (Bit0 + 2*Bit1 + Bit2_Bit3 + 32*Bit4 + 64*Bit5 + 128*Bit7 + 256*Bit8 + 1024*Bit10). Valid Bit options are:

      Bit0

      Split mode. Effective only for native boundary layers or when "size_trans_flag=1". Valid values are:

      0 - All 3D non-tetra elems are split into tetras.

      1 - Prism and pyramid elems in the boundary layer are not split into tetras.

      Bit1

      The main boundary layer mode. Valid values are:

      0 - Native boundary layer method is used.

      1 - Smooth boundary layer method is used.

      Bit2-Bit3

      Boundary layer total thickness mode. Effective only for smooth boundary layer method. Valid values are:

      0 - bl_thicktotal specifies the total boundary layer thickness.

      4 - bl_thicktotal specifies the total number of boundary layers.

      8 - bl_thicktotal specifies the ratio of the total boundary layer thickness over the average input element size.

      Bit4

      Non-boundary layer remesh mode. Effective only for smooth boundary layer method. Valid values are:

      0 - The float non-boundary layer inputs that intersect the boundary layer elems are morphed to accommodate the boundary layers.

      1 - The float non-boundary layer inputs that intersect the boundary layer elems are imprint-remeshed to accommodate the boundary layers.

      Bit5

      Distribute boundary layer thickness mode. Effective only for smooth boundary layer method. Valid values are:

      0 - No special boundary layer thickness distribution.

      14 - The special load comp ^CFD_BL_Thickness is used to extract the boundary layer thickness reduction ratio distribution. Note that this component needs to be pre-constructed with either the auto or manual boundary layer thickness generation utilities.

      Bit7

      Special comp cleanup mode. Effective only for smooth boundary layer method. Valid values are:

      0 - Do not delete elements in special CFD_boundary_layer and CFD_tetramesh_core components first.

      1 - Delete elements in special CFD_boundary_layer and CFD_tetramesh_core components first.

      Bit8

      Determines if multiple normals should be used for baffle edges or inward sharp edges that are sharper than a given threshold angle. This threshold angle is 1.5 degrees by default and can be reset by unoffsettable_angle in the "pars:…" string below. Valid values are:

      0 - Collapse BL for nodes on the baffle edges and inward-sharp edges.

      1 - Use multiple normals (currently 2) per node on the baffle edges and inward-sharp edges so to generate a wrapping BL around them.

    • bl_thick0 <value> - The first layer thickness.

    • bl_thicktotal <value> - Either the total boundary layer thickness, or the number of layers, depending on cfd_opts. Effective only for the smooth boundary layer method.

    • bl_growthrate <value> - The boundary layer to tetra core elem size transition mode. Effective only for smooth boundary layer method. If set to 1, the boundary layer heights are smoothly transitioned to the core elem size whenever possible. In rare situations where the smooth boundary layer is unable to be built for some baffle elems, activation of this mode may cause meshing failures.

    For elem size control box:

    "size_ctrl: x1 y1 z1 x2 y2 z2 … x8 y8 z8"

    This string contains 25 double numbers and inputs a single size control box. Note, a size control box can be input also using components that are specially pre-constructed for size control boxes (see Model.tetmesh_create_size_ctrl()). The first 24 numbers above consist of 8 triplets that each defines the 3d coordinates of a corner of the control box. The corners are ordered the same as an hm hex element. The last number is the target element size for elems inside and near the box.

    For the 2D auto meshing parameters, which are used for meshing unmeshed input surfaces. This is required only for meshing by geometries

    "2d: elem_order elem_type mesh_type elem_size min_size max_angle use_existing_mesh"

    • elem_order <value> - The element order. Should be the same as the global elem order setting. Valid values are 1 and 2.

    • elem_type <value> - The element type. Valid values are:

      0 - trias

      1 - quads

      2 - mixed

      3 - R-trias

      4 - quads only

    • mesh_type <value> - The mesh type. Valid values are:

      1 - No chordal and no curvature and no proximity

      2 - Chordal and no curvature and no proximity

      3 - No chordal and no curvature and proximity

      4 - Chordal and curvature and proximity

      5 - Chordal and curvature and no proximity

    • elem_size <value> - The 2D element size.

    • min_size <value> - The minimum element size.

    • max_angle <value> - The feature angle in degrees (typically 30).

    • 2D_mesh_creation_flag <flag> - Valid values are:

      0 - Recreate 2D mesh on input surfaces even if there is an existing mesh.

      1 - Create 2D mesh only on the input surfaces that do not have an existing mesh (default)

    Other meshing parameters that either are not categorized, or are less used. Pairs are separated by either a space or a comma. In general a key may have a default off-value and a default on-value. When a key is not present in the “pars…” string, it assumes the default off-value; while when the key is in the “pars:…” string without the “=value” part, it assumes the default on-value. Note also, not all keys have default on-values. In this case the “=value” part is mandatory.

    "pars: key1=value1 key2=value2 ..."

    String value parameters:

    • aft/delauney/octree <value> - Valid options are:

      aft - Node insertion based on the legacy advancing front method.

      delauney - Node insertion based on the Delauney method (default if not specified).

      octree - Node insertion based on the octree method.

    Integer value parameters:

    • auto_cfd_bc <flag> - If on, the floating input shell elements will be updated by the corresponding faces of resulting solid elements. Valid options are:

      0 - Do not reclassify interfacial input elements (default off)

      1 - All interfacial input elements between meshing fluid volumes are auto reclassified as float non-BL input regardless of how they are specified on input (default on)

    • bdr_iso_lyrs <flag> -

      0 - Do not create isotropic layered mesh (default off)

      1 - Create isotropic layered mesh (default on)

    • feature_angle <value>- Valid only if "...skip_aflr3..." is on. The feature angle to use for tet mesh optimization.

    • fill_void <value> - Determines if auto-detected voids are to be meshed.

      0 - No fill (default off)

      1 - Fill (default on)

    • fix_comp_bdr <value> - Valid only if "...skip_aflr3..." is on.

      0 - Node-wide (as opposed to topologically) preserve the surface boundary while doing tet mesh optimization (default off)

      1 - Topologically (as opposed to node-wise) preserve the surface boundary while doing tet mesh optimization (default on)

    • niter <value> - Valid only if "...skip_aflr3..." is on. The max iterations to use for tet mesh optimization. Must be a value \(\ge\) 0. The default off is 0 and there is no default on value.

    • nlayer_tet <value> - The minimum number of tetra mesh layers, \(\ge\) 1 (default =1).

    • no_tetra_has_2btri <value> -

      0 - Do not prevent any resulting tetra from having more than one face on a boundary (default off)

      1 - Prevent any resulting tetra from having more than one face on a boundary (default on)

    • post_cln <flag> - If on, if tet meshing fails, the shell elements are checked and cleaned before tet meshing is retried.

      0 - Do not clean after tet failure (default off)

      1 - Clean after tet failure (default on)

    • pre_cln <flag> - If on, input shell elements are checked and cleaned before tet meshing.

      0 - Do not clean (default off)

      1 - Clean (default on)

    • shell_remesh <flag> -

      0 - Swap only (default off)

      1 - Float input can be remeshed (default on)

    • shell_swap <value> - Valid only if "...skip_aflr3..." is on. The input triangles are swappable only while doing tet mesh optimization.

    • shell_validation <flag> -

      0 - Do not check shell validity before tet meshing (default off)

      1 - Check shell validity before tet meshing (default on)

    • skip_aflr3 <flag> -

      0 - Do not skip AFLR3 (default off)

      1 - Skip AFLR3 (default on)

    • upd_shell <flag> - If on, the floating input shell elements will be updated by the corresponding faces of resulting solid elements.

      0 - Do not update float shells (default off)

      1 - Update float shells (default on)

    • task <value> -

      0 - Normal run (default off)

      1 - Initial tetra Delaunay, only an initial tetra Delaunay mesh with minimum insertion of nodes will be created. The inserted nodes are only for the purpose of a successful recovery of the boundary shell.

      64 - Generate a convex hull of inputs.

    Double value parameters:

    • bl_core_r <value> - The dynamic BL thickness reduction parameter for avoiding BL collisions. Valid values are:

      1.0 - Disabled (default off value).

      > 0.0 - Enabled with the specified value as the thickness ration of the tetcore thickness versus the BL thickness.

    • bl_corer_r <value> - The dynamic BL thickness reduction parameter for sharp corners for avoiding BL collisions. Valid values are 1.0 ≥ value > 0.0. The default off value is 0.3.

      1.0 - Disabled (default off value).

      > 0.0 - Enabled with the specified value as the thickness ration of the tetcore thickness veruss the BL thickness.

    • bl_int_lyrs <value> - The initial number of BL layers that are to be interpolated, instead of done by smoothing layer-by-layer. A value \(\ge\) 0.0, with a default off value of 0.0.

    • bl_iter_max <value> - The max BL per layer smooth iterations, between 0.0 and 3000. 0.0 means auto-calculate. The default off value is 0.0.

    • bl_res_thr <value> - The BL smooth relative residue convergence criteria, between 0.0 and 1.0. At any smooth iteration, if the worst relative residue is below this value, smoothing is performed. 0.0 means auto-calculate. The default off value is 0.002.

    • unoffsettable_angle <value> - A threshold angle in degrees, between 0.0 and 45.0. An element edge is classified as inward-sharp if the inward-dihedral angle is sharper than this threshold. Baffle edges are always considered as sharp edges. BL on a sharp edge is handled either by BL node collapsing or BL wrapping by multiple normals per node depending on Bit8 of cfd_flags options in the “cfd:…” string. The default off value is 1.5.

    • shell_dev=<off geom>,<along geom> - Defines the optional allowed deviation off and along the “geometry” while improving tet quality. A typical value might be "... shell_dev=0.01,0.1 ..."

    Quality parameters, any combination can be used:

    • aspect <value> - Aspect ratio. Range > 1.0, typical is 8.0.

    • cell_squish <value> - Cell squish. Range [0-1.0], typical is 0.9.

    • skew <value> - Skew. Range > 0.0, typical is 60.

    • stretch <value> - SimLab stretch criteria=sqrt(R/Lmax) where R is the radius of the inscribed sphere and Lmax is the longest tet edge. For an equilateral tet, stretch is 1. Range [0-1.0], typical is 0.1.

    • tet_clps <value> - Tet collapse. Range [0-1.0], typical is 0.1.

    • vol_ar <value>- Volumetric aspect ratio. Range > 1.22, typical is 8.0.

    • vol_skew <value> - Volumetric skewness. Range [0-1.0], typical is 0.95.

    For saving mesh to file. This string is optional and it is mainly for large model handling. When this string exists, the resulting mesh will not be created on the HM database. Instead, it will be written directly to the indicated file in Nastran format.

    "save_as: file_path"

    • file_path <value> - The file path to save the mesh. If the path has spaces, it should be double quoted by " pairs (for example, "save_as: "C:Program Filesmesh.dat"").

    For advanced control of tetra meshing core. These parameter values take precedence over those defined by the tetra meshing string. Each name/value pair must be a proper parameter string name/value pair as defined in AFLR3.

    "aflr3_int: str_name1 int1 …"

    "aflr3_dble: str_name1 double1 …"

    "aflr3_str: str_name1 str_value1 …"

  • graphicsDB (int) – Internal parameter (default 0).

Examples#

Create a tetra mesh on all solids of cuurent model by geometries and by set some parameters#
import hm
import hm.entities as ent

model = hm.Model()

node_col = hm.Collection(model, ent.Node, populate=False)

str_array = [
  "pars: upd_shell fix_comp_bdr post_cln elem_order = 2 delaunay el2comp=3 fill_void=1 tet_clps='0.100000,0.300000, 0.500000, 1.000000, 0.380000, 0.100000'",
  "tet: 35 1.3 -1 0.014 0.8 0 0 1",
  "2d: 1 0 4 0.01 0.001 30 1",
]

solids_col = hm.Collection(model, ent.Solid)

model.tetmesh(
    collection1=solids_col,
    mode1=1,
    collection2=node_col,
    mode2=2,
    string_array=str_array,
)
Create a tetra mesh in specific components#
import hm
import hm.entities as ent

model = hm.Model()

elements_col = hm.Collection(model, ent.Element, populate=False)

str_array = ["tet: 35 1.3 -1 0.014 0.8 0 0 1"]

comps_list = [
    comp for comp in hm.Collection(model, ent.Component)
    if comp.name in ("inlet", "outlets", "wall", "wall_cyl")
]

comps_col = hm.Collection(comps_list)

model.tetmesh(
    collection1=comps_col,
    mode1=0,
    collection2=elements_col,
    mode2=0,
    string_array=str_array,
)