Mesh a half model on a symmetry plane
Use this when the configuration is mirror-symmetric and you grid only one half: the bodies are cut at the plane, the junction grid ends on it, and its faces on the plane carry a SYMMETRY boundary condition through to cc.par.
The script runs in about 2 s.
Cut a body into a half body
# keep the y >= 0 half of each body and drop the faces lying on the plane y = 0
box = shapes.box(extents=(4.0, 2.0, 1.0))
box.apply_translation((0.0, 1.0, -0.5))
box.update_faces(~np.all(np.isclose(box.vertices[box.faces][..., 1], 0.0), axis=1))
post = shapes.cylinder(radius=0.5, height=1.6, sections=96)
post.apply_translation((0.0, 0.0, 0.2))
post.update_faces(post.triangles_center[:, 1] > 0.0)
for mesh in (box, post):
mesh.remove_unreferenced_vertices()
box.export("half_box.stl")
post.export("half_post.stl")- A half body is an open STL: the facets on the plane are removed, so the surface ends on it. Here a box (the "wing") and a vertical post, the half model of ADR 0011, cut at y = 0.
- An open STL is not watertight, so loading it warns. The script loads it with
skip_hygiene=True, as the half-collar acceptance tests do: the facets and their orientation stay as written (no vertex merge, degenerate-face removal orfix_normals). The CLI runs the hygiene pass; on these bodies both give the same grid. - The
cubed_sphere,ogridandohtopologies ray-cast from an anchor inside a closed, star-shaped body and do not take half bodies. Half models serve the junction grids: intersection curves, surface marching and collars.
Build a half-collar at the junction
p = Project()
with warnings.catch_warnings():
warnings.simplefilter("ignore") # an open half body is not watertight: expected
p.load_geometry("half_box.stl", skip_hygiene=True)
p.build_collar(
"half_post.stl",
seed=(0.45, 0.2, 0.02), # a point near the junction
n_loop=25,
ds_surface=0.01,
growth_surface=1.12,
m_a=12,
m_b=12,
ds_wall=1e-4,
growth_wall=1.2,
nk=25,
plane=((0.0, 0.0, 0.0), (0.0, 1.0, 0.0)), # (point, normal) of the symmetry plane
)
block = p.mesh.blocks[0]
print("nodes:", block.nodes.shape)
print("j-faces off the plane by", np.abs(block.nodes[:, [0, -1], :, 1]).max())
print({f.name: f.bc.name for f in block.faces()})
p.write_geo("half_collar")shore collar half_box.stl half_post.stl --seed 0.45 0.2 0.02 --n-loop 25 \
--ds-surface 0.01 --growth-surface 1.12 --m-a 12 --m-b 12 \
--ds-wall 1e-4 --growth-wall 1.2 --nk 25 --plane 0 0 0 0 1 0 \
-o half_collar --adjacency-json half_collar.adjacency.jsonnodes: (25, 25, 26, 3)
j-faces off the plane by 0.0
{'i_lo': 'FREE', 'i_hi': 'FREE', 'j_lo': 'SYMMETRY', 'j_hi': 'SYMMETRY', 'k_lo': 'WALL', 'k_hi': 'FREE'}plane=(point, normal)(CLI--plane PX PY PZ NX NY NZ) turns the collar into a half-collar: the junction curve is traced from the seed both ways until it reaches the plane, the surface grids march with both ends held on the plane, and the block is open in j withj_loandj_hion the plane.- Block shape:
m_b + m_a + 1nodes across the junction,n_loopalong it,nk + 1wall-normal. - On mirror-symmetric bodies the half-collar is the y >= 0 half of the whole collar built on the mirrored wall, and its j-lines meet the plane at a right angle.
- When the curve meets the plane obliquely (more than 1 deg off the plane normal) the build warns: the faces are still on the plane, but the quality near it is not guaranteed.
- The CLI prints the two not-watertight warnings of the half bodies; they are expected. Add
--project DIRto record the build in a project. - One plane only: a model cut by two planes is out of scope.
Write the SYMMETRY faces to cc.par
p.write_adjacency("half_collar.adjacency.json")
write_cc_par(
read_adjacency_json("half_collar.adjacency.json"), "cc.par", grd_filename="half_collar.grd"
)shore cc-par half_collar.adjacency.json cc.par --grd half_collar.grdThe two j-faces come out as natural-BC code 2 (symmetry), the wall as 1, the free faces as the chimera code 40:
1 3 2 0 0 24 0 0 0 25 ! 3
1 4 2 0 0 24 24 24 0 25 ! 4
1 5 1 0 0 24 0 24 0 0 ! 5FaceBC.SYMMETRY round-trips through .adjacency.json and is written as BCSymmetryPlane by the CGNS export (Export CGNS and Plot3D).
Declare the symmetry plane of a blocking
A blocked half model declares its cut plane once, after create_blocking:
p.create_blocking(53, 33, 25, vmin=(-6, -4, 0), vmax=(7, 4, 6))
p.symmetry_plane((0, 0, 0), (0, 0, 1))premesh then makes the faces on the plane SYMMETRY faces, and orthogonalize keeps the wall-normal lines that start on it in it (ADR 0053); without the declaration those faces are FREE and drift off the plane. Blocking a wing–body uses it.