How to get the mesh quality using ACT

Options
M
M Member, Employee Posts: 230
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited December 2023 in Structures

Simple check of mesh quality

Will walk through all available mesh metric quantities write ave, min, max, std to dict

    with Transaction():
        m = Model.Mesh
        m_q = {}
        mm = 1
        ctr = 1
        while mm == 1:
            try:
                m.MeshMetric = ctr
                m_nam=m.PropertyByName("MeshMetric").StringValue
                m_ave = m.Average
                m_min = m.Minimum
                m_max = m.Maximum
                m_std = m.StandardDeviation
                m_q[m_nam] = ([ctr,m_ave,m_min,m_max,m_std]) # mesh metric, counter, 
                ctr+=1
            except:
                pass
                mm = 0
Tagged:

Best Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    Another method is to use GetResultsData() to retrieve the values on the elements directly. For example, to retrieve MAPDL Jacobian Ration on element n°1, one can use:

        results = ExtAPI.DataModel.Project.Model.Analyses[0].GetResultsData() # access results
        mesh_results = results.GetResult("MESH_") # access results on mesh
        mesh_results.Components # print "components", ie, name of available results for the mesh
        mesh_results.SelectComponents(['JACOBIAN_RATIO_MAPDL']) # select MAPDL Jacobian ratio
        mesh_results.GetElementValues([1]) # print value on element 1
    
  • Erik Kostson
    Erik Kostson Member, Employee Posts: 133
    First Answer Name Dropper First Anniversary Ansys Employee
    edited March 4 Answer ✓
    Options

    Just to add to the first post.

    Instead of using ctr=1 or some other integer we can now (say 2023 r2) use the following to set the type of mesh metric one wants to look at:

    m.MeshMetric=MeshMetricType.AspectRatio

Answers

  • M
    M Member, Employee Posts: 230
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    edited March 12
    Options

    Much clearer. Thanks Erik!