How do I obtain displacement results in a cylindrical coordinate system during a cyclic symmetric an

Options
Sascha Hell
Sascha Hell Member, Employee Posts: 11
First Anniversary 5 Likes Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

How do I obtain displacement results in a cylindrical coordinate system during a cyclic symmetric analysis using DPF?

Tagged:

Answers

  • Sascha Hell
    Sascha Hell Member, Employee Posts: 11
    First Anniversary 5 Likes Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options
    def define_dpf_workflow(analysis):
        import mech_dpf
        import Ans.DataProcessing as dpf
        
        ####set up the file paths
        ExtAPI.Log.WriteMessage(analysis.WorkingDir + 'file.rst')
        ExtAPI.Log.WriteMessage('Load Datasources rst')
        data_sources = dpf.DataSources(r'' + analysis.WorkingDir + 'file.rst')
        
        model = dpf.Model(data_sources)             # MODEL is new entity that allows to access results and metadata (mesh, timeFreqSupport, etc.), not documented yet...
        # model.ResultInfo                            # gives info on Analysis type, unit system and available result quantities
        meshProviders = model.MeshProvider          # Provide mesh and cure degenerated elements
        meshProviders.inputs.read_cyclic.Connect(2) # Cyclic Expansion of Results, 1=off, 2=on
        
        ### Result Set Scoping
        timeScop = dpf.Scoping()
        timeScop.Ids = [1]
        
        ### Results operator: Displacements
        u = model.results.displacement()            # Initialize operator
        u.inputs.time_scoping.Connect(timeScop)     # Select Result Set
        u.inputs.read_cyclic.Connect(2)             # Cyclic Expansion of Results, 1=off, 2=on
        #u.inputs.bool_rotate_to_global.Connect(False)# keep stress in solution coordinate sys
        
        # Create cylindrical CS
        xAxis = [1.,0.,0.]
        yAxis = [0.,1.,0.]
        zAxis = [0.,0.,1.]
        origi = [0.,0.,0.]
        cylDataInput = [xAxis[0],yAxis[0],zAxis[0],
                        xAxis[1],yAxis[1],zAxis[1],
                        xAxis[2],yAxis[2],zAxis[2],
                        origi[0],origi[1],origi[2]]
        cylCS= dpf.FieldsFactory.CreateVectorField(12,1) # create field to host CS data
        cylCS.Data=cylDataInput
        
        # Convert from Cartesian to Cylindrical
        u_cyl = dpf.operators.geo.rotate_in_cylindrical_cs_fc() # operator instanciation
        u_cyl.inputs.field.Connect(u)                  # field to be transformed
        u_cyl.inputs.coordinate_system.Connect(cylCS)  # cylindrical coordinate system
        #u_cyl_field = u_cyl.outputs.fields_container.GetData()
        
        ### Logic operator for vector component selection: 
        u_comp = dpf.operators.logic.component_selector_fc() # Operator instanciation
        u_comp.Connect(0,u_cyl)   # use stress operator to provide input
        u_comp.Connect(1,0)       # select component: 0-X, 1-Y, 2-Z
        #u_comp_field = u_comp.outputs.fields_container.GetData()
        
        ### Define Workflow for Execution
        dpf_workflow = dpf.Workflow()
        ### Add operators to Workflow
        dpf_workflow.Add(u)
        dpf_workflow.Add(u_comp)
        ### Set input and output
        #dpf_workflow.Connect('time', timeScop)
        dpf_workflow.SetOutputContour(u_comp)
        dpf_workflow.SetOutputMesh(meshProviders.outputs.mesh)
        dpf_workflow.SetOutputWarpField(u)
        ### execution commands for Workflow
        dpf_workflow.Record('wf_id', True)
        this.WorkflowId = dpf_workflow.GetRecordedId()