Ejemplo n.º 1
0
    def grab_grspring(m):
        nonlocal gr_spr_elements
        d = m.groupdict()
        matno = str_to_int(d["matno"])
        ndof = str_to_int(d["ndof"])
        bulk = d["bulk"].replace("\n", "").split()
        el = gr_spr_elements[matno]
        spr_name = f"spr{el.id}"

        n1 = el.nodes[0]
        a = 1
        row = 0
        spring = []
        subspring = []
        for dof in bulk:
            subspring.append(float(dof.strip()))
            a += 1
            if a > ndof - row:
                spring.append(subspring)
                subspring = []
                a = 1
                row += 1
        new_s = []
        for row in spring:
            l = abs(len(row) - 6)
            if l > 0:
                new_s.append([0 for i in range(0, l)] + row)
            else:
                new_s.append(row)
        X = np.array(new_s)
        X = X + X.T - np.diag(np.diag(X))
        return Spring(spr_name, matno, "SPRING1", n1=n1, stiff=X, parent=fem)
Ejemplo n.º 2
0
 def get_setmap(m):
     d = m.groupdict()
     set_type = "nset" if str_to_int(d["istype"]) == 1 else "elset"
     if set_type == "nset":
         members = [parent.nodes.from_id(str_to_int(x)) for x in d["members"].split()]
     else:
         members = [parent.elements.from_id(str_to_int(x)) for x in d["members"].split()]
     return str_to_int(d["isref"]), set_type, members
Ejemplo n.º 3
0
 def grab_constraint(master, data):
     m = str_to_int(master)
     m_set = FemSet(f"co{m}_m", [fem.nodes.from_id(m)], "nset")
     slaves = []
     for d in data:
         s = str_to_int(d["slave"])
         slaves.append(fem.nodes.from_id(s))
     s_set = FemSet(f"co{m}_m", slaves, "nset")
     fem.add_set(m_set)
     fem.add_set(s_set)
     return Constraint(f"co{m}", "coupling", m_set, s_set, parent=fem)
Ejemplo n.º 4
0
    def get_morsmel(m):
        """
        MORSMEL

        Anisotropy, Linear Elastic Structural Analysis, 2-D Membrane Elements and 2-D Thin Shell Elements

        :param m:
        :return:
        """

        d = m.groupdict()
        matno = str_to_int(d["matno"])
        return Material(
            name=mat_names[matno],
            mat_id=matno,
            mat_model=CarbonSteel(
                rho=roundoff(d["rho"]),
                E=roundoff(d["d11"]),
                v=roundoff(d["ps1"]),
                alpha=roundoff(d["alpha1"]),
                zeta=roundoff(d["damp1"]),
                sig_p=[],
                eps_p=[],
                sig_y=5e6,
            ),
            metadata=d,
            parent=part,
        )
Ejemplo n.º 5
0
 def get_eccentricities(match):
     d = match.groupdict()
     eccno = str_to_int(d["eccno"])
     ex = float(d["ex"])
     ey = float(d["ey"])
     ez = float(d["ez"])
     return eccno, (ex, ey, ez)
Ejemplo n.º 6
0
        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)
Ejemplo n.º 7
0
 def get_GenBeams(match):
     d = match.groupdict()
     sec_id = str_to_int(d["geono"])
     gen_props = GeneralProperties(
         ax=roundoff(d["area"]),
         ix=roundoff(d["ix"]),
         iy=roundoff(d["iy"]),
         iz=roundoff(d["iz"]),
         iyz=roundoff(d["iyz"]),
         wxmin=roundoff(d["wxmin"]),
         wymin=roundoff(d["wymin"]),
         wzmin=roundoff(d["wzmin"]),
         shary=roundoff(d["shary"]),
         sharz=roundoff(d["sharz"]),
         scheny=roundoff(d["shceny"]),
         schenz=roundoff(d["shcenz"]),
         sy=float(d["sy"]),
         sz=float(d["sz"]),
     )
     if sec_id in fem.parent.sections.idmap.keys():
         sec = fem.parent.sections.get_by_id(sec_id)
         sec._genprops = gen_props
         gen_props.parent = sec
     else:
         sec = Section(name=f"GB{sec_id}",
                       sec_id=sec_id,
                       sec_type="GENBEAM",
                       genprops=gen_props,
                       parent=fem.parent)
         gen_props.parent = sec
         fem.parent.sections.add(sec)
