PyPrimeMesh Creating Triangular Faces vs. Workbench Mechanical Creating Quad Faces #953
Unanswered
Kevin-Yanik
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am looking to create a fully hex mesh for a simple angled plate, which I have attached the spaceclaim geometry file for. When I perform meshing in Workbench Mechanical, the mesher is easily able to create all hex elements, but when I try to use PyPrimeMesh, using the code below, some triangular elements are created on the base surface, which is not desirable. How can I force an all quad surface mesh, that is swept through the volume to create an all hex mesh. I have tried splitting the geometry in multiple smaller sections in hopes that it would be simpler to mesh and have also tried using multizone methods, along with going through the available examples, but have not found a solution yet that works. Please advise on how I should modify the code and thank you in advance!
Angled_Plate.zip
Workbench Mechanical Mesh:
PyPrimeMesh Mesh:
import os
import ansys.meshing.prime as prime
from ansys.meshing.prime.graphics import Graphics
pv.global_theme.background = 'white'
prime.LengthUnit.M
prime_client = prime.launch_prime()
model = prime_client.model
mesh_util = prime.lucid.Mesh(model=model)
file_io = prime.FileIO(model=model)
params = prime.ImportCadParams(model=model,
length_unit= 0, #set unit to m
cad_reader_route=prime.CadReaderRoute.WORKBENCH,
)
layers_per_solid = 4 # number of hexa mesh layers in each solid
base_face_size = 0.00175 # surface mesh size in m on the base face, use 1.75e-3m
CAD_file = file_io.import_cad(
file_name= 'C:/Users/Desktop/sim/Angled_Plate.scdoc',
params=params)
print(model)
Set the global sizing parameters after importing the model
model.set_global_sizing_params(
prime.GlobalSizingParams(model=model, min=0.0001, max=base_face_size)
)
Access the first part in the model
part = model.parts[0]
ids = []
for label in part.get_labels():
# Check whether the named selection's name starts with the string "edge"
if label.startswith('z_edges'):
#Define the length of edge
length = .003175 #meters
# Initialize a constant-size mesh control (Soft)
soft_size_control = model.control_data.create_size_control(prime.SizingType.SOFT)
# Assign a mesh size equal to the edge's length/number of mesh layers
soft_size_params = prime.SoftSizingParams(model=model, max=length / layers_per_solid)
# Finalize the creation of mesh sizing
soft_size_control.set_soft_sizing_params(soft_size_params)
Soft_size_scope = prime.ScopeDefinition(
model,
part_expression=part.name,
entity_type=prime.ScopeEntity.FACEANDEDGEZONELETS,
label_expression=label + "*",
)
soft_size_control.set_scope(Soft_size_scope)
soft_size_control.set_suggested_name(label)
# Append the id of the edge sizing to the edge sizings' ids' list
ids.append(soft_size_control.id)
Instantiate the volume sweeper
sweeper = prime.VolumeSweeper(model)
Define the parameters for stacker
stacker_params = prime.MeshStackerParams(
model=model,
direction=[0, 0, 1], # define the sweep direction for the mesh
delete_base=True, # delete the base face in the end of stacker
size_control_ids=ids,
) # list of control IDs to be respected by the stacker
Set up the necessary parameters for the generation of the base face.
soft_size_control = model.control_data.create_size_control(prime.SizingType.SOFT)
soft_size_params = prime.SoftSizingParams(model=model, max=base_face_size)
soft_size_control.set_soft_sizing_params(soft_size_params)
soft_size_scope = prime.ScopeDefinition(
model, part_expression=part.name, entity_type=prime.ScopeEntity.FACEANDEDGEZONELETS
)
soft_size_control.set_scope(soft_size_scope)
soft_size_control.set_suggested_name("b_f_size")
Create the base face, appending the the stacker mesh parameters.
createbase_results = sweeper.create_base_face(
part_id=model.get_part_by_name(part.name).id,
topo_volume_ids=model.get_part_by_name(part.name).get_topo_volumes(),
params=stacker_params,
)
base_faces = createbase_results.base_face_ids
model.get_part_by_name(part.name).add_labels_on_topo_entities(["base_faces"], base_faces)
scope = prime.ScopeDefinition(model=model, label_expression="base_faces")
base_scope = prime.lucid.SurfaceScope(
entity_expression="base_faces",
part_expression=part.name,
scope_evaluation_type=prime.ScopeEvaluationType.LABELS,
)
Generate the quad-dominant surface mesh on the base face.
mesh_util_controls = mesh_util.surface_mesh_with_size_controls(
size_control_names="b_f_size", scope=base_scope, generate_quads=True
)
Use the
stack_base_face
function to generate the volume meshstackbase_results = sweeper.stack_base_face(
part_id=model.get_part_by_name(part.name).id,
base_face_ids=base_faces,
topo_volume_ids=model.get_part_by_name(part.name).get_topo_volumes(),
params=stacker_params,
)
display = Graphics(model)
display()
prime_client.exit()
Beta Was this translation helpful? Give feedback.
All reactions