Hello there!
Recently I've moved from ye'olde Mechanical Scripts Python reader to DPF in search for more advanced post processing functionalities and improved performance. But now I'm facing issues with extracting data from large .RST (20-100GB). I'm working on a bigger ACT plugin for weld fatigue calculations, here below is only a sample of code that should extract S1 stress. It does work perfectly fine for smaller RST files (tested up to 8GB) with ~20 Result Sets.
It crashes at line "s1_fields = s1_op.outputs.fields_container.GetData()" for RST1: 28GB 84 Result Sets and RST2:100GB 512 Result Sets. For RST1 it pops up a window with Ansys Dump File, for RST2 it simply closes the window. No error messages in Log in both cases.
If I reduce the time_scoping to singe time step, it works. But when I try to iterate through the time sets, and put s1_op.inputs.time_scoping.Connect(time_scoping) inside the loop, it fails again. I guess the buffer fills up and crashes the whole environment. I wonder if the same would occur if standalone DPF was used. But at the moment, it is preferable to use DPF inside mechanical for result plotting and easier interaction with end user. Have you faced this issue before? Is there any solution to improve its performance from within Mechanical WB?
import mech_dpf
import Ans.DataProcessing as dpf
analysis_id = 0
node_Ids = [95667,95666,95665]
model = ExtAPI.DataModel.Project.Model
analysis = model.Analyses[analysis_id]
rst_path = r"{}file.rst".format(analysis.Solution.ResultFileDirectory)
# Read in RST file
dataSource = dpf.DataSources()
dataSource.ResultFilePath = rst_path
# Create result operator
s1_op = dpf.operators.result.stress_principal_1()
# Get the time data corresponding to result sets
time_provider = dpf.operators.metadata.time_freq_provider()
time_provider.inputs.data_sources.Connect(dataSource)
numSets = time_provider.outputs.time_freq_support.GetData().NumberSets
timeids = time_provider.outputs.time_freq_support.GetData().TimeFreqs.Data
result_set_ids = []
for i in range(numSets):
result_set_ids.append(i+1)
# Create time scoping operator
time_scoping = dpf.Scoping()
time_scoping.Location = dpf.locations.time_freq_sets
time_scoping.Ids = result_set_ids
# Create mesh scoping operator
mesh_scoping = dpf.Scoping()
mesh_scoping.Location = "Nodal"
mesh_scoping.Ids = node_Ids
# S1
s1_op.inputs.data_sources.Connect(dataSource)
s1_op.inputs.time_scoping.Connect(time_scoping)
s1_op.inputs.mesh_scoping.Connect(mesh_scoping)
output = {}
try:
s1_fields = s1_op.outputs.fields_container.GetData()
for set_id in result_set_ids:
output[set_id] = {}
s1_field = s1_fields[set_id - 1]
for node_Id in node_Ids:
S1 = s1_field.GetEntityDataById(node_Id)
output[set_id][node_Id] = S1
except Exception as e:
ExtAPI.Log.WriteMessage("Error: {}".format(e))