DraftContext#

class DraftContext[source]#

Bases: AbstractContextManager[DraftContext]

Context manager that tracks locally modified simulation entities/status. This should (eventually, not right now) be replacement of accessing entities directly from assets.

Properties

body_groups: EntityRegistryView#

Return the list of body groups in the draft.

Example

>>> with fl.create_draft(new_run_from=geometry) as draft:
...     draft.body_groups["body_group_1"]
...     draft.body_groups["body_group*"]
surfaces: EntityRegistryView#

Return the list of surfaces in the draft.

mirrored_body_groups: EntityRegistryView#

Return the list of mirrored body groups in the draft.

Notes

Mirrored entities are draft-only entities derived from mirror actions and stored in the draft registry.

mirrored_surfaces: EntityRegistryView#

Return the list of mirrored surfaces in the draft.

Notes

Mirrored entities are draft-only entities derived from mirror actions and stored in the draft registry.

edges: EntityRegistryView#

Return the list of edges in the draft.

volumes: EntityRegistryView#

Return the list of volumes (volume zones) in the draft.

boxes: EntityRegistryView#

Return the list of boxes in the draft.

cylinders: EntityRegistryView#

Return the list of cylinders in the draft.

imported_geometries: List#

Return the list of imported geometries in the draft.

imported_surfaces: EntityRegistryView#

Return the list of imported surfaces in the draft.

coordinate_systems: CoordinateSystemManager#

Coordinate system manager for this draft.

This is the primary user entry point to create/remove coordinate systems, define parent relationships, and assign coordinate systems to draft entities.

See also

CoordinateSystemManager

mirror: MirrorManager#

Mirror manager for this draft.

This is the primary user entry point to define mirror planes and create/remove mirrored draft-only entities derived from geometry body groups.

See also

MirrorManager

Methods

preview_selector(selector, *, return_names=True)[source]#

Preview which entities a selector would match in this draft context.

Parameters:
  • selector (EntitySelector) – The selector to preview (SurfaceSelector, EdgeSelector, VolumeSelector, or BodyGroupSelector).

  • return_names (bool, default True) – When True, returns entity names. When False, returns entity instances.

Returns:

Matched entity names or instances depending on return_names.

Return type:

list[str] or list[EntityBase]

Example

>>> import flow360 as fl
>>> geometry = fl.Geometry.from_cloud(id="...")
>>> with fl.create_draft(new_run_from=geometry) as draft:
...     selector = fl.SurfaceSelector(name="wing_surfaces").match("wing*")
...     matched = draft.preview_selector(selector)
...     print(matched)  # ['wing_upper', 'wing_lower', ...]

See also

preview_unselected

the complement – entities no selection covers.

preview_unselected(selection, *, return_names=True)[source]#

Report which entities in this draft a selection does not cover.

Catches silent under-selection: a glob matching nothing, or a name whose capitalization differs from the geometry, leaves surfaces out of every assignment without raising.

The comparison pool is every entity the selection’s kind of selector can reach, read from the configuration selector expansion itself uses. For surfaces that is Surface and MirroredSurface; imported surfaces and ghost boundaries are not selectable and never reported. The pool spans the whole draft.

Parameters:
  • selection (EntitySelection) – What counts as selected. Must name exactly one entity kind and be non-empty, since the kind is inferred from it.

  • return_names (bool, default True) – When True, returns entity names. When False, returns entity instances.

Returns:

Unselected entity names or instances depending on return_names.

Return type:

list[str] or list[EntityBase]

Example

>>> import flow360 as fl
>>> geometry = fl.Geometry.from_cloud(id="...")
>>> with fl.create_draft(new_run_from=geometry, face_grouping="faceId") as draft:
...     wheels = fl.SurfaceSelector(name="wheels").match("*rim*")
...     body = fl.SurfaceSelector(name="body").match("*body*")
...     missed = draft.preview_unselected([wheels, body])
...     if missed:
...         raise ValueError(f"No selector covers: {missed}")

See also

preview_selector

the complement – what a single selector matches.

compute_obb(entities)[source]#

Compute an oriented bounding box for selected surfaces.

Deprecated: use fl.measure.oriented_bounding_box(draft, surfaces=...).

Parameters:

entities (Surface | List[Surface] | EntityRegistryView | EntitySelector)