Check whether mesh is linear or quadratic through scripting

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

How can I check whether mesh is linear or quadratic through Mechanical scripting?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    The following function can be used:

    def LinearQuadraticMesh(analysis):
        '''
        Check whether linear or quadratic elements are used, for beams, shells and solids
        '''
       
        meshData = analysis.MeshData
        elemList = meshData.Elements
        existLinearBeamElements = False
        existQuadraticBeamElements = False
        existLinearShellElements = False
        existQuadraticShellElements = False
        existLinearSolidElements = False
        existQuadraticSolidElements = False
        analysis = ExtAPI.DataModel.Project.Model.Analyses[0]
        meshData = analysis.MeshData
        elemList = meshData.Elements
    
        for part in ExtAPI.DataModel.Project.Model.Geometry.Children:
            for body in part.Children:
                if body.Suppressed is False:
                    geoBody = body.GetGeoBody()
                    if geoBody.BodyType.ToString() == "GeoBodyWire":
                        for elem in elemList:
                            elemType = elem.Type
                            if elemType == ElementTypeEnum.kBeam3 and existLinearBeamElements is False:
                                existLinearBeamElements = True
                            elif elemType == ElementTypeEnum.kBeam4 and existQuadraticBeamElements is False:
                                existQuadraticBeamElements = True
                            else:
                                pass
                    elif geoBody.BodyType.ToString() == "GeoBodySheet":
                        for elem in elemList:
                            elemType = elem.Type
                            if elemType in (
                                    ElementTypeEnum.kTri3, ElementTypeEnum.kQuad4
                            ) and existLinearShellElements is False:
                                existLinearShellElements = True
                            elif elemType in (
                                    ElementTypeEnum.kTri6, ElementTypeEnum.kQuad8
                            ) and existQuadraticShellElements is False:
                                existQuadraticShellElements = True
                            else:
                                pass
                    elif geoBody.BodyType.ToString() == "GeoBodySolid":
                        for elem in elemList:
                            elemType = elem.Type
                            if elemType in (
                                    ElementTypeEnum.kTet4, ElementTypeEnum.kHex8
                            ) and existLinearSolidElements is False:
                                existLinearSolidElements = True
                            elif elemType in (
                                    ElementTypeEnum.kTet10, ElementTypeEnum.kHex20
                            ) and existQuadraticSolidElements is False:
                                existQuadraticSolidElements = True
                            else:
                                pass
                    else:
                        pass
    
            return [existLinearBeamElements , existQuadraticBeamElements, existLinearShellElements , existQuadraticShellElements , existLinearSolidElements , existQuadraticSolidElements]