32.9. Additional Metadata

Settings object methods are provided to access some additional metadata. There are a number of explicit methods and two generic methods: get_attr and get_attrs.

The following example accesses the list of allowed values for a particular state of the viscous model. All string and string list objects have an allowed_values method, which returns a list of allowed string values if such a constraint currently applies for that object or returns None otherwise.

>>> solver.setup.models.viscous.model.allowed_values()
['inviscid', 'laminar', 'k-epsilon-standard', 'k-omega-standard', 'mixing-length', 
'spalart-allmaras', 'k-kl-w', 'transition-sst', 'reynolds-stress', 'scale-adaptive-simulation', 
'detached-eddy-simulation', 'large-eddy-simulation']

This example accesses the list of zone surfaces:

>>> root.solution.report_definitions.flux["mass_flow_rate"] = {}
root.solution.report_definitions.flux[
        "mass_flow_rate"
    ].zone_names.allowed_values()
['symmetry-xyplane', 'hot-inlet', 'cold-inlet', 'outlet', 'wall-inlet', 
'wall-elbow', 'interior--elbow-fluid']

The following table contains metadata names, corresponding methods to access this metadata, whether the method can return None, applicable object types, and returned data types:

Metadata nameMethodCan return NoneType applicabilityMetadata type
is-active?is_activenoallbool
is-read-only?is_read_onlynoallbool
default-valuedefault_valueyesall primitivestype of primitive
allowed-valuesallowed_valuesyesstr, str liststr list
minminyesint, floatint or float
maxmaxyesint, floatint or float

Using the get_attr method requires knowledge of metadata names, their applicability, and the ability to interpret the raw values of the metadata. You can avoid all these issues by using the explicitly named methods. Note also that the metadata is dynamic, which means values can change based on the application state. A None value signifies that no value is currently designated for this metadata.

This simple example shows you how to use a number of these explicit metadata access methods in a single solver session:

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from pprint import pprint
>>> import_filename = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
>>> solver = pyfluent.launch_fluent(mode="solver")
>>> solver.file.read(file_type="case", file_name=import_filename)
Fast-loading...
...Done
>>> solver.setup.models.viscous.is_active()
True
>>> solver.setup.models.viscous.model.is_read_only()
False
>>> solver.setup.models.viscous.model.default_value()
>>> pprint(solver.setup.models.viscous.model.allowed_values())
['inviscid',
 'laminar',
 'k-epsilon',
 'k-omega',
 'mixing-length',
 'spalart-allmaras',
 'k-kl-w',
 'transition-sst',
 'reynolds-stress',
 'scale-adaptive-simulation',
 'detached-eddy-simulation',
 'large-eddy-simulation']
>>> solver.setup.boundary_conditions.velocity_inlet['cold-inlet'].turb_intensity.min()
0
>>> solver.setup.boundary_conditions.velocity_inlet['cold-inlet'].turb_intensity.max()
1