Skip to content

Make a test body ​

You need a body to mesh before you have the real CAD: an analytic shape, an airfoil section or a wing built from one. SHORE generates all three, as STL files from the CLI or as trimesh.Trimesh / numpy arrays from Python.

The Python code on this page is examples/cookbook/bodies.py; it runs in under a second.

Write an analytic body as STL ​

bash
shore body sphere --radius 1.0 --subdivisions 3 -o sphere.stl
shore body capsule --radius 0.5 --height 2.0 --sections 24 -o capsule.stl
shore body box --extents 2 1 0.5 -o box.stl
python
# Analytic bodies are trimesh.Trimesh objects; export() writes the STL.
shapes.sphere(radius=1.0, subdivisions=3).export("sphere.stl")
shapes.capsule(radius=0.5, height=2.0, sections=24).export("capsule.stl")
torus = shapes.torus(r_major=1.0, r_minor=0.25)
torus.export("torus.stl")
print(f"torus: {len(torus.faces)} triangles, watertight={torus.is_watertight}")
text
torus: 2048 triangles, watertight=True
  • Every body is centred at the origin; the cylinder, capsule and torus have their axis along z.
  • sphere is an icosphere: each subdivision level multiplies the triangle count by 4 (level 3 = 1280 triangles). Its radius is exact only at the vertices, so a fine level keeps the faceting error small against your first cell.
  • capsule (height = length of the cylindrical middle) and sphere are star-shaped from the centroid, so they suit the cubed_sphere, ogrid and oh topologies. The torus is not star-shaped: use it to test geometry and association code, not the ray-cast projection.

Generate a NACA section ​

bash
shore profile naca 0012 -o naca0012.dat
shore profile naca 2412 --open-te -o naca2412_blunt.dat
python
sharp = profiles.naca("0012", n_pts=80)  # (159, 2), upper TE -> LE -> lower TE
blunt = profiles.naca("2412", n_pts=80, closed_te=False)
profiles.write_section("naca0012.dat", sharp, name="NACA 0012")
profiles.write_section("naca2412_blunt.dat", blunt, name="NACA 2412 blunt TE")
gap = np.linalg.norm(blunt[0] - blunt[-1])
print(f"NACA 0012: {sharp.shape[0]} points; NACA 2412 blunt TE gap {gap:.2e} chord")
text
NACA 0012: 159 points; NACA 2412 blunt TE gap 2.52e-03 chord
  • 4-digit (0012, 2412) and 5-digit (23012, reflexed 23112) designations are supported; anything else raises ParameterError.
  • n_pts (--n-pts, default 80) is the number of cosine-spaced chord samples per side; the section has 2 * n_pts - 1 points, ordered upper TE → LE → lower TE (Selig order).
  • The default closes the trailing edge exactly (sharp TE). closed_te=False (--open-te) keeps the standard polynomial's residual thickness, a blunt TE about 0.25 % chord thick, which the C-grid topology detects and meshes with its 4-block blunt variant.
  • The .dat file is plain x y rows with an optional name line, the UIUC airfoil database format; read_section reads such files.

Extrude a wing with taper, sweep and twist ​

bash
shore body extrude --section naca0012.dat --span 1.0 --n-stations 8 -o wing_straight.stl
shore body extrude --section naca0012.dat --span 2.0 --n-stations 12 \
    --taper 0.6 --sweep-deg 25 --twist-deg -3 --span-axis y --end-caps -o wing_swept.stl
python
section = profiles.read_section("naca0012.dat")
# Straight wing with open ends: the C-grid topology slices it per span station.
shapes.extrude_section(section, span=1.0, n_stations=8).export("wing_straight.stl")
# Tapered, swept, twisted wing with watertight end caps.
swept = shapes.extrude_section(
    section,
    span=2.0,
    n_stations=12,
    taper=0.6,
    sweep_deg=25.0,
    twist_deg=-3.0,
    span_axis="y",
    end_caps=True,
)
swept.export("wing_swept.stl")
print(f"swept wing: extents {np.round(swept.extents, 3)}, watertight={swept.is_watertight}")
text
swept wing: extents [1.532 2.    0.12 ], watertight=True
ParameterDefaultMeaning
span1.0total length along span_axis
n_stations8span stations including root and tip (>= 2)
taper1.0tip-to-root chord ratio
sweep_deg0.0leading-edge sweep, positive = sweepback
twist_deg0.0tip twist, linear from 0 at the root, positive = nose-up
span_axiszx, y or z
end_capsFalsecentroid-fan caps at both ends, watertight
  • Leave the ends open (the default) for the cgrid and ch topologies: they cut the wing into span stations and need the open ends to slice cleanly. Close them (end_caps=True) for anything that needs a watertight body: shore boxes-from-stl (voxel fill) refuses an open STL, and loading one warns.
  • The section is stacked as given: the stations are straight copies, so the spanwise faceting is linear between stations.

See also ​

Released under the MIT License.