This was a request for some training material.
The challenge is to create a method to get the element break down per core when doing a distributed solve.
Note you need to solve with My Computer/Background or RSM and bring back all files (Mechanical - File - Options - Results - RSM File Manager - RSM Output Files Download - Show) and then the partial code below will use the os.walk function to get all the partial .rst files, read them and put the element ids in a dictionary that used the number of the file (file1, file2...) as the key.
def define_dpf_workflow(analysis):
import mech_dpf
import Ans.DataProcessing as dpf
import os
rstFiles = []
elemDict = {}
wd = ExtAPI.DataModel.Project.Model.Analyses[0].WorkingDir
for root, dirs, files in os.walk(wd):
for file in files:
if file.endswith('rst') and file != 'file.rst':
ExtAPI.Log.WriteMessage(file)
rstFiles.append(os.path.join(root,file))
for file in rstFiles:
model = dpf.Model(dpf.DataSources(file))
meshElems = model.Mesh.ElementIds
ekey = file.split(os.sep)[-1].split('.')[0].split('e')[-1]
elemDict[ekey] = meshElems
#ExtAPI.Log.WriteMessage('my cpu --> ' + ekey)
mech_dpf.setExtAPI(ExtAPI)
dataSource = dpf.DataSources(analysis.ResultFileName)
... here the field creation and plot will be added