예제 #1
0
def get_elems():
    n1, n2, n3, n4, n5, n6, n7, n8, n9, n10 = get_nodes()
    el1 = Elem(1, [n1, n2], "B31")
    el2 = Elem(2, [n2, n3], "B31")
    el3 = Elem(3, [n3, n1], "B31")
    el4 = Elem(4, [n1, n2, n3, n4], "S4R")
    return el1, el2, el3, el4
예제 #2
0
def numpy_array_to_list_of_elements(res_, eltype, elset, ada_el_type,
                                    fem: "FEM") -> List["Elem"]:
    if ada_el_type == Elem.EL_TYPES.CONNECTOR_SHAPES.CONNECTOR:
        connectors = []
        for e in res_:
            if len(e) != 3:
                raise ValueError()
            el_id = e[0]
            n1, n2 = [fem.nodes.from_id(n) for n in e[1:]]
            con = Connector(next(con_names),
                            el_id,
                            n1,
                            n2,
                            con_type=None,
                            con_sec=None,
                            parent=fem)
            connectors.append(con)
        return connectors
    else:
        return [
            Elem(
                e[0],
                [fem.nodes.from_id(n) for n in e[1:]],
                ada_el_type,
                elset,
                el_formulation_override=eltype,
                parent=fem,
            ) for e in res_
        ]
예제 #3
0
파일: reader.py 프로젝트: Caladeux/adapy
        def grab_mass(match):
            d = match.groupdict()

            nodeno = str_to_int(d["nodeno"])
            mass_in = [
                roundoff(d["m1"]),
                roundoff(d["m2"]),
                roundoff(d["m3"]),
                roundoff(d["m4"]),
                roundoff(d["m5"]),
                roundoff(d["m6"]),
            ]
            masses = [m for m in mass_in if m != 0.0]
            if checkEqual2(masses):
                mass_type = None
                masses = [masses[0]] if len(masses) > 0 else [0.0]
            else:
                mass_type = "anisotropic"
            no = fem.nodes.from_id(nodeno)
            fem_set = FemSet(f"m{nodeno}", [], "elset", metadata=dict(internal=True), parent=fem)
            mass = Mass(f"m{nodeno}", fem_set, masses, "mass", ptype=mass_type, parent=fem)
            elem = Elem(no.id, [no], "mass", fem_set, mass_props=mass, parent=fem)
            fem.elements.add(elem)
            fem_set.add_members([elem])
            fem.sets.add(fem_set)
            return Mass(f"m{nodeno}", fem_set, masses, "mass", ptype=mass_type, parent=fem)
예제 #4
0
파일: utils.py 프로젝트: Krande/adapy
def get_elements_from_entity(model: gmsh.model, ent, fem: FEM,
                             dim) -> List[Elem]:
    elem_types, elem_tags, elem_node_tags = model.mesh.getElements(dim, ent)
    elements = []
    el_tags = []
    for k, element_list in enumerate(elem_tags):
        el_name, _, _, numv, _, _ = model.mesh.getElementProperties(
            elem_types[k])
        if el_name == "Point":
            continue
        elem_type = gmsh_map[el_name]
        for j, eltag in enumerate(element_list):
            if eltag in el_tags:
                continue
            el_tags.append(eltag)
            nodes = []
            for i in range(numv):
                idtag = numv * j + i
                p1 = elem_node_tags[k][idtag]
                nodes.append(fem.nodes.from_id(p1))

            new_nodes = node_reordering(elem_type, nodes)
            if new_nodes is not None:
                nodes = new_nodes

            el = Elem(eltag, nodes, elem_type, parent=fem)
            elements.append(el)
    return elements
