ogstools.materiallib.core.material_manager module#
- class ogstools.materiallib.core.material_manager.MaterialManager[source]#
Bases:
object
Manager for material definitions loaded from a repository of YAML files.
A MaterialManager can be constructed in two ways:
From a repository directory (default): If no materials are provided, all YAML files in the given data_dir are parsed into Material objects and stored in materials_db.
From pre-filtered materials: If a dictionary of Material objects is passed via materials, the manager is created directly from these. This is typically used internally when creating filtered views.
Once constructed, a MaterialManager can: - provide access to the stored materials
filter materials according to a process schema, subdomain mapping, and/or fluid assignments
represent the filtered material set as a new MaterialManager.
Initialize a MaterialManager instance.
Parameters#
- data_dirPath | None
Directory containing the repository of material YAML files. Defaults to defs.MATERIALS_DIR. Only used if no materials are passed.
- materialsdict[str, Material] | None
Pre-loaded material dictionary. If None, materials are loaded from the repository directory. If provided, these materials are used as-is without accessing the repository (commonly from filtering).
- subdomain_idsdict[str, int] | None
Mapping of subdomain names to material IDs.
- processstr | None
Process type used for filtering, if applicable.
Notes#
If materials is None, the instance represents the full material repository loaded from the given directory.
If materials is provided, the instance represents a filtered view and does not perform any additional repository access.
- __init__(data_dir=None, materials=None, subdomain_ids=None, process=None)[source]#
Initialize a MaterialManager instance.
Parameters#
- data_dirPath | None
Directory containing the repository of material YAML files. Defaults to defs.MATERIALS_DIR. Only used if no materials are passed.
- materialsdict[str, Material] | None
Pre-loaded material dictionary. If None, materials are loaded from the repository directory. If provided, these materials are used as-is without accessing the repository (commonly from filtering).
- subdomain_idsdict[str, int] | None
Mapping of subdomain names to material IDs.
- processstr | None
Process type used for filtering, if applicable.
Notes#
If materials is None, the instance represents the full material repository loaded from the given directory.
If materials is provided, the instance represents a filtered view and does not perform any additional repository access.
- get_material(name)[source]#
Retrieve a material from the repository by name.
- Return type:
Material | None
- filter(process, subdomains, fluids=None)[source]#
Create a filtered view of the materials for a given process.
Filtering is based on: - a process schema, - subdomain assignments (mapping subdomain names to one or more material IDs), - optional fluid phase materials.
Parameters#
- processstr
The process name to filter by.
- subdomainslist[dict[str, Any]]
A list of dictionaries, each containing the material name, a subdomain name, and one or more material IDs.
- fluidsdict[str, str] | None
A dictionary mapping phase types to material names.
Returns#
- MaterialManager
A new MaterialManager instance containing only the filtered materials. This new instance does not access the repository; it reuses the already loaded Material objects.
- Return type: