Model.rebuild_mesh_advanced#

Model.rebuild_mesh_advanced(collection, flow_guides=hwTripleList(), keep_selection='', mode='')#

Remesh/Improve selected shell elements with quality and flow considerations, and optional flow guide selections to guide the mesh directions. It uses the same parameter and criteria files as used by BatchMesher to specify the quality criteria and mesh parameters. The criteria and parameter files must be properly set and registered before execution. It utilizes the following fields from the parameter file:

  1. Surface hole recognition table

  2. Feature angle during element cleanup

  3. Element type

  4. Mesh type

1Ds attached to the input shell elements are used as features and they significantly impact the mesh quality and flow. If no 1Ds are present in the shells of the input elements, the specified feature angle is internally used to recognize features.

Rebuild/improve is currently supported for first-order shell elements that are not attached to solid elements.

Parameters:
  • collection (Collection) – The collection containing the element entities to rebuild or improve.

  • flow_guides (hwTripleList) – A set of lines that are used to guide the mesh directions. Each line is composed of a list of points. User can specify as a list of lists.

  • keep_selection (hwString) –

    Flag to keep the element selection for selective rerun. Valid values are:

    always - Keep the full selection.

    failed - Keep only the failed selection.

    never - Do not keep the selection.

  • mode (hwString) –

    The mode of the operation. Valid values are:

    rebuild - Rebuild all selected elements.

    improve - Detect and rebuild only elements that affect flow/quality the most.

Example#

Remesh the displayed shell elements with 5mm criteria and parameter file settings, with mesh flow guides, and keep the failed areas on selection#
import hm
import hm.entities as ent

model = hm.Model()

model.setqualitycriteria(
    string_array=[
        " 0 penalty value      0.00    0.00    0.80    1.00   10.00",
        " 1 min length        1 1.0   3.000   2.749   1.502   1.000   0.749  1",
        " 2 max length        1 1.0   3.000   3.600   4.500   6.000   9.000  0",
        " 3 aspect ratio      1 1.0   1.000   2.000   4.400   5.000  10.000  0",
        " 4 warpage           1 1.0   0.000   5.000  13.000  15.000  30.000  0",
        " 5 max angle quad    1 1.0  90.000 110.000 134.000 140.000 160.000  0",
        " 6 min angle quad    1 1.0  90.000  70.000  46.000  40.000  20.000  0",
        " 7 max angle tria    1 1.0  60.000  80.000 112.000 120.000 150.000  0",
        " 8 min angle tria    1 1.0  60.000  50.000  34.000  30.000  15.000  0",
        " 9 skew              1 1.0   0.000  10.000  34.000  40.000  70.000  0",
        "10 jacobian          1 1.0   1.000   0.900   0.700   0.600   0.300  0",
        "11 chordal dev       0 1.0   0.000   0.300   0.800   1.000   2.000  0",
        "12 taper             1 1.0   0.000   0.200   0.500   0.600   0.900  0",
        "13 % of trias        1 1.0   0.000   6.000  10.000  15.000  20.000  0",
    ],
    mode=0,
)


