flow360.Project#

class Project[source]#

Bases: BaseModel

Project class containing the interface for creating and running simulations.

metadata#

Metadata of the project.

Type:

ProjectMeta

solver_version#

Version of the solver being used.

Type:

str

metadata: ProjectMeta [Required]#
project_tree: ProjectTree [Required]#
solver_version: str [Required]#
classmethod show_remote(search_keyword=None)[source]#

Shows all projects on the cloud.

Parameters:

search_keyword (str, optional)

property id: str#

Returns the ID of the project.

Returns:

The project ID.

Return type:

str

property length_unit: Annotated[_Constrained, PlainSerializer(func=_dimensioned_type_serializer, return_type=PydanticUndefined, when_used=always)]#

Returns the length unit of the project.

Returns:

The length unit.

Return type:

LengthType.Positive

property geometry: Geometry#

Returns the geometry asset of the project. There is always only one geometry asset per project.

Raises:

Flow360ValueError โ€“ If the geometry asset is not available for the project.

Returns:

The geometry asset.

Return type:

Geometry

get_surface_mesh(asset_id=None)[source]#

Returns the surface mesh asset of the project.

Parameters:

asset_id (str, optional) โ€“ The ID of the asset from among the generated assets in this project instance. If not provided, the property contains the most recently run asset.

Raises:

Flow360ValueError โ€“ If the surface mesh asset is not available for the project.

Returns:

The surface mesh asset.

Return type:

SurfaceMeshV2

property surface_mesh#

Returns the last used surface mesh asset of the project.

Raises:

Flow360ValueError โ€“ If the surface mesh asset is not available for the project.

Returns:

The surface mesh asset.

Return type:

SurfaceMeshV2

get_volume_mesh(asset_id=None)[source]#

Returns the volume mesh asset of the project.

Parameters:

asset_id (str, optional) โ€“ The ID of the asset from among the generated assets in this project instance. If not provided, the property contains the most recently run asset.

Raises:

Flow360ValueError โ€“ If the volume mesh asset is not available for the project.

Returns:

The volume mesh asset.

Return type:

VolumeMeshV2

property volume_mesh#

Returns the last used volume mesh asset of the project.

Raises:

Flow360ValueError โ€“ If the volume mesh asset is not available for the project.

Returns:

The volume mesh asset.

Return type:

VolumeMeshV2

get_case(asset_id=None)[source]#

Returns the last used case asset of the project.

Parameters:

asset_id (str, optional) โ€“ The ID of the asset from among the generated assets in this project instance. If not provided, the property contains the most recently run asset.

Raises:

Flow360ValueError โ€“ If the case asset is not available for the project.

Returns:

The case asset.

Return type:

Case

property case#

Returns the case asset of the project.

Raises:

Flow360ValueError โ€“ If the case asset is not available for the project.

Returns:

The case asset.

Return type:

Case

get_surface_mesh_ids()[source]#

Returns the available IDs of surface meshes in the project

Returns:

An iterable of asset IDs.

Return type:

Iterable[str]

get_volume_mesh_ids()[source]#

Returns the available IDs of volume meshes in the project

Returns:

An iterable of asset IDs.

Return type:

Iterable[str]

get_case_ids()[source]#

Returns the available IDs of cases in the project

Returns:

An iterable of asset IDs.

Return type:

Iterable[str]

classmethod from_geometry(files, /, name=None, solver_version='release-25.5', length_unit='m', tags=None, run_async=False)[source]#

Initializes a project from local geometry files.

Parameters:
  • files (Union[str, list[str]] (positional argument only)) โ€“ Geometry file paths.

  • name (str, optional) โ€“ Name of the project (default is None).

  • solver_version (str, optional) โ€“ Version of the solver (default is None).

  • length_unit (LengthUnitType, optional) โ€“ Unit of length (default is โ€œmโ€).

  • tags (list of str, optional) โ€“ Tags to assign to the project (default is None).

  • run_async (bool, optional) โ€“ Whether to create project asynchronously (default is False).

