How to merge workflow ?

Adrien Vet
Adrien Vet Member Posts: 10
Photogenic First Comment Name Dropper
**
edited July 2023 in Structures

Hello, I wrote a python result code to plot with dpf the total stiffness energy of named selection with name "R_" + number ("R_1", "R_2", "R_3", etc...).

The user has to select his named selection in the property provider, and the plot appears as a result. My code is :

def post_started(sender, analysis):# Do not edit this line

  define_dpf_workflow(analysis)

def define_dpf_workflow(analysis):

  import mech_dpf

  import Ans.DataProcessing as dpf

  mech_dpf.setExtAPI(ExtAPI)

  # On charge nos résultats

  dataSource = dpf.DataSources(analysis.ResultFileName)

  # On charge notre modème

  model = dpf.Model(dataSource)

  R = this.GetCustomPropertyByPath("Énergie de déformation modale/Sélection").ValueString

R=model.GetNamedSelection(R)

  E = dpf.operators.result.stiffness_matrix_energy()   

  E.inputs.data_sources.Connect(dataSource)

  E.inputs.mesh_scoping.Connect(R)   

  e = dpf.operators.math.accumulate(E)

  scale = dpf.operators.math.scale()

  scale.inputs.field.Connect(E)

  scale.inputs.ponderation.Connect(0) 

  a = e.outputs.getfield().Data[0]

  E_totale = dpf.operators.math.add_constant()

  E_totale.inputs.field.Connect(scale)

  E_totale.inputs.ponderation.Connect(a)

  dpf_workflow = dpf.Workflow()

  dpf_workflow.Add([E, E_totale, e, scale])

  dpf_workflow.SetOutputContour(E_totale)

  dpf_workflow.Record('wf_energy', False)

  this.WorkflowId = dpf_workflow.GetRecordedId()


Then, I want to display all the plots "all the workflow" in on plot.

I have different possible plots and I want the python result to display all the parts in one plot. (with different colors because the stiffness energy is different for each part)

Any help could help,

Thank you

Adrien

Tagged:

Answers

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 183
    5 Answers 100 Comments Photogenic Name Dropper
    admin

    @Ramdane - can you assist here?

  • Ramdane
    Ramdane Member, Employee Posts: 13
    10 Comments Name Dropper Ansys Employee First Anniversary
    ✭✭✭

    assigned it to Varun from the mechanical post team.

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 327
    25 Answers First Anniversary 100 Comments 25 Likes
    ✭✭✭✭

    @Adrien Vet ,

    I think the general idea you need is to manually create a DPF Field object with Elemental scoping. You can then manually set the values of the Field.Data property from a list (DataList) like this:
    DataCollection = System.Collections.Generic.List[System.Double](map(System.Double, DataList))

    You can also use an existing field where you extract the energy of each element, but then simply change the Field.Data values to be whatever you want. This is just to have an operator setup an elemental field rather than do it from scratch.