batch_options = [
    "geometry_cleanup_flag    1",
    "meshing_flag                      5",
    "element_size                      5.0",
    "element_type                      2",
    "mesh_align                        3",
    "element_order                     1",
    "surf_component                    1",
    "feature_angle                     30.0",
    "holes_table_begin",
    "appl_surf(1)"
    "appl_solid(0)"
    "appl_cordsfiles(0)"
    "appl_flanged_suppr(1)"
    "flanged_suppr_height(1.4)"
    "narrow_slots_type(0)"
    "abs_fixed_nodes_count_max(-8)"
    "rad(0.0,2.2) do action(1) washer(0) ",
    "rad(2.2,3.01) do action(0) elems(4) washer(0) ",
    "rad(3.01,4.7) do action(0) elems(6) washer(1) layers(3.5) ",
    "rad(4.7,9.0) do action(0) elems(8) washer(1) layers(0.75*radius) ",
    "rad(9.0,11.0) do action(0) elems(8) washer(1) layers(7.0) ",
    "rad(11.0,20) do action(0) elems(8) washer(1) layers(auto) ",
    "rad(0.0,2.2) solid(1) do action(1) ",
    "rad(2.2,3.01) solid(1) do action(0) elems(4) ",
    "rad(3.01,20) solid(1) do action(0) elems(6) ",
    "holes_table_end",
    "edge_fillet_recognition           1",
    "max_fillet_radius                 5.0",
    "surface_fillet_table_begin",
    "surface_fillet_recognition(1)"
    "minimize_transitions(1)"
    "rad(0,2.2) wid(3.0,6.2) do split(suppress_on)"
    "rad(2.2,15) wid(3.4,6.2) do elems(1)"
    "rad(0,25.0) wid(6.2,9.2) do elems(2)"
    "rad(0,35.0) wid(9.2,12.5) do elems(3)"
    "rad(0,40.0) wid(12.5,25.0) do chordal_deviation(0.2)"
    "surface_fillet_table_end",
    "del_dupl_surfs_flag               2",
    "del_dupl_surfs_tol                -1",
    "edges_stitch_flags                0",
    "max_edges_stitch_tol              -1.0",
    "fix_overlapsurfs_flag             1",
    "overlapsurfs_maxtangangle         -1.0",
    "narrow_surfs_merge_width          -1.0",
    "narrow_surfs_treat_flags          3",
    "beads_suppression                 1",
    "beads_recognition                 1",
    "minimal_beads_height              1.4",
    "beads_treat_flags                 0",
    "flange_recognition                1",
    "flange_elements_across            3",
    "flange_max_width                  30.0",
    "flange_min_width                  8.0",
    "flanges_treat_flags               1",
    "flange_max_remove_width           -1.0",
    "appl_tria_reduction               1",
    "tria_redu_max_elemsize            auto",
    "tria_redu_min_elemsize            auto",
    "trias_around_holes                0",
    "common_mesh_flow                  0",
    "extract_thinsolids                1",
    "midsurf_method                    3",
    "thinsolid_ratio                   0.3",
    "max_thickness                     10.0",
    "extract_feature_angle             25.0",
    "pre_midsurf_cleanup               1",
    "direct_midmesh                    0",
    "ignore_flat_edges                 1",
    "flatten_connections               0",
    "defeat_open_width_on              1",
    "defeat_open_width                 1.0",
    "supp_proxim_edges_on              1",
    "supp_proxim_edges                 0.5",
    "combine_nonmanifold_on            1",
    "combine_nonmanifold               0.5",
    "midmesh_extact_elem_size          10.0",
    "remove_logo                       1",
    "logo_max_size                     30.0",
    "logo_max_height                   1.4",
    "logo_min_concavity                1.0",
    "threads_removal                   0",
    "threads_toremove_max_depth        5.0",
    "threads_replacediametertype       -2",
    "folded_elems_angle                150.0",
    "smooth_elems_target               0.2",
    "fillets_mesh_flow                 0",
    "failed_elems_cleanup_flgs         8",
    "move_nodes_across_feature_edges   1",
    "featureedge_nodes_moveacross_max  0.1",
    "move_nodes_across_free_edges      1",
    "freeedge_nodes_moveacross_max     0.05",
    "move_normal_flag                  1",
    "move_normal_dist                  0.8",
    "divide_warped_quads               1",
    "ignore_comps_boundary             0",
    "gen_topology_prepare_flags        7",
    "cleanup_comp_flag                 0 ",
    "comp_select                        ",
    "use_wildcards_for_compsnames      0",
    "cleanup_tolerances                auto",
    "suppress_features_rate            0",
    "feat_charsize_method              0",
    "custom_feat_suppr_maxangle        25.0",
    "uncond_constr_lines_suppress      0",
    "aggressive_fillet_lines_suppress  0",
]
model.createbatchparamsfromstrings(strings=batch_options)

elem_collection = hm.CollectionByDisplayed(model, ent.Element)
model.rebuild_mesh_advanced(
    collection=elem_collection,
    flow_guides=[
        [308.746697, 719.296657, 906.673771],
        [339.768568, 714.811262, 904.452529],
    ],
    keep_selection="failed",
    mode="rebuild",
)