Returns:

An instance of the project. Or Project ID when run_async is True.

Return type:

Project

Raises:

Flow360FileError โ€“ If the project cannot be initialized from the file.

Example

>>> my_project = fl.Project.from_geometry(
...     "/path/to/my/geometry/my_geometry.csm",
...     name="My_Project_name",
...     solver_version="release-Major.Minor"
...     length_unit="cm"
...     tags=["Quarter 1", "Revision 2"]
... )
====
classmethod from_surface_mesh(file, /, name=None, solver_version='release-25.5', length_unit='m', tags=None, run_async=False)[source]#

Initializes a project from a local surface mesh file.

Parameters:
  • file (str (positional argument only)) โ€“ Surface mesh file path. For UGRID file the mapbc file needs to be renamed with the same prefix under same folder.

  • name (str, optional) โ€“ Name of the project (default is None).

  • solver_version (str, optional) โ€“ Version of the solver (default is None).

  • length_unit (LengthUnitType, optional) โ€“ Unit of length (default is โ€œmโ€).

  • tags (list of str, optional) โ€“ Tags to assign to the project (default is None).

  • run_async (bool, optional) โ€“ Whether to create project asynchronously (default is False).

Returns:

An instance of the project. Or Project ID when run_async is True.

Return type:

Project

Raises:

Flow360FileError โ€“ If the project cannot be initialized from the file.

Example

>>> my_project = fl.Project.from_surface_mesh(
...     "/path/to/my/mesh/my_mesh.ugrid",
...     name="My_Project_name",
...     solver_version="release-Major.Minor"
...     length_unit="inch"
...     tags=["Quarter 1", "Revision 2"]
... )
====
classmethod from_volume_mesh(file, /, name=None, solver_version='release-25.5', length_unit='m', tags=None, run_async=False)[source]#

Initializes a project from a local volume mesh file.

Parameters:
  • file (str (positional argument only)) โ€“ Volume mesh file path. For UGRID file the mapbc file needs to be renamed with the same prefix under same folder.

  • name (str, optional) โ€“ Name of the project (default is None).

  • solver_version (str, optional) โ€“ Version of the solver (default is None).

  • length_unit (LengthUnitType, optional) โ€“ Unit of length (default is โ€œmโ€).

  • tags (list of str, optional) โ€“ Tags to assign to the project (default is None).

  • run_async (bool, optional) โ€“ Whether to create project asynchronously (default is False).

Returns:

An instance of the project.

Return type:

Project

Raises:

Flow360FileError โ€“ If the project cannot be initialized from the file. Or Project ID when run_async is True.

Example

>>> my_project = fl.Project.from_volume_mesh(
...     "/path/to/my/mesh/my_mesh.cgns",
...     name="My_Project_name",
...     solver_version="release-Major.Minor"
...     length_unit="inch"
...     tags=["Quarter 1", "Revision 2"]
... )
====
classmethod from_file(file, name=None, solver_version='release-25.5', length_unit='m', tags=None, run_async=False)[source]#

[Deprecated function] Initializes a project from a file.

Parameters:
  • file (str) โ€“ Path to the file.

  • name (str, optional) โ€“ Name of the project (default is None).

  • solver_version (str, optional) โ€“ Version of the solver (default is None).

  • length_unit (LengthUnitType, optional) โ€“ Unit of length (default is โ€œmโ€).

  • tags (list of str, optional) โ€“ Tags to assign to the project (default is None).

  • run_async (bool, optional) โ€“ Whether to create project asynchronously (default is False).

Returns:

An instance of the project. Or Project ID when run_async is True.

Return type:

Project

Raises:

Flow360ValueError โ€“ If the project cannot be initialized from the file.

classmethod from_cloud(project_id, *, new_run_from=None)[source]#

Loads a project from the cloud.

