Insert 1
import numpy """ Get the summation of element nodal forces """ #Index for the analysis in the tree AnalysisIndex = 0 #Time steps (not the actual time) you want to calculate ENFO TimeSteps = [1,2] #A named selection should be in the tree that is for elements. This is its name. ElemNsName ="My Elements for ENFO" import mech_dpf import Ans.DataProcessing as dpf Analysis = ExtAPI.DataModel.Project.Model.Analyses[AnalysisIndex] DataSource = dpf.DataSources(Analysis.ResultFileName) #Get the results file mesh op = dpf.operators.mesh.mesh_provider() op.inputs.data_sources.Connect(DataSource) RstMesh = op.outputs.mesh.GetData() #Get the mesh for the selected elements by named selection name ElemIds = ExtAPI.DataModel.GetObjectsByName(ElemNsName)[0].Ids ElemScoping = dpf.MeshScopingFactory.ElementalScoping(ElemIds) op = dpf.operators.mesh.from_scoping() # operator instantiation op.inputs.scoping.Connect(ElemScoping) op.inputs.mesh.Connect(RstMesh) ElemMesh = op.outputs.mesh.GetData() TimeScoping = dpf.TimeFreqScopingFactory.ScopingByLoadSteps(TimeSteps) ENFO_Op = dpf.operators.result.element_nodal_forces() # operator instantiation ENFO_Op.inputs.data_sources.Connect(DataSource) ENFO_Op.inputs.time_scoping.Connect(TimeScoping) ENFO_Op.inputs.bool_rotate_to_global.Connect(True) ENFO_Op.inputs.mesh.Connect(ElemMesh) ENFO_Op.inputs.requested_location.Connect(dpf.locations.nodal) ENFO_FC=ENFO_Op.outputs.fields_container.GetData() SummedENFO_FCs = [] for i in range(3): ComponentOp = dpf.operators.logic.component_selector_fc() ComponentOp.inputs.fields_container.Connect(ENFO_FC) ComponentOp.inputs.component_number.Connect(i) SumOp = dpf.operators.math.accumulate_fc() # operator instantiation SumOp.inputs.fields_container.Connect(ComponentOp) SummedFC = SumOp.outputs.fields_container.GetData() SummedENFO_FCs.append(SummedFC)
SummedENFO_FCs.append(SummedFC)
Insert 2
#Index for the analysis in the tree AnalysisIndex = 0 #Time steps (not the actual time) you want to calculate ENFO TimeSteps = [1,2] #A named selection should be in the tree that is for elements. This is its name. ElemNsName ="My Elements for ENFO" import mech_dpf import Ans.DataProcessing as dpf Analysis = ExtAPI.DataModel.Project.Model.Analyses[AnalysisIndex] DataSource = dpf.DataSources(Analysis.ResultFileName) #Get the results file mesh op = dpf.operators.mesh.mesh_provider() op.inputs.data_sources.Connect(DataSource) RstMesh = op.outputs.mesh.GetData() #Get the mesh for the selected elements by named selection name ElemIds = ExtAPI.DataModel.GetObjectsByName(ElemNsName)[0].Ids ElemScoping = dpf.MeshScopingFactory.ElementalScoping(ElemIds) op = dpf.operators.mesh.from_scoping() # operator instantiation op.inputs.scoping.Connect(ElemScoping) op.inputs.mesh.Connect(RstMesh) ElemMesh = op.outputs.mesh.GetData() TimeScoping = dpf.TimeFreqScopingFactory.ScopingByLoadSteps(TimeSteps) ENFO_Op = dpf.operators.result.element_nodal_forces() # operator instantiation ENFO_Op.inputs.data_sources.Connect(DataSource) ENFO_Op.inputs.time_scoping.Connect(TimeScoping) ENFO_Op.inputs.bool_rotate_to_global.Connect(True) ENFO_Op.inputs.mesh.Connect(ElemMesh) ENFO_Op.inputs.requested_location.Connect(dpf.locations.nodal) ENFO_FC=ENFO_Op.outputs.fields_container.GetData() SummedENFO_FCs = [] for i in range(3): ComponentOp = dpf.operators.logic.component_selector_fc() ComponentOp.inputs.fields_container.Connect(ENFO_FC) ComponentOp.inputs.component_number.Connect(i) SumOp = dpf.operators.math.accumulate_fc() # operator instantiation SumOp.inputs.fields_container.Connect(ComponentOp) SummedFC = SumOp.outputs.fields_container.GetData() SummedENFO_FCs.append(SummedFC)
@dataclass class ValueCollection: a: int b: str c: float d: tuple[int, int] e: str @property def f(self): return self.a + self.c values = [] for aa, bb, cc, dd, ee in zip(a, b, c, d, e): vc = ValueCollection(aa, bb, cc, dd, ee) values.append(vc)
Testing qouted posts by trolls…
new comment