flow360.Project#
- class Project[source]#
Bases:
BaseModel
Project class containing the interface for creating and running simulations.
- metadata#
Metadata of the project.
- Type:
ProjectMeta
- metadata: ProjectMeta [Required]#
- project_tree: ProjectTree [Required]#
- classmethod show_remote(search_keyword=None)[source]#
Shows all projects on the cloud.
- Parameters:
search_keyword (str, optional)
- 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:
- 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:
- 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:
- 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:
- 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:
- 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.
- 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)#
- 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)#
- 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)#
- 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.
- model_copy(*, update=None, deep=False)#
Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#model_copy
Returns a copy of the 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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.
- classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
- classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
- classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
- classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#