plaid.containers.features¶
Module for implementing collections of features within a Sample.
Classes¶
A container for meshes within a Sample. |
Module Contents¶
- class SampleFeatures(data: dict[float, plaid.types.CGNSTree] | None = None)[source]¶
A container for meshes within a Sample.
- Parameters:
data (dict[float, CGNSTree], optional) – A dictionary mapping time steps to CGNSTrees. Defaults to None.
- set_default_time(time: float) None[source]¶
Set the default active time. Calls the DefaultManager to set the default time.
- Parameters:
time (float) – The time to set as the default active time.
- set_default_base(base_name: str, time: float | None = None) None[source]¶
Set the default active base. Calls the DefaultManager to set the default base.
- set_default_zone_base(zone_name: str, base_name: str, time: float | None = None) None[source]¶
Set the default active zone within a base. Calls the DefaultManager to set the default zone and base.
- resolve_time(time: float | None = None) float[source]¶
Get the resolved time assignment. Calls the DefaultManager to resolve the time.
- resolve_base(base_name: str | None = None, time: float | None = None) str | None[source]¶
Get the resolved base assignment. Calls the DefaultManager to resolve the base.
- resolve_zone(zone_name: str | None = None, base_name: str | None = None, time: float | None = None) str | None[source]¶
Get the resolved zone assignment. Calls the DefaultManager to resolve the zone.
- Parameters:
- Returns:
The resolved zone name.
- Return type:
Optional[str]
- get_all_time_values() list[float][source]¶
Retrieve all time steps corresponding to the meshes, if available.
- get_all_mesh_times() list[float][source]¶
DEPRECATED: Use
get_all_time_values()instead.
- init_tree(time: float | None = None) plaid.types.CGNSTree[source]¶
Initialize a CGNS tree structure at a specified time step or create a new one if it doesn’t exist.
- Parameters:
time (float, optional) – The time step for which to initialize the CGNS tree structure. If a specific time is not provided, the method will display the tree structure for the default time step.
- Returns:
The initialized or existing CGNS tree structure for the specified time step.
- Return type:
- get_tree(time: float | None = None, only_mesh: bool = False) plaid.types.CGNSTree | None[source]¶
Retrieve the CGNS tree structure for a specified time step, if available.
- Parameters:
- Returns:
The CGNS tree structure for the specified time step if available; otherwise, returns None.
- Return type:
- set_trees(meshes: dict[float, plaid.types.CGNSTree]) None[source]¶
Set all meshes with their corresponding time step.
- add_tree(tree: plaid.types.CGNSTree, time: float | None = None, in_place: bool = True) plaid.types.CGNSTree[source]¶
Merge a CGNS tree into the tree stored at a given time.
If there is no tree at
time,treeis stored directly. Otherwise, Base nodes fromtreeare appended only when their name does not already exist in the destination tree. Bases with duplicate names are ignored and a warning is emitted.- Parameters:
tree (CGNSTree) – CGNS tree to add.
time (float, optional) – Time step at which the tree is added. If omitted, the default time resolution is used.
in_place (bool, optional) – Controls ownership of the input tree. When
True(default), the provided object may be stored/used directly. WhenFalse, the input tree is deep-copied before insertion.
- Raises:
ValueError – If
treeis an empty list.- Returns:
The resulting tree for the resolved
time.- Return type:
- get_topological_dim(base_name: str | None = None, time: float | None = None) int[source]¶
Get the topological dimension of a base node at a specific time.
- Parameters:
- Raises:
ValueError – If there is no base node with the specified base_name at the given time in this sample.
- Returns:
The topological dimension of the specified base node at the given time.
- Return type:
- get_physical_dim(base_name: str | None = None, time: float | None = None) int[source]¶
Get the physical dimension of a base node at a specific time.
- Parameters:
- Raises:
ValueError – If there is no base node with the specified base_name at the given time in this sample.
- Returns:
The topological dimension of the specified base node at the given time.
- Return type:
- init_base(topological_dim: int, physical_dim: int, base_name: str | None = None, time: float | None = None) plaid.types.CGNSNode[source]¶
Create a Base node named base_name if it doesn’t already exists.
- Parameters:
topological_dim (int) – Cell dimension, see [CGNS standard](https://pycgns.github.io/PAT/lib.html#CGNS.PAT.cgnslib.newCGNSBase).
physical_dim (int) – Ambient space dimension, see [CGNS standard](https://pycgns.github.io/PAT/lib.html#CGNS.PAT.cgnslib.newCGNSBase).
base_name (str) – If not specified, uses mesh_base_name specified in Sample initialization. Defaults to None.
time (float, optional) – The time at which to initialize the base. If a specific time is not provided, the method will display the tree structure for the default time step.
- Returns:
The created Base node.
- Return type:
- del_base(base_name: str, time: float) plaid.types.CGNSTree[source]¶
Delete a CGNS base node for a specific time.
- Parameters:
- Raises:
- Returns:
The tree at the provided time (without the deleted node)
- Return type:
- get_base_names(full_path: bool = False, unique: bool = False, time: float | None = None) list[str][source]¶
Return Base names.
- Parameters:
full_path (bool, optional) – If True, returns full paths instead of only Base names. Defaults to False.
unique (bool, optional) – If True, returns unique names instead of potentially duplicated names. Defaults to False.
time (float, optional) – The time at which to check for the Base. If a specific time is not provided, the method will display the tree structure for the default time step.
- Return type:
- has_base(base_name: str, time: float | None = None) bool[source]¶
Check if a CGNS tree contains a Base with a given name at a specified time.
- Parameters:
- Returns:
True if the CGNS tree has a Base called base_name, else return False.
- Return type:
- has_globals(time: float | None = None) bool[source]¶
Check if a CGNS tree contains globals a given name at a specified time.
- get_base(base_name: str | None = None, time: float | None = None) plaid.types.CGNSNode[source]¶
Return Base node named base_name.
If base_name is not specified, checks that there is at most one base, else raises an error.
- Parameters:
- Returns:
The Base node with the specified name or None if it is not found.
- Return type:
CGNSNode or None
- init_zone(zone_shape: plaid.types.Array, zone_type: str = CGK.Unstructured_s, zone_name: str | None = None, base_name: str | None = None, time: float | None = None) plaid.types.CGNSNode[source]¶
Initialize a new zone within a CGNS base.
- Parameters:
zone_shape (Array) – An array specifying the shape or dimensions of the zone.
zone_type (str, optional) – The type of the zone. Defaults to CGK.Unstructured_s.
zone_name (str, optional) – The name of the zone to initialize. If not provided, uses mesh_zone_name specified in Sample initialization. Defaults to None.
base_name (str, optional) – The name of the base to which the zone will be added. If not provided, the zone will be added to the currently active base. Defaults to None.
time (float, optional) – The time at which to initialize the zone. If a specific time is not provided, the method will display the tree structure for the default time step.
- Raises:
KeyError – If the specified base does not exist. You can create a base using Sample.init_base(base_name).
- Returns:
The newly initialized zone node within the CGNS tree.
- Return type:
CGLNode
- del_zone(zone_name: str, base_name: str, time: float) plaid.types.CGNSTree[source]¶
Delete a zone within a CGNS base.
- Parameters:
zone_name (str) – The name of the zone to be deleted.
base_name (str, optional) – The name of the base from which the zone will be deleted. If not provided, the zone will be deleted from the currently active base. Defaults to None.
time (float, optional) – The time step for which to delete the zone. Defaults to None.
- Raises:
- Returns:
The tree at the provided time (without the deleted node)
- Return type:
- get_zone_names(base_name: str | None = None, full_path: bool = False, unique: bool = False, time: float | None = None) list[str][source]¶
Return list of Zone names in Base named base_name with specific time.
- Parameters:
base_name (str, optional) – Name of Base where to search Zones. If not specified, checks if there is at most one Base. Defaults to None.
full_path (bool, optional) – If True, returns full paths instead of only Zone names. Defaults to False.
unique (bool, optional) – If True, returns unique names instead of potentially duplicated names. Defaults to False.
time (float, optional) – The time at which to check for the Zone. If a specific time is not provided, the method will display the tree structure for the default time step.
- Returns:
List of Zone names in Base named base_name, empty if there is none or if the Base doesn’t exist.
- Return type:
- has_zone(zone_name: str, base_name: str | None = None, time: float | None = None) bool[source]¶
Check if the CGNS tree contains a Zone with the specified name within a specific Base and time.
- Parameters:
zone_name (str) – The name of the Zone to check for.
base_name (str, optional) – The name of the Base where the Zone should be located. If not provided, the function checks all bases. Defaults to None.
time (float, optional) – The time at which to check for the Zone. If a specific time is not provided, the method will display the tree structure for the default time step.
- Returns:
True if the CGNS tree has a Zone called zone_name in a Base called base_name, else return False.
- Return type:
- get_zone(zone_name: str | None = None, base_name: str | None = None, time: float | None = None) plaid.types.CGNSNode[source]¶
Retrieve a CGNS Zone node by its name within a specific Base and time.
- Parameters:
zone_name (str, optional) – The name of the Zone node to retrieve. If not specified, checks that there is at most one zone in the base, else raises an error. Defaults to None.
base_name (str, optional) – The Base in which to seek to zone retrieve. If not specified, checks that there is at most one base, else raises an error. Defaults to None.
time (float, optional) – Time at which you want to retrieve the Zone node.
- Returns:
Returns a CGNS Zone node if found; otherwise, returns None.
- Return type:
- get_zone_type(zone_name: str | None = None, base_name: str | None = None, time: float | None = None) str[source]¶
Get the type of a specific zone at a specified time.
- Parameters:
- Raises:
KeyError – Raised when the specified zone or base does not exist. You should first create the base/zone using Sample.init_zone(zone_name, base_name).
- Returns:
The type of the specified zone as a string.
- Return type:
- get_nodal_tags(zone_name: str | None = None, base_name: str | None = None, time: float | None = None) dict[str, plaid.types.Array][source]¶
Get the nodal tags for a specified base and zone at a given time.
- Parameters:
zone_name (str, optional) – The name of the zone for which element connectivity data is requested. Defaults to None, indicating the default zone.
base_name (str, optional) – The name of the base for which element connectivity data is requested. Defaults to None, indicating the default base.
time (float, optional) – The time at which element connectivity data is requested. If a specific time is not provided, the method will display the tree structure for the default time step.
- Returns:
A dictionary where keys are nodal tags names and values are NumPy arrays containing the corresponding tag indices. The NumPy arrays have shape (num_nodal_tags).
- Return type:
- get_global(name: str, time: float | None = None) plaid.types.Array | None[source]¶
Retrieve a global array by name at a specified time.
- Parameters:
- Returns:
The global array if found, otherwise None. Returns a scalar if the array has size 1.
- Return type:
Optional[Array]
- add_global(name: str, global_array: plaid.types.Array, time: float | None = None) None[source]¶
Add or update a global array at a specified time.
- Parameters:
Note
If the “Global” base does not exist, it will be created. If an array with the same name exists, its value will be updated.
- del_global(name: str, time: float | None = None) plaid.types.Array[source]¶
Delete a global array by name at a specified time.
- Parameters:
- Raises:
KeyError – If the global array does not exist at the specified time.
- Returns:
The value of the deleted global array.
- Return type:
- get_global_names(time: float | None = None) list[str][source]¶
Return a list of all global array names at the specified time(s).
- get_nodes(zone_name: str | None = None, base_name: str | None = None, time: float | None = None) plaid.types.Array | None[source]¶
Get grid node coordinates from a specified base, zone, and time.
- Parameters:
zone_name (str, optional) – The name of the zone to search for. Defaults to None.
base_name (str, optional) – The name of the base to search for. Defaults to None.
time (float, optional) – The time value to consider when searching for the zone. If a specific time is not provided, the method will display the tree structure for the default time step.
- Raises:
TypeError – Raised if multiple <GridCoordinates> nodes are found. Only one is expected.
- Returns:
A NumPy array containing the grid node coordinates. If no matching zone or grid coordinates are found, None is returned.
- Return type:
Optional[Array]
- Seealso:
This function can also be called using get_points() or get_vertices().
- set_nodes(nodes: plaid.types.Array, zone_name: str | None = None, base_name: str | None = None, time: float | None = None) None[source]¶
Set the coordinates of nodes for a specified base and zone at a given time.
- Parameters:
nodes (Array) – A numpy array containing the new node coordinates.
zone_name (str, optional) – The name of the zone where the nodes should be updated. Defaults to None.
base_name (str, optional) – The name of the base where the nodes should be updated. Defaults to None.
time (float, optional) – The time at which the node coordinates should be updated. If a specific time is not provided, the method will display the tree structure for the default time step.
- Raises:
KeyError – Raised if the specified base or zone do not exist. You should first
create the base and zone using the Sample.init_zone(zone_name,base_name) method. –
- Seealso:
This function can also be called using set_points() or set_vertices()
- get_elements(zone_name: str | None = None, base_name: str | None = None, time: float | None = None) dict[str, plaid.types.Array][source]¶
Retrieve element connectivity data for a specified zone, base, and time.
- Parameters:
zone_name (str, optional) – The name of the zone for which element connectivity data is requested. Defaults to None, indicating the default zone.
base_name (str, optional) – The name of the base for which element connectivity data is requested. Defaults to None, indicating the default base.
time (float, optional) – The time at which element connectivity data is requested. If a specific time is not provided, the method will display the tree structure for the default time step.
- Returns:
A dictionary where keys are element type names and values are NumPy arrays representing the element connectivity data. The NumPy arrays have shape (num_elements, num_nodes_per_element), and element indices are 0-based.
- Return type:
- get_field_names(location: str = None, zone_name: str | None = None, base_name: str | None = None, time: float | None = None) list[str][source]¶
Get a set of field names associated with a specified zone, base, location, and/or time.
For each argument that is not specified, the method will search for fields in all available values for this argument.
- Parameters:
location (str, optional) – The desired grid location where to search for. Defaults to None. Possible values :
plaid.constants.CGNS_FIELD_LOCATIONSzone_name (str, optional) – The name of the zone to search for. Defaults to None.
base_name (str, optional) – The name of the base to search for. Defaults to None.
time (float, optional) – The specific time at which to search for. Defaults to None.
- Returns:
A set containing the names of the fields that match the specified criteria.
- Return type:
- get_field(name: str, location: str = 'Vertex', zone_name: str | None = None, base_name: str | None = None, time: float | None = None) plaid.types.Field[source]¶
Retrieve a field with a specified name from a given zone, base, location, and time.
- Parameters:
name (str) – The name of the field to retrieve.
location (str, optional) – The location at which to retrieve the field. Defaults to ‘Vertex’. Possible values :
plaid.constants.CGNS_FIELD_LOCATIONSzone_name (str, optional) – The name of the zone to search for. Defaults to None.
base_name (str, optional) – The name of the base to search for. Defaults to None.
time (float, optional) – The time value to consider when searching for the field. If a specific time is not provided, the method will display the tree structure for the default time step.
- Returns:
A set containing the names of the fields that match the specified criteria.
- Return type:
- add_field(name: str, field: plaid.types.Field, location: str = 'Vertex', zone_name: str | None = None, base_name: str | None = None, time: float | None = None, warning_overwrite: bool = True) None[source]¶
Add a field to a specified zone in the grid.
- Parameters:
name (str) – The name of the field to be added.
field (Field) – The field data to be added. Integer arrays with dtype
np.int32ornp.int64are automatically converted tonp.float64(with a warning) for CGNS compatibility.location (str, optional) – The grid location where the field will be stored. Defaults to ‘Vertex’. Possible values :
plaid.constants.CGNS_FIELD_LOCATIONSzone_name (str, optional) – The name of the zone where the field will be added. Defaults to None.
base_name (str, optional) – The name of the base where the zone is located. Defaults to None.
time (float, optional) – The time associated with the field. Defaults to 0.
warning_overwrite (bool, optional) – Show warning if a preexisting field is being overwritten. Defaults to True.
- Raises:
KeyError – Raised if the specified zone does not exist in the given base.
- del_field(name: str, location: str = 'Vertex', zone_name: str | None = None, base_name: str | None = None, time: float | None = None) plaid.types.CGNSTree[source]¶
Delete a field with specified name in the mesh.
- Parameters:
name (str) – The name of the field to be deleted.
location (str, optional) – The grid location where the field is stored. Defaults to ‘Vertex’. Possible values :
plaid.constants.CGNS_FIELD_LOCATIONSzone_name (str, optional) – The name of the zone from which the field will be deleted. Defaults to None.
base_name (str, optional) – The name of the base where the zone is located. Defaults to None.
time (float, optional) – The time associated with the field. Defaults to None.
- Raises:
KeyError – Raised if the specified zone or field does not exist in the given base.
- Returns:
The tree at the provided time (without the deleted node)
- Return type:
- show_tree(time: float | None = None) None[source]¶
Display the structure of the CGNS tree for a specified time.
- Parameters:
time (float, optional) – The time step for which you want to display the CGNS tree structure. Defaults to None. If a specific time is not provided, the method will display the tree structure for the default time step.