Parameters:
  • project_id (str) โ€“ ID of the project.

  • new_run_from (Optional[Union[Geometry, SurfaceMeshV2, VolumeMeshV2, Case]]) โ€“

    The cloud resource that the current run should be based on. The root asset will use entity settings (grouping, transformation etc) from this resource. This results in the same behavior when user clicks New run on webUI. By default this will be the root asset (what user uploaded) of the project.

    TODO: We can add โ€˜lastโ€™ as one option to automatically start from the latest created asset within the project.

Returns:

An instance of the project.

Return type:

Project

Raises:
  • Flow360WebError โ€“ If the project cannot be loaded from the cloud.

  • Flow360ValueError โ€“ If the root asset cannot be retrieved for the project.

refresh_project_tree()[source]#

Refresh the local project tree by fetching the latest project tree from cloud.

print_project_tree(line_width=30, is_horizontal=True)[source]#

Print the project tree to the terminal.

Parameters:
  • line_width (str) โ€“ The maximum number of characters in each line.

  • is_horizontal (bool) โ€“ Choose if the project tree is printed in horizontal (default) or vertical direction.

generate_surface_mesh(params, name='SurfaceMesh', run_async=True, solver_version=None, use_beta_mesher=None, raise_on_error=False, **kwargs)[source]#

Runs the surface mesher for the project.

Parameters:
  • params (SimulationParams) โ€“ Simulation parameters for running the mesher.

  • name (str, optional) โ€“ Name of the surface mesh (default is โ€œSurfaceMeshโ€).

  • run_async (bool, optional) โ€“ Whether to run the mesher asynchronously (default is True).

  • solver_version (str, optional) โ€“ Optional solver version to use during this run (defaults to the project solver version)

  • use_beta_mesher (bool, optional) โ€“ Whether to use the beta mesher (default is None). Must be True when using Geometry AI.

  • raise_on_error (bool, optional) โ€“ Option to raise if submission error occurs (default is False)

Raises:

Flow360ValueError โ€“ If the root item type is not Geometry.

generate_volume_mesh(params, name='VolumeMesh', run_async=True, solver_version=None, use_beta_mesher=None, raise_on_error=False, **kwargs)[source]#

Runs the volume mesher for the project.

Parameters:
  • params (SimulationParams) โ€“ Simulation parameters for running the mesher.

  • name (str, optional) โ€“ Name of the volume mesh (default is โ€œVolumeMeshโ€).

  • run_async (bool, optional) โ€“ Whether to run the mesher asynchronously (default is True).

  • solver_version (str, optional) โ€“ Optional solver version to use during this run (defaults to the project solver version)

  • use_beta_mesher (bool, optional) โ€“ Whether to use the beta mesher (default is None). Must be True when using Geometry AI.

  • raise_on_error (bool, optional) โ€“ Option to raise if submission error occurs (default is False)

Raises:

Flow360ValueError โ€“ If the root item type is not Geometry.

run_case(params, name='Case', run_async=True, fork_from=None, interpolate_to_mesh=None, solver_version=None, use_beta_mesher=None, raise_on_error=False, **kwargs)[source]#

Runs a case for the project.

Parameters:
  • params (SimulationParams) โ€“ Simulation parameters for running the case.

  • name (str, optional) โ€“ Name of the case (default is โ€œCaseโ€).

  • run_async (bool, optional) โ€“ Whether to run the case asynchronously (default is True).

  • fork_from (Case, optional) โ€“ Which Case we should fork from (if fork).

  • interpolate_to_mesh (VolumeMeshV2, optional) โ€“ If specified, forked case will interpolate parent case results to this mesh before running solver.

  • solver_version (str, optional) โ€“ Optional solver version to use during this run (defaults to the project solver version)

  • use_beta_mesher (bool, optional) โ€“ Whether to use the beta mesher (default is None). Must be True when using Geometry AI.

  • raise_on_error (bool, optional) โ€“ Option to raise if submission error occurs (default is False)

__init__(**data)#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

Return type:

None

__new__(**kwargs)#
classmethod construct(_fields_set=None, **values)#
Parameters:
Return type:

Model