Ejemplo n.º 8
0
 def get_lcsys(m):
     d = m.groupdict()
     return str_to_int(d["transno"]), (
         roundoff(d["unix"]),
         roundoff(d["uniy"]),
         roundoff(d["uniz"]),
     )
Ejemplo n.º 9
0
    def grab_bc(match):
        d = match.groupdict()
        node = fem.nodes.from_id(str_to_int(d["nodeno"]))
        assert isinstance(node, Node)

        fem_set = FemSet(f"bc{node.id}_set", [node], "nset")
        fem.sets.add(fem_set)
        dofs = []
        for i, c in enumerate(d["content"].replace("\n", "").split()):
            bc_sestype = str_to_int(c.strip())
            if bc_sestype in [0, 4]:
                continue
            dofs.append(i + 1)
        bc = Bc(f"bc{node.id}", fem_set, dofs, parent=fem)
        node.bc = bc

        return bc
Ejemplo n.º 10
0
 def grab_elements(match):
     d = match.groupdict()
     nodes = [
         fem.nodes.from_id(x) for x in filter(
             lambda x: x != 0,
             map(str_to_int, d["nids"].replace("\n", "").split()),
         )
     ]
     eltyp = d["eltyp"]
     el_type = sesam_eltype_2_general(eltyp)
     metadata = dict(eltyad=str_to_int(d["eltyad"]), eltyp=eltyp)
     return Elem(
         str_to_int(d["elno"]),
         nodes,
         el_type,
         None,
         parent=fem,
         metadata=metadata,
     )
Ejemplo n.º 11
0
 def get_femsets(m):
     nonlocal set_map
     d = m.groupdict()
     isref = str_to_int(d["isref"])
     fem_set = FemSet(
         d["set_name"].strip(),
         set_map[isref][0],
         set_map[isref][1],
         parent=parent,
     )
     return fem_set
Ejemplo n.º 12
0
 def get_hinges(match):
     d = match.groupdict()
     fixno = str_to_int(d["fixno"])
     opt = str_to_int(d["opt"])
     trano = str_to_int(d["trano"])
     a1 = str_to_int(d["a1"])
     a2 = str_to_int(d["a2"])
     a3 = str_to_int(d["a3"])
     a4 = str_to_int(d["a4"])
     a5 = str_to_int(d["a5"])
     try:
         a6 = str_to_int(d["a6"])
     except BaseException as e:
         logging.debug(e)
         a6 = 0
         pass
     return fixno, (opt, trano, a1, a2, a3, a4, a5, a6)
Ejemplo n.º 13
0
def sesam_eltype_2_general(eltyp):
    """
    Converts the numeric definition of elements in Sesam to a generalized element type form (ie. B31, S4, etc..)

    :param eltyp:
    :return: Generic element description
    """
    for ses, gen in SesamReader.el_map.items():
        if str_to_int(eltyp) == ses:
            return gen

    raise Exception("Currently unsupported eltype", eltyp)
Ejemplo n.º 14
0
 def get_BoxBeams(match):
     d = match.groupdict()
     sec_id = str_to_int(d["geono"])
     return Section(
         name=sect_names[sec_id],
         sec_id=sec_id,
         sec_type="BG",
         h=roundoff(d["hz"]),
         w_top=roundoff(d["by"]),
         w_btn=roundoff(d["by"]),
         t_w=roundoff(d["ty"]),
         t_ftop=roundoff(d["tt"]),
         t_fbtn=roundoff(d["tb"]),
         genprops=GeneralProperties(sfy=float(d["sfy"]), sfz=float(d["sfz"])),
         parent=fem.parent,
     )
Ejemplo n.º 15
0
 def get_gpipe(match):
     d = match.groupdict()
     sec_id = str_to_int(d["geono"])
     if sec_id not in sect_names:
         sec_name = f"TUB{sec_id}"
     else:
         sec_name = sect_names[sec_id]
     t = d["t"] if d["t"] is not None else (d["dy"] - d["di"]) / 2
     return Section(
         name=sec_name,
         sec_id=sec_id,
         sec_type="TUB",
         r=roundoff(float(d["dy"]) / 2),
         wt=roundoff(t),
         genprops=GeneralProperties(sfy=float(d["sfy"]), sfz=float(d["sfz"])),
         parent=fem.parent,
     )
Ejemplo n.º 16
0
 def get_mat(match):
     d = match.groupdict()
     matno = str_to_int(d["matno"])
     return Material(
         name=mat_names[matno],
         mat_id=matno,
         mat_model=CarbonSteel(
             rho=roundoff(d["rho"]),
             E=roundoff(d["young"]),
             v=roundoff(d["poiss"]),
             alpha=roundoff(d["damp"]),
             zeta=roundoff(d["alpha"]),
             sig_p=[],
             eps_p=[],
             sig_y=roundoff(d["yield"]),
         ),
         parent=part,
     )
Ejemplo n.º 17
0
    def get_femsecs(match):
        d = match.groupdict()
        geono = str_to_int(d["geono"])
        next(total_geo)
        transno = str_to_int(d["transno"])
        elno = str_to_int(d["elno"])
        elem = fem.elements.from_id(elno)

        matno = str_to_int(d["matno"])

        # Go no further if element has no fem section
        if elem.type in ElemShapes.springs + ElemShapes.masses:
            next(importedgeom_counter)
            elem.metadata["matno"] = matno
            return None

        mat = fem.parent.materials.get_by_id(matno)
        if elem.type in ElemShapes.beam:
            next(importedgeom_counter)
            sec = fem.parent.sections.get_by_id(geono)
            n1, n2 = elem.nodes
            v = n2.p - n1.p
            if vector_length(v) == 0.0:
                xvec = [1, 0, 0]
            else:
                xvec = unit_vector(v)
            zvec = lcsysd[transno]
            crossed = np.cross(zvec, xvec)
            ma = max(abs(crossed))
            yvec = tuple([roundoff(x / ma, 3) for x in crossed])

            fix_data = str_to_int(d["fixno"])
            ecc_data = str_to_int(d["eccno"])

            members = None
            if d["members"] is not None:
                members = [
                    str_to_int(x)
                    for x in d["members"].replace("\n", " ").split()
                ]

            hinges = None
            if fix_data == -1:
                hinges = get_hinges_from_elem(elem, members, hinges_global,
                                              lcsysd, xvec, zvec, yvec)

            offset = None
            if ecc_data == -1:
                offset = get_ecc_from_elem(elem, members, eccentricities,
                                           fix_data)

            fem_set = FemSet(sec.name, [elem],
                             "elset",
                             metadata=dict(internal=True),
                             parent=fem)
            fem.sets.add(fem_set, append_suffix_on_exist=True)
            fem_sec = FemSection(
                name=sec.name,
                sec_type="beam",
                elset=fem_set,
                section=sec,
                local_z=zvec,
                local_y=yvec,
                material=mat,
                offset=offset,
                hinges=hinges,
                parent=fem,
            )
            return fem_sec

        elif elem.type in ElemShapes.shell:
            next(importedgeom_counter)
            sec_name = f"sh{elno}"
            fem_set = FemSet(sec_name, [elem],
                             "elset",
                             parent=fem,
                             metadata=dict(internal=True))
            fem.sets.add(fem_set)
            fem_sec = FemSection(
                name=sec_name,
                sec_type="shell",
                thickness=roundoff(thicknesses[geono]),
                elset=fem_set,
                material=mat,
                parent=fem,
            )
            return fem_sec
        else:
            raise ValueError("Section not added to conversion")
Ejemplo n.º 18
0
 def grab_name(m):
     d = m.groupdict()
     return str_to_int(d["geo_no"]), d["name"]
Ejemplo n.º 19
0
 def get_thicknesses(match):
     d = match.groupdict()
     sec_id = str_to_int(d["geono"])
     t = d["th"]
     return sec_id, t
Ejemplo n.º 20
0
 def get_section_names(m):
     d = m.groupdict()
     return str_to_int(d["geono"]), d["set_name"].strip()