How to calculate Centroids of a volume mesh using DPF?
Ayush Kumar
Member, Moderator, Employee Posts: 442
✭✭✭✭
Comments
-
import mech_dpf import Ans.DataProcessing as dpf # ACT Mesh mesh = ExtAPI.DataModel.MeshDataByName('Global') # Convert to DPF Mesh mesh_op = dpf.operators.mesh.acmo_mesh_provider() mesh_op.inputs.assembly_mesh.Connect(dpf.AnsDispatchHolder(mesh.InternalObject)) dpf_mesh = mesh_op.outputs.getmeshes_container()[0] # Element volume el_vol = dpf.operators.geo.elements_volume(mesh=dpf_mesh) # Get nodes n_coord = dpf.operators.mesh.node_coordinates(mesh=dpf_mesh) # Integrate coordinates over element volume vol_int = dpf.operators.geo.integrate_over_elements(field=n_coord, mesh=dpf_mesh) # Select Components vol_int_x = dpf.operators.logic.component_selector(field=vol_int, component_number=0) vol_int_y = dpf.operators.logic.component_selector(field=vol_int, component_number=1) vol_int_z = dpf.operators.logic.component_selector(field=vol_int, component_number=2) # Get centroid fields cent_x = dpf.operators.math.component_wise_divide(fieldA=vol_int_x, fieldB=el_vol) cent_f_x = cent_x.outputs.field.GetData() cent_y = dpf.operators.math.component_wise_divide(fieldA=vol_int_y, fieldB=el_vol) cent_f_y = cent_y.outputs.field.GetData() cent_z = dpf.operators.math.component_wise_divide(fieldA=vol_int_z, fieldB=el_vol) cent_f_z = cent_z.outputs.field.GetData()
0