Exemplo n.º 1
0
def convert_springs_to_connectors(assembly):
    """
    Converts all single noded springs to connector elements

    :param assembly:
    :type assembly: ada.Assembly
    """
    import numpy as np

    from ada import Node
    from ada.fem import Bc, Connector, ConnectorSection, FemSet

    for p in assembly.get_all_subparts():
        for spring in p.fem.springs.values():
            n1 = spring.nodes[0]
            n2 = Node(n1.p - np.array([0, 0, 10e-3]))
            assembly.fem.add_rp(spring.name + "_rp", n2)
            fs = FemSet(spring.name + "_bc", [n2], "nset")
            assembly.fem.add_set(fs)
            assembly.fem.add_bc(Bc(spring.name + "_bc", fs,
                                   [1, 2, 3, 4, 5, 6]))
            diag = []
            for dof, row in enumerate(spring.stiff):
                for j, stiffness in enumerate(row):
                    if dof == j:
                        diag.append(stiffness)

            con_sec = ConnectorSection(spring.name + "_consec", diag, [])
            assembly.fem.add_connector_section(con_sec)
            con = Connector(spring.name + "_con", spring.id, n1, n2, "bushing",
                            con_sec)
            assembly.fem.add_connector(con)
        p.fem._springs = dict()
        p.fem.elements.filter_elements(delete_elem=["SPRING1"])
Exemplo n.º 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_
        ]
Exemplo n.º 3
0
 def add_connector(self, connector: Connector) -> Connector:
     connector.parent = self
     self.elements.add(connector)
     connector.csys.parent = self
     if connector.con_sec.parent is None:
         self.add_connector_section(connector.con_sec)
     self.add_set(
         FemSet(name=connector.name, members=[connector], set_type="elset"))
     return connector
Exemplo n.º 4
0
def get_connectors_from_inp(bulk_str, fem):
    """

    :param bulk_str:
    :param fem:
    :type fem: ada.fem.FEM
    :return:
    """

    nsuffix = Counter(1, "_")
    cons = dict()
    for m in AbaCards.connector_section.regex.finditer(bulk_str):
        d = m.groupdict()
        name = d["behavior"] + next(nsuffix)
        elset = fem.elsets[d["elset"]]
        elem = elset.members[0]

        csys_ref = d["csys"].replace('"', "")
        csys_ref = csys_ref[:-1] if csys_ref[-1] == "," else csys_ref

        con_type = d["contype"]
        if con_type[-1] == ",":
            con_type = con_type[:-1]

        n1 = elem.nodes[0]
        n2 = elem.nodes[1]

        cons[name] = Connector(
            name,
            elem.id,
            n1,
            n2,
            con_type,
            fem.connector_sections[d["behavior"]],
            csys=fem.lcsys[csys_ref],
        )
    return cons