copy(*, include=None, exclude=None, update=None, deep=False)#

Returns a copy of the model.

!!! warning โ€œDeprecatedโ€

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`py data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Parameters:
  • include (AbstractSetIntStr | MappingIntStrAny | None) โ€“ Optional set or mapping specifying which fields to include in the copied model.

  • exclude (AbstractSetIntStr | MappingIntStrAny | None) โ€“ Optional set or mapping specifying which fields to exclude in the copied model.

  • update (Dict[str, Any] | None) โ€“ Optional dictionary of field-value pairs to override field values in the copied model.

  • deep (bool) โ€“ If True, the values of fields that are Pydantic models will be deep-copied.

  • self (Model)

Returns:

A copy of the model with included, excluded and updated fields as specified.

Return type:

Model

dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)#
Parameters:
Return type:

Dict[str, Any]

classmethod from_orm(obj)#
Parameters:

obj (Any)

Return type:

Model

json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)#
Parameters:
Return type:

str

classmethod model_construct(_fields_set=None, **values)#

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == โ€˜allowโ€™, then all extra passed values are added to the model instanceโ€™s __dict__ and __pydantic_extra__ fields. If model_config.extra == โ€˜ignoreโ€™ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == โ€˜forbidโ€™ does not result in an error if extra values are passed, but they will be ignored.

Parameters:
  • _fields_set (set[str] | None) โ€“ The set of field names accepted for the Model instance.

  • values (Any) โ€“ Trusted or pre-validated data dictionary.

Returns:

A new instance of the Model class with validated data.

Return type:

Model

model_copy(*, update=None, deep=False)#

Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#model_copy

Returns a copy of the model.

Parameters:
  • update (dict[str, Any] | None) โ€“ Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.

  • deep (bool) โ€“ Set to True to make a deep copy of the model.

  • self (Model)

Returns:

New model instance.

Return type:

Model

model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, serialize_as_any=False)#

Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#modelmodel_dump

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • mode (Literal['json', 'python'] | str) โ€“ The mode in which to_python should run. If mode is โ€˜jsonโ€™, the output will only contain JSON serializable types. If mode is โ€˜pythonโ€™, the output may contain non-JSON-serializable Python objects.

  • include (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) โ€“ A set of fields to include in the output.

  • exclude (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) โ€“ A set of fields to exclude from the output.

  • context (dict[str, Any] | None) โ€“ Additional context to pass to the serializer.

  • by_alias (bool) โ€“ Whether to use the fieldโ€™s alias in the dictionary key if defined.

  • exclude_unset (bool) โ€“ Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) โ€“ Whether to exclude fields that are set to their default value.

  • exclude_none (bool) โ€“ Whether to exclude fields that have a value of None.

  • round_trip (bool) โ€“ If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (bool | Literal['none', 'warn', 'error']) โ€“ How to handle serialization errors. False/โ€noneโ€ ignores them, True/โ€warnโ€ logs errors, โ€œerrorโ€ raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • serialize_as_any (bool) โ€“ Whether to serialize fields with duck-typing serialization behavior.

Returns:

A dictionary representation of the model.

Return type:

dict[str, Any]

model_dump_json(*, indent=None, include=None, exclude=None, context=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, serialize_as_any=False)#

Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#modelmodel_dump_json

Generates a JSON representation of the model using Pydanticโ€™s to_json method.

Parameters:
  • indent (int | None) โ€“ Indentation to use in the JSON output. If None is passed, the output will be compact.

  • include (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) โ€“ Field(s) to include in the JSON output.

  • exclude (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) โ€“ Field(s) to exclude from the JSON output.

  • context (dict[str, Any] | None) โ€“ Additional context to pass to the serializer.

  • by_alias (bool) โ€“ Whether to serialize using field aliases.

  • exclude_unset (bool) โ€“ Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) โ€“ Whether to exclude fields that are set to their default value.

  • exclude_none (bool) โ€“ Whether to exclude fields that have a value of None.

  • round_trip (bool) โ€“ If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (bool | Literal['none', 'warn', 'error']) โ€“ How to handle serialization errors. False/โ€noneโ€ ignores them, True/โ€warnโ€ logs errors, โ€œerrorโ€ raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • serialize_as_any (bool) โ€“ Whether to serialize fields with duck-typing serialization behavior.

Returns:

A JSON string representation of the model.

Return type:

str

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to โ€œallowโ€.

property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation')#

Generates a JSON schema for a model class.

Parameters:
  • by_alias (bool) โ€“ Whether to use attribute aliases or not.

  • ref_template (str) โ€“ The reference template.

  • schema_generator (type[GenerateJsonSchema]) โ€“ To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) โ€“ The mode in which to generate the schema.

Returns:

The JSON schema for the given model class.

Return type:

dict[str, Any]

classmethod model_parametrized_name(params)#

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Parameters:

params (tuple[type[Any], ...]) โ€“ Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError โ€“ Raised when trying to generate concrete names for non-generic models.

Return type:

str

model_post_init(__context)#

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since thatโ€™s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) โ€“ The BaseModel instance.

  • __context (Any) โ€“ The context.

Return type:

None

classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)#

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters:
  • force (bool) โ€“ Whether to force the rebuilding of the model schema, defaults to False.

  • raise_errors (bool) โ€“ Whether to raise errors, defaults to True.

  • _parent_namespace_depth (int) โ€“ The depth level of the parent namespace, defaults to 2.

  • _types_namespace (dict[str, Any] | None) โ€“ The types namespace, defaults to None.

Returns:

Returns None if the schema is already โ€œcompleteโ€ and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

Return type:

bool | None

classmethod model_validate(obj, *, strict=None, from_attributes=None, context=None)#

Validate a pydantic model instance.

Parameters:
  • obj (Any) โ€“ The object to validate.

  • strict (bool | None) โ€“ Whether to enforce types strictly.

  • from_attributes (bool | None) โ€“ Whether to extract data from object attributes.

  • context (dict[str, Any] | None) โ€“ Additional context to pass to the validator.

Raises:

ValidationError โ€“ If the object could not be validated.

Returns:

The validated model instance.

Return type:

Model

classmethod model_validate_json(json_data, *, strict=None, context=None)#

Usage docs: https://docs.pydantic.dev/2.7/concepts/json/#json-parsing

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) โ€“ The JSON data to validate.

  • strict (bool | None) โ€“ Whether to enforce types strictly.

  • context (dict[str, Any] | None) โ€“ Extra variables to pass to the validator.

Returns:

The validated Pydantic model.

Raises:

ValueError โ€“ If json_data is not a JSON string.

Return type:

Model

classmethod model_validate_strings(obj, *, strict=None, context=None)#

Validate the given object contains string data against the Pydantic model.

Parameters:
  • obj (Any) โ€“ The object contains string data to validate.

  • strict (bool | None) โ€“ Whether to enforce types strictly.

  • context (dict[str, Any] | None) โ€“ Extra variables to pass to the validator.

Returns:

The validated Pydantic model.

Return type:

Model

classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Parameters:
  • path (str | Path)

  • content_type (str | None)

  • encoding (str)

  • proto (DeprecatedParseProtocol | None)

  • allow_pickle (bool)

Return type:

Model

classmethod parse_obj(obj)#
Parameters:

obj (Any)

Return type:

Model

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Parameters:
  • b (str | bytes)

  • content_type (str | None)

  • encoding (str)

  • proto (DeprecatedParseProtocol | None)

  • allow_pickle (bool)

Return type:

Model

classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
Parameters:
  • by_alias (bool)

  • ref_template (str)

Return type:

Dict[str, Any]

classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#
Parameters:
  • by_alias (bool)

  • ref_template (str)

  • dumps_kwargs (Any)

Return type:

str

classmethod update_forward_refs(**localns)#
Parameters:

localns (Any)

Return type:

None

classmethod validate(value)#
Parameters:

value (Any)

Return type:

Model