Write a multi-component Xall run
An overset case is several independent grids, a near-body grid per body and a background, that Xall reads as one block list. SHORE keeps each grid as a component of one project and writes the merged run in one step; the *-merge commands do the same from separate files.
The code is examples/cookbook/multi_component.py (about 10 s, most of it the marker boxes).
Build the components in one project
shapes.sphere(radius=1.0, subdivisions=4).export("sphere.stl")
p = Project()
p.load_geometry("sphere.stl")
p.build_topology("cubed_sphere", nk=17, ds=1e-2, growth=1.15, ni=33, nj=64,
theta_cap=np.deg2rad(35.0)) # fmt: skip
p.march() # outer shell near r = 1.55
p.use_component("background")
p.build_primitive("flat_caps", r_out=4.0, z0=-4.0, z1=4.0, ni=9, nc=17, nk=33)
p.save("case.shore")
print({name: len(mesh.blocks) for name, mesh in p.components.items()}){'main': 6, 'background': 5}use_component(name)makesnamecurrent, creating it if new; every build command acts on the current component. The first one ismain.- From the CLI,
--project DIR --component NAMEonshore mesh,shore collarandshore primitive ...adds a component to a saved project (see Save, load, replay). - Each component keeps its own k-schedule and its own block labels; the labels only have to be unique within a component.
Write the run with an options file
The options file sets run-wide cc.par header values under [run] and per-component values under [components.<name>]:
# Marker boxes that cut the hole in the background (hole cutting is Xall's job).
boxes = boxes_from_stl("sphere.stl", "sub0", max_outward_gap=0.2)
Path("boxes.json").write_text(json.dumps([box_to_json(b) for b in boxes]))
Path("xall.toml").write_text("""\
[run]
grd = "run.grd"
np = 8
[components.main]
body = 1
boxes = "boxes.json"
[components.background]
free_face_bc = 9
""")
print(f"{len(boxes)} marker boxes")shore xall case.shore --out run --options xall.toml✓ Wrote the Xall run of ['main', 'background'] to runThe Python call takes the same options as keyword arguments; it writes the same files byte for byte:
p.write_xall(
"run",
grd="run.grd",
np=8,
components={
"main": {"body": 1, "boxes": [box_to_json(b) for b in boxes]},
"background": {"free_face_bc": 9},
},
)
print(sorted(str(f) for f in Path("run").iterdir()))['run/background', 'run/cc.par', 'run/main', 'run/proc.input', 'run/run.grd']| Key | Where | Default | Meaning |
|---|---|---|---|
grd | [run] | mesh.grd | merged grid file name |
np | [run] | 1 | MPI ranks of proc.input, balanced over the merged grid |
output_basename, multigrid_levels, boundary_layer_thickness, numerical_beach | [run] | cc., [4, 1], -0.1, -1.0 | cc.par header, one for the run |
free_face_bc | component | 40 | cc.par code of its FREE faces: 40 chimera, a natural BC (1–19) for a far field, e.g. 9 extrapolation |
body | component | 0 | Xall body number of all its blocks in proc.input |
boxes | component | none | marker boxes, a JSON file from shore boxes-from-stl (relative to the options file) |
meta.<block> | component | per-block level, group, priority, comment, free_face_bc | |
proc_meta.<block> | component | per-block proc, group, body in proc.input |
run/<component>/holds each component's.geofiles, adjacency sidecar,.grdandcc.par;run/holds the mergedrun.grd,cc.parand oneproc.input.- Components are merged in creation order. Unknown keys, unknown components or block labels, and components without a mesh are errors, reported before anything is written.
shore xallrequires--out.
Background primitives (box, annulus, flat_caps) have no wall: every face that is not a seam is FREE, so free_face_bc sets all their boundary codes (ADR 0055).
Merge separate component files
When the components come from separate runs, merge their files with the same input order in all three commands:
shore grd-merge main.grd background.grd -o run.grd
shore cc-par-merge main.cc.par background.cc.par -o cc.par --grd run.grd
shore proc-input run.grd proc.input --np 8✓ Wrote run.grd (2 inputs merged)
✓ Wrote cc.par (2 inputs merged)
✓ Wrote proc.input
...
imbalance: 0.0%grd-mergeconcatenates the block payloads byte for byte and rewrites the block count. The result here is identical torun/run.grd.cc-par-mergeshifts block and patch indices of the later inputs and prefixes each block comment with its input's stem (main.sub0,background.center). Header fields come from the first input; a disagreement is a warning.shore proc-inputon the merged.grdbalances all blocks together.shore proc-input-mergeinstead concatenates per-componentproc.inputfiles without re-balancing: two components each balanced on their own ranks pile onto the same low ranks (150 % imbalance for this case, 6 + 2 ranks merged). Use it only when you assigned the ranks yourself.
See also
- Chimera grids and Marker boxes.
- Chimera assembly and Xall bundle: the same workflow told end to end.
- Split and balance: more blocks for more ranks.
- ADR 0016, ADR 0017, ADR 0018.
- CLI:
shore xall,shore grd-merge,shore cc-par-merge,shore proc-input-merge,shore boxes-from-stl. - API:
Project.write_xall.