예제 #5
0
    def test_negative_sec_contained(self):
        # A minor change in section box thickness
        sec = Section("myBG", from_str="BG800x400x20x40")
        mat = Material("my_mat")

        bm = Beam("my_beam", (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], "B31")
        fem_set = FemSet("my_set", [elem], "elset")
        fem_sec = FemSection("my_sec", "beam", fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
예제 #6
0
    def test_negative_mat_contained(self):
        # A minor change in material property (S420 instead of S355)
        sec = Section("myBG", from_str="BG800x400x30x40")

        mat = Material("my_mat", CarbonSteel("S420"))

        bm = Beam("my_beam", (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], "B31")
        fem_set = FemSet("my_set", [elem], "elset")
        fem_sec = FemSection("my_sec", "beam", fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
예제 #7
0
def add_hinge_prop_to_elem(elem: Elem, members, hinges_global, xvec,
                           yvec) -> None:
    """Add hinge property to element from sesam FEM file"""
    from ada.fem.elements import Hinge, HingeProp

    if len(elem.nodes) > 2:
        raise ValueError(
            "This algorithm was not designed for more than 2 noded elements")

    for i, x in enumerate(members):
        if i >= len(elem.nodes):
            break
        if x == 0:
            continue
        if x not in hinges_global.keys():
            raise ValueError("fixno not found!")
        opt, trano, a1, a2, a3, a4, a5, a6 = hinges_global[x]
        n = elem.nodes[i]
        if trano > 0:
            csys = None
        else:
            csys = Csys(
                f"el{elem.id}_hinge{i + 1}_csys",
                coords=([
                    unit_vector(xvec) + n.p,
                    unit_vector(yvec) + n.p, n.p
                ]),
                parent=elem.parent,
            )
        dofs_origin = [1, 2, 3, 4, 5, 6]
        dofs = [
            int(x) for x, i in zip(dofs_origin, (a1, a2, a3, a4, a5, a6))
            if int(i) != 0
        ]
        end = Hinge(retained_dofs=dofs, csys=csys, fem_node=n)
        if i == 0:
            elem.hinge_prop = HingeProp(end1=end)
        else:
            elem.hinge_prop = HingeProp(end2=end)
예제 #8
0
    def test_negative_contained_shell_(self):
        # Testing equal operator for change in element type
        mat = Material("my_mat")
        elem = Elem(1, [
            Node((0, 0, 0)),
            Node((1, 0, 0)),
            Node((1, 1, 0)),
            Node((0, 1, 0))
        ], "S4")
        fem_set = FemSet("my_set", [elem], "elset")
        fem_sec = FemSection("my_sec", "shell", fem_set, mat, thickness=0.01)

        p = get_fsec_sh_collection()

        self.assertFalse(fem_sec in p.fem.sections)
예제 #9
0
파일: conftest.py 프로젝트: Krande/adapy
def part_with_shell():
    p = Part("my_part")
    mat = Material("my_mat")
    elem = Elem(
        1,
        [Node((0, 0, 0)),
         Node((1, 0, 0)),
         Node((1, 1, 0)),
         Node((0, 1, 0))], "quad")
    fem_set = FemSet("my_set", [elem], "elset")
    fem_sec = FemSection("my_sec", "shell", fem_set, mat, thickness=0.01)
    for n in elem.nodes:
        p.fem.nodes.add(n)
    p.fem.elements.add(elem)
    p.fem.sets.add(fem_set)
    p.fem.sections.add(fem_sec)
    return p
예제 #10
0
def get_nodes_and_elements(gmsh, fem=None, fem_set_name="all_elements"):
    """

    :param gmsh:
    :type gmsh: gmsh
    :param fem:
    :type fem: ada.fem.FEM
    :param fem_set_name:
    :type fem_set_name: str
    """
    from ada.fem import FEM

    fem = FEM("AdaFEM") if fem is None else fem

    nodes = list(gmsh.model.mesh.getNodes(-1, -1))
    # Get nodes
    fem._nodes = Nodes(
        [
            Node(
                [roundoff(x) for x in gmsh.model.mesh.getNode(n)[0]],
                n,
                parent=fem,
            ) for n in nodes[0]
        ],
        parent=fem,
    )

    # Get elements
    elemTypes, elemTags, elemNodeTags = gmsh.model.mesh.getElements(2, -1)
    elements = []
    for k, element_list in enumerate(elemTags):
        face, dim, morder, numv, parv, _ = gmsh.model.mesh.getElementProperties(
            elemTypes[k])
        elem_type = gmsh_map[face]
        for j, eltag in enumerate(element_list):
            nodes = []
            for i in range(numv):
                idtag = numv * j + i
                p1 = elemNodeTags[k][idtag]
                nodes.append(fem.nodes.from_id(p1))

            el = Elem(eltag, nodes, elem_type, parent=fem)
            elements.append(el)
    fem._elements = FemElements(elements, fem_obj=fem)
    femset = FemSet(fem_set_name, elements, "elset")
    fem.sets.add(femset)