The Xall bundle
You turn the two grids of 3. A Chimera assembly into the files the Xall solver chain reads: marker boxes that cut the body out of the background, one binary .grd with every block, the cc.par connectivity and boundary file, and the proc.input MPI distribution. You do it twice: in one shore xall call on the project, and by hand, file by file, which is what the one call does for you. You also meet one defect of the background grid that you have to fix by hand today.
You need
shore-mesh(no extras);shore boxes-exportneeds thevisextra.- About 15 minutes. The script runs in about 7 s, most of it in the marker boxes.
- The script:
examples/tutorials/xall_bundle.py. It rebuilds the grids of tutorial 3 first, so it runs on its own; the CLI commands below run in the directory where you ran tutorial 3.
| File | Read by | Content |
|---|---|---|
.grd | Xall, overset pre-processor | Fortran unformatted binary: block count, cell counts per block, then X, Y, Z of every block |
cc.par | overset pre-processor | header options, per-block level / group / priority, one patch per block face (boundary code or connection), marker boxes |
proc.input | Xall at MPI start-up | per block: group, body, MPI rank |
The three files share one 1-based block numbering. Whatever writes them must use one block order for all three. The formats are in shore grd, shore cc-par and shore proc-input.
shore.shapes.sphere(radius=0.5, subdivisions=4).export("sphere.stl")
p = Project()
p.use_component("sphere")
p.load_geometry("sphere.stl", name="sphere")
p.build_topology(
"cubed_sphere", nk=13, ds=0.01, growth=1.1, geometry="sphere",
ni=30, nj=40, theta_cap=math.radians(30.0),
) # fmt: skip
p.march()
p.write_geo("wall")
p.write_adjacency("wall.adjacency.json")
p.use_component("background")
p.build_primitive("flat_caps", r_out=10.0, z0=-10.0, z1=50.0, inner_frac=0.4, ni=16, nc=24, nk=60)
p.write_geo("background")
p.write_adjacency("background.adjacency.json")
wall_geo = [f"wall_{b.label}.geo" for b in p.components["sphere"].blocks]
background_geo = [f"background_{b.label}.geo" for b in p.components["background"].blocks]1. Generate the marker boxes
The background covers the body. Marker boxes tell the overset pre-processor which background cells lie inside the body and must be blanked. voxel-fill (the default) voxelises the body's bounding box and keeps the voxels inside the body, merged into larger boxes; the voxel size is max_outward_gap / sqrt(3), so no box surface is farther than the gap outside the body. Keep the gap below the near-body thickness (about 0.21 here), so the boxes end inside the near-body grid.
shore boxes-from-stl sphere.stl --block sub0 --max-outward-gap 0.10 -o sphere_boxes.json
shore boxes-export sphere_boxes.json -o sphere_boxes.vtmfrom shore.boxes import boxes_from_stl # noqa: E402
from shore.io.boxes import box_to_json # noqa: E402
boxes = boxes_from_stl(
"sphere.stl",
"sub0", # the block the boxes belong to (any block of the near-body grid)
max_outward_gap=0.10, # < the near-body thickness, ~0.21
)
with open("sphere_boxes.json", "w") as f:
json.dump([box_to_json(b) for b in boxes], f)
print(f"{len(boxes)} marker boxes")✓ Wrote sphere_boxes.json (101 box(es), method='voxel-fill')--block sub0 is the near-body block the boxes belong to in cc.par; any block of that grid will do. See Marker boxes for the algorithm and the aabb / obb alternatives.


