Print temperatures node ids and locations using DPF inside mechanical
Erik Kostson
Member, Moderator, Employee Posts: 276
✭✭✭✭
We have a named selection (say MY_NS surface scoped) and we want to obtain and print temperatures, node ids and locations in transient thermal analysis.
0
Comments
-
There was an error rendering this rich post.
0 -
# Import DPF import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) #Get the data source (i.e. result file) analysis = ExtAPI.DataModel.Project.Model.Analyses[0] dataSource = dpf.DataSources(analysis.ResultFileName) #Create Named Selection Operator ns_op = dpf.operators.scoping.on_named_selection() ns_op.inputs.data_sources.Connect(dataSource) ns_op.inputs.requested_location.Connect('Nodal') #Name should be in all caps ns_op.inputs.named_selection_name.Connect('MY_NS') mymeshscoping = ns_op.outputs.mesh_scoping # Get node numbers for nodes in named selection mesh_data = ns_op.outputs.mesh_scoping.GetData() mesh_data.Ids # node Ids #Then, let's grab the complete mesh through: # Get complete mesh model=dpf.Model(dataSource) mesh=model.Mesh #Now we can use the info on the mesh and on the node Ids to get information on the nodes of this named selection: # time #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 f1=open("D:\\testtempssdpf.txt","w") #open file in user directory change as needed #hget results # Get information for first node in named selection for mytime in timeids: temp=0 i=0 mytemp=dpf.operators.result.temperature(time_scoping=mytime,data_sources=dataSource,mesh_scoping=mymeshscoping).outputs.fields_container.GetData()[0] temp=mytemp.Data for idd in mesh_data.Ids: node1=mesh.NodeById(idd) f1.write(str(mytime) + "," + str(idd) +","+str(temp[i])+","+ str(node1.X) + "," + str(node1.Y) +"," + str(node1.Z)+ "\n") i=i+1 f1.close() model.ReleaseStreams()
0
This discussion has been closed.