Model.batchmesh_mc#
- Model.batchmesh_mc(collection, entity_collection, options)#
Meshes geometry using BatchMesh mesh controls.
- Parameters:
collection (Collection) – The collection containing the mesh control entities to use.
entity_collection (Collection) –
The collection containing the entities for the model control on-the-fly selection. Valid entities are surfaces, components and regions.
This is ignored, if the model control selection is set directly in the model mesh control.
options (int) –
A flag that indicates the advanced options.
Bit values are used and the value is calculated as (2*Bit1 + 4*Bit2 + 8*Bit3 + 64*Bit6 + 128*Bit7). Valid Bit options are:
Bit1
Overlapping selection behavior. Valid values are:
0 - Allow overlapping selections. The first mesh control referencing the entity is used and that entity is ignored in subsequent mesh controls.
1 - Do not allow overlapping selections and return an error.
Bit2
Mesh connectivity. Valid values are:
0 - Keep connectivity with existing mesh.
1 - Break connectivity with existing mesh.
Bit3
Mesh controls order. Valid values are:
0 - Apply mesh controls by element size.
1 - Apply mesh controls by increasing ID.
Bit6
Plot elements. Valid values are:
0 - Keep plot elements.
1 - Delete plot elements before meshing.
Bit7
Delete elements unassociated to geometry. Valid values are:
0 - Keep unassociated elements.
1 - Delete unassociated elements before meshing.
Show Bit value calculator
Radio Button Table Option Name Value Overlapping selection behavior (Bit1) Mesh connectivity (Bit2) Mesh controls order (Bit3) Plot elements (Bit6) Delete elements unassociated to geometry (Bit7) Calculated argument value: 0
Examples#
BatchMeshing the components with IDs 1 and 2, using a first-order mixed mesh, keeping any adjacent existing elements with criteria file “C:/batch_criteria/crash_10mm.criteria” and parameters file “C:/batch_criteria/crash_10mm.param”#import hm import hm.entities as ent model = hm.Model() # Creating Mesh_control. "MCBM_CFG_BATCHMESH_GLB -> config=38 mshc_ent = ent.Meshcontrol(model, name="main_mc", config=38) # Setting files and parameters mshc_ent.MCBM_ENTITY_SEL = [ent.Component(model, 1), ent.Component(model, 2)] mshc_ent.MCBM_MODE_CBX = 0 mshc_ent.MCBM_CRITERIA_FILE = "C:/batch_criteria/crash_10mm.criteria" mshc_ent.MCBM_PARAMS_FILE = "C:/batch_criteria/crash_10mm.param" meshCon_col = hm.Collection([mshc_ent]) model.batchmesh_mc( collection=meshCon_col, entity_collection=hm.Collection(model,ent.Component,populate=False), options=0, )
BatchMeshing the components “Main_Body”, “Medium and” “Detailed”, using a first-order mixed mesh, keeping any adjacent existing elements. Mesh component “Main_Body” with criteria file “C:/batch_criteria/crash_10mm.criteria” and parameters file “C:/batch_criteria/crash_10mm.param”. Mesh component “Medium” with element size 7.0, scaling the criteria and parameters from “C:/batch_criteria/crash_5mm.criteria” and “C:/batch_criteria/crash_5mm.param”. Mesh component “Detailed” with auto generated criteria and parameters with element size 4.0, min element size 2.0 and max element size 6.5. Use defaults for all other auto-generation options.#import hm import hm.entities as ent model = hm.Model() # Create a global mesh control for all comps. "MCBM_CFG_BATCHMESH_GLB" -> config=38 compcol = hm.Collection( model, ent.Component, "Name=Main_Body OR Name=Medium OR Name=Detailed" ) mshc_ent = ent.Meshcontrol(model, name="main_mc", config=38) # Setting files and parameters mshc_ent.MCBM_ENTITY_SEL = list(compcol) mshc_ent.MCBM_MODE_CBX = 0 mshc_ent.MCBM_CRITERIA_FILE = "C:/batch_criteria/crash_10mm.criteria" mshc_ent.MCBM_PARAMS_FILE = "C:/batch_criteria/crash_10mm.param" # Create a local mesh control for Medium. "MCBM_CFG_BATCHMESH" -> config=39 medium_comp = [c for c in compcol if c.name == "Medium"][0] mshc_medium_ent = ent.Meshcontrol(model, name="medium_mc", config=39) # Setting files and parameters mshc_medium_ent.MCBM_ENTITY_SEL = [mshc_medium_ent] mshc_medium_ent.MCBM_MODE_CBX = 1 mshc_medium_ent.MCBM_ELEM_SIZE = 7.0 mshc_medium_ent.MCBM_CRITERIA_FILE = "C:/batch_criteria/crash_5mm.criteria" mshc_medium_ent.MCBM_PARAMS_FILE = "C:/batch_criteria/crash_5mm.param" # Create a local mesh control for Detailed. "MCBM_CFG_BATCHMESH" -> config=39 detailed_comp = [c for c in compcol if c.name == "Detailed"][0] mshc_detailed_ent = ent.Meshcontrol(model, name="detailed_mc", config=39) # Setting files and parameters mshc_detailed_ent.MCBM_ENTITY_SEL = list(detailed_comp) mshc_detailed_ent.MCBM_MODE_CBX = 2 mshc_detailed_ent.MCBM_MIN_ELEM_SIZE = 2.0 mshc_detailed_ent.MCBM_MAX_ELEM_SIZE = 6.5 # Create the mesh from the 3 mesh controls. # The component selection is not required since the entity selection is defined already. meshCon_col = hm.Collection([mshc_ent, mshc_medium_ent, mshc_detailed_ent]) model.batchmesh_mc( collection=meshCon_col, entity_collection=hm.Collection(model, ent.Component, populate=False), options=0, )
BatchMeshing all surfaces with criteria and parameters “C:/batch_criteria/crash_12mm.criteria” and “C:/batch_criteria/crash_12mm.param” with the following exceptions; (I) Surfaces with IDs 78, 134 and 163 should be meshed with criteria and parameters “C:/batch_criteria/crash_8mm.criteria” and “C:/batch_criteria/crash_8mm.param”, (II) Regions with IDs 2 and 5 should be meshed with criteria and parameters “C:/batch_criteria/crash_5mm.criteria” and “C:/batch_criteria/crash_5mm.param”#import hm import hm.entities as ent model = hm.Model() # #Global mesh control for 12mm mesh. "MCBM_CFG_BATCHMESH_GLB" -> config=38 mshc_part_ent = ent.Meshcontrol(model, name="part_mc", config=38) # Setting files and parameters mshc_part_ent.MCBM_MODE_CBX = 0 mshc_part_ent.MCBM_CRITERIA_FILE = "C:/batch_criteria/crash_12mm.criteria" mshc_part_ent.MCBM_PARAMS_FILE = "C:/batch_criteria/crash_12mm.param" # Local mesh control for 8mm mesh. "MCBM_CFG_BATCHMESH" -> config=39 mshc_8_ent = ent.Meshcontrol(model, name="mc_8mm", config=39) # Setting files and parameters mshc_8_ent.MCBM_ENTITY_SEL = [ent.Surface(model,78),ent.Surface(model,134),ent.Surface(model,163)] mshc_8_ent.MCBM_MODE_CBX = 0 mshc_8_ent.MCBM_CRITERIA_FILE = "C:/batch_criteria/crash_8mm.criteria" mshc_8_ent.MCBM_PARAMS_FILE = "C:/batch_criteria/crash_8mm.param" # Local mesh control for 5mm mesh. "MCBM_CFG_BATCHMESH" -> config=39 mshc_5_ent = ent.Meshcontrol(model, name="mc_5mm", config=39) # Setting files and parameters mshc_5_ent.MCBM_ENTITY_SEL = [ent.Region(model,2),ent.Region(model,5)] mshc_5_ent.MCBM_MODE_CBX = 0 mshc_5_ent.MCBM_CRITERIA_FILE = "C:/batch_criteria/crash_5mm.criteria" mshc_5_ent.MCBM_PARAMS_FILE = "C:/batch_criteria/crash_5mm.param" # Create the mesh from the 3 mesh controls. # The surfs selection is required since the global control entity selection is not defined. The component selection is not required since the entity selection is defined already. meshCon_col = hm.Collection([mshc_part_ent, mshc_8_ent, mshc_5_ent]) model.batchmesh_mc( collection=meshCon_col, entity_collection=hm.Collection(model, ent.Surface), options=0, )