Filter Field Data

This code filter Field data based on a min/max threshold. Before running the code, define

path = r’path to rst file’

Transparent

import ansys.dpf.core as dpf
import numpy as np
############################################### user input
path = r"C:\temp\test_filter_files\dp0\SYS\MECH\file.rst"

model = dpf.Model(path)
opNamedSel = dpf.operators.scoping.on_named_selection() 
opNamedSel.inputs.named_selection_name.connect("MYBODY")
opNamedSel.inputs.requested_location.connect("Elemental")
opNamedSel.inputs.data_sources.connect(model)
original_stress_field = dpf.operators.result.stress_von_mises(
    data_sources = model,
    mesh_scoping = opNamedSel,
    requested_location = 'Nodal').outputs.fields_container()[0]
len(original_stress_field.data)
min(original_stress_field.data)
max(original_stress_field.data)
filtered_stress_field = dpf.operators.filter.field_band_pass(
    field = original_stress_field,
    min_threshold = 0.1,
    max_threshold = 4.0,
).outputs.field()
len(filtered_stress_field.data)
min(filtered_stress_field.data)
max(filtered_stress_field.data)