2. Write the run in one call
shore xall writes the Xall run of every component of a saved project. Its options file has one [run] table for the run-wide options and one [components.<name>] table per component:
# xall.toml
[run]
grd = "assembly.grd"
np = 4
[components.background]
free_face_bc = 9 # natural BC 9: extrapolation at the far field
body = 0
[components.sphere]
body = 1
boxes = "sphere_boxes.json"
[components.sphere.meta.cap_north]
level = 2
[components.sphere.meta.cap_south]
level = 2shore xall assembly --out run --options xall.tomlp.write_xall(
"run",
grd="assembly.grd",
np=4,
components={
"sphere": {
"body": 1,
"boxes": [box_to_json(b) for b in boxes],
"meta": {"cap_north": {"level": 2}, "cap_south": {"level": 2}},
},
"background": {"free_face_bc": 9},
},
)
print(p.last_result[1]) # the balance of the one proc.input over all 11 blocks
print("same .grd as the manual merge:", filecmp.cmp("assembly.grd", "run/assembly.grd", False))✓ Wrote the Xall run of ['sphere', 'background'] to runrun/
assembly.grd # the 11 blocks, sphere first (component creation order)
cc.par # merged
proc.input # balanced once over all 11 blocks
sphere/ # per component: .geo files, sidecar, sphere.grd, cc.par
background/What the options mean:
| Option | Effect |
|---|---|
free_face_bc | the code of the component's FREE faces: 40 (the default) is a chimera fringe that receives from other grids; a far-field background takes a natural boundary code in 1–19, e.g. 9 (extrapolation), 3 (inflow), 4 (outflow) |
body | the Xall body number of all the component's blocks in proc.input (forces and moments are integrated per body) |
boxes | marker boxes for the component's cc.par, a file relative to the options file |
meta.<block> | per-block level, group, priority, comment, free_face_bc in cc.par; here the caps get overset level 2 |
proc_meta.<block> | per-block proc / group / body in proc.input |
Unknown tables and keys, components without a grid and block labels a component does not have are errors, reported before anything is written. The shore xall page lists the [run] options.
Never a negative far-field code
Older SHORE documentation used -9 for far-field faces. Xall rejects any face code below 1 ("icc sulle facce deve essere > 0"): the natural codes are positive, 1 to 19.
3. The same, file by file
shore xall runs the steps below for you. Run them yourself when the components do not live in one project, or to control each file. The shell script examples/05-chimera-assembly/chimera_assembly.sh chains the same commands from the STL on.
Pack the blocks. The order of the files is the block order of the .grd and must be the order cc.par uses: the order of the blocks in the sidecar.
shore grd wall_sub0.geo wall_sub1.geo wall_sub2.geo wall_sub3.geo \
wall_cap_north.geo wall_cap_south.geo -o wall.grd
shore grd background_center.geo background_sub_e.geo background_sub_n.geo \
background_sub_w.geo background_sub_s.geo -o background.grdfrom shore.io.grd import write_grd # noqa: E402
write_grd("wall.grd", wall_geo) # the block order of the .grd is the order of the files
write_grd("background.grd", background_geo)Write one cc.par per component. Near-body FREE faces default to 40; the background's take 9: a background primitive has no wall, every face that is not a seam is FREE (ADR 0055). The boxes go with the near-body grid.
shore cc-par wall.adjacency.json wall.cc.par --grd wall.grd \
--boxes sphere_boxes.json --meta '{"cap_north": {"level": 2}, "cap_south": {"level": 2}}'
shore cc-par background.adjacency.json background.cc.par --grd background.grd --free-bc 9from shore.io.cc_par import BlockMeta, write_cc_par # noqa: E402
near = {b: BlockMeta(free_face_bc=40) for b in ("sub0", "sub1", "sub2", "sub3")}
near |= {b: BlockMeta(level=2, free_face_bc=40) for b in ("cap_north", "cap_south")}
write_cc_par(
"wall.adjacency.json", "wall.cc.par", grd_filename="wall.grd",
block_metadata=near, boxes=boxes,
) # fmt: skip
far = {b.label: BlockMeta(free_face_bc=9) for b in p.components["background"].blocks}
write_cc_par(
"background.adjacency.json", "background.cc.par", grd_filename="background.grd",
block_metadata=far,
) # fmt: skipWrite one proc.input per component. --meta keys are 1-based block indices of that .grd; the near-body blocks are body 1.
shore proc-input wall.grd wall.proc.input --np 4 \
--meta '{"1": {"body": 1}, "2": {"body": 1}, "3": {"body": 1}, "4": {"body": 1}, "5": {"body": 1}, "6": {"body": 1}}'
shore proc-input background.grd background.proc.input --np 4from shore.io.proc_input import write_proc_input # noqa: E402
_, summary = write_proc_input(
"wall.grd", "wall.proc.input", np=4, body_assignment=dict.fromkeys(range(1, 7), 1)
)
write_proc_input("background.grd", "background.proc.input", np=4)
print(summary)proc.input: 5 blocks across 4 ranks
rank 0: 1 blocks, 31.2k cells (27.7%)
rank 1: 2 blocks, 40.7k cells (36.1%)
rank 2: 1 blocks, 20.4k cells (18.1%)
rank 3: 1 blocks, 20.4k cells (18.1%)
imbalance: 72.3%
Warning: load imbalance is 72.3% (> 5%). Run `shore balance` to plan a topology-safe
set of splits that brings the imbalance within tolerance.Merge. The three merges must take the components in the same order; each shifts the block (and patch) indices of the later inputs.
shore grd-merge wall.grd background.grd -o assembly.grd
shore cc-par-merge wall.cc.par background.cc.par -o assembly.cc.par --grd assembly.grd
shore proc-input-merge wall.proc.input background.proc.input -o assembly.proc.input \
--grd assembly.grdfrom shore.io.cc_par import merge_cc_par # noqa: E402
from shore.io.grd import merge_grd # noqa: E402
from shore.io.proc_input import merge_proc_input # noqa: E402
order = ["wall", "background"] # one order for all three merges
merge_grd([f"{c}.grd" for c in order], "assembly.grd")
merge_cc_par([f"{c}.cc.par" for c in order], "assembly.cc.par", grd_filename="assembly.grd")
_, merged = merge_proc_input(
[f"{c}.proc.input" for c in order], "assembly.proc.input", grd_path="assembly.grd"
)
print(merged)✓ Wrote assembly.proc.input (2 inputs merged)
proc.input: 11 blocks across 4 ranks
rank 0: 3 blocks, 35.9k cells (27.8%)
rank 1: 4 blocks, 45.4k cells (35.2%)
rank 2: 2 blocks, 23.8k cells (18.5%)
rank 3: 2 blocks, 23.8k cells (18.5%)
imbalance: 66.9%The CLI and the script write the same bytes for all nine files.
4. Compare the two routes
With the near-body grid first in both, the merged .grd of the two routes is the same file. The other two differ:
cc.par: besides the z0 faces of the background, only the block comments differ (wall.sub0by hand,cc.sub0fromshore xall).proc.input: the merge does not re-balance; it keeps each component's ranks, balanced on its own.shore xallbalances once over all 11 blocks: imbalance 37.8 % instead of 66.9 %.
Neither is good, and no assignment can be: the background has five large blocks (31 211 and 4 × 20 355 of the 129 k cells) for four ranks, so one rank carries two of them, 40 710 cells against a mean of 32 238. Only splitting blocks helps. Split and balance plans the splits (shore balance, shore split).
What you learned
- Marker boxes from the body STL blank the background inside the body; the outward gap must be smaller than the near-body thickness.
cc.parcodes: 1 wall, 40 chimera fringe, 1–19 natural far-field codes, never negative.shore xallwrites the per-component files and the merged run of a project in one call, from one options file, and balancesproc.inputover the whole run.- The file-by-file route needs one block order for
.grd,cc.parandproc.input, and its mergedproc.inputis not re-balanced. - The flat-caps background's
z0end comes out as a wall: fix the sidecar beforeshore cc-par.