def get_lcsys_from_bulk(bulk_str: str, parent: FEM) -> dict[str, Csys]: """ https://abaqus-docs.mit.edu/2017/English/SIMACAEKEYRefMap/simakey-r-orientation.htm#simakey-r-orientation """ lcsysd = dict() for m in cards.orientation.regex.finditer(bulk_str): d = m.groupdict() name = d["name"].replace('"', "") defi = d.get("definition", "COORDINATES") system = d.get("system", "RECTANGULAR") if defi is None or defi.upper() == "COORDINATES": coords = [tuple(float(d[x]) for x in ["ax", "ay", "az"]), tuple(float(d[x]) for x in ["bx", "by", "bz"])] if d["cx"] is not None: coords += [(float(d["cx"]), float(d["cy"]), float(d["cz"]))] lcsysd[name] = Csys(name, system=system, coords=coords, parent=parent) elif defi.upper() == "NODES": nodes = [] for n in ["ax", "ay", "az"]: nodes += [get_set_from_assembly(d[n], parent, "nset")] lcsysd[name] = Csys(name, system=system, definition=defi, nodes=nodes, parent=parent) else: raise NotImplementedError(f'Orientation definition "{defi}" is not yet supported') return lcsysd
def add_lcsys(self, lcsys: Csys) -> Csys: if lcsys.name in self.lcsys.keys(): raise ValueError( "Local Coordinate system cannot have duplicate name") lcsys.parent = self self.lcsys[lcsys.name] = lcsys return lcsys
def get_lcsys_from_bulk(bulk_str, parent): """ https://abaqus-docs.mit.edu/2017/English/SIMACAEKEYRefMap/simakey-r-orientation.htm#simakey-r-orientation :param bulk_str: :param parent: :return: """ # re_lcsys = re.compile( # r"^\*Orientation(:?,\s*definition=(?P<definition>.*?)|)(?:,\s*system=(?P<system>.*?)|)\s*name=(?P<name>.*?)\n(?P<content>.*?)$", # _re_in, # ) lcsysd = dict() for m in AbaCards.orientation.regex.finditer(bulk_str): d = m.groupdict() name = d["name"].replace('"', "") defi = d["definition"] if d["definition"] is not None else "COORDINATES" system = d["system"] if d["system"] is not None else "RECTANGULAR" if defi.upper() == "COORDINATES": coords = [ (float(d["ax"]), float(d["ay"]), float(d["az"])), (float(d["bx"]), float(d["by"]), float(d["bz"])), ] if d["cx"] is not None: coords += [(float(d["cx"]), float(d["cy"]), float(d["cz"]))] lcsysd[name] = Csys(name, system=system, coords=coords, parent=parent) else: raise NotImplementedError(f'Orientation definition "{defi}" is not yet supported') return lcsysd
def test_simple_hinged_beam(test_dir): bm = Beam("MyBeam", (0, 0, 0), (1, 0, 0), "IPE400") bm.hinge_prop = HingeProp(end1=Hinge([1, 2, 3, 4, 6], Csys("MyBeam_hinge"))) p = Part("MyPart") / bm p.fem = p.to_fem_obj(0.1) convert_hinges_2_couplings(p.fem) assert len(p.fem.constraints.values()) == 1
def get_hinges_from_elem(elem, members, hinges_global, lcsysd, xvec, zvec, yvec): """ :param elem: :param members: :param hinges_global: :type elem: ada.Elem :return: """ if len(elem.nodes) > 2: raise ValueError( "This algorithm was not designed for more than 2 noded elements") from ada.core.utils import unit_vector hinges = [] 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] d = [ int(x) for x, i in zip(dofs_origin, (a1, a2, a3, a4, a5, a6)) if int(i) != 0 ] hinges.append((n, d, csys)) return hinges
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)