def test_mix_extrude(): bm = Beam("MyBeam", (0, 0, 0), (1.5, 0, 0), Section("myIPE", from_str="IPE400")) a = Assembly("Test", user=User("krande")) / [Part("MyPart") / bm] h = 0.2 r = 0.02 # Polygon Extrusions origin = np.array([0.1, 0.1, -0.1]) normal = np.array([0, -1, 0]) xdir = np.array([1, 0, 0]) points = [(0, 0), (0.05, 0.1), (0.1, 0)] bm.add_penetration(PrimExtrude("my_pen", points, h, normal, origin, xdir)) origin = np.array([0.3, 0.1, -0.1]) points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)] bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir)) origin = np.array([0.5, 0.1, -0.1]) points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)] bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir)) # Cylinder Extrude x = 0.8 bm.add_penetration(PrimCyl("my_pen5", (x, -0.1, 0), (x, 0.1, 0), 0.1)) # Box Extrude x = 1.0 bm.add_penetration(PrimBox("my_pen6", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1))) _ = a.to_ifc(test_dir / "penetrations_mix.ifc", return_file_obj=True)
def add_random_cutouts(bm: Beam): h = 0.2 r = 0.02 normal = [0, 1, 0] xdir = [-1, 0, 0] # Polygon Extrusions origin = np.array([0.2, -0.1, -0.1]) points = [(0, 0), (0.1, 0), (0.05, 0.1)] bm.add_penetration(PrimExtrude("Poly1", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)] bm.add_penetration(PrimExtrude("Poly2", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)] bm.add_penetration(PrimExtrude("Poly3", points, h, normal, origin, xdir)) # Cylinder Extrude x = origin[0] + 0.2 bm.add_penetration(PrimCyl("cylinder", (x, -0.1, 0), (x, 0.1, 0), 0.1)) # Box Extrude x += 0.2 bm.add_penetration(PrimBox("box", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1)))
def test_mix_extrude(self): bm = Beam("MyBeam", (0, 0, 0), (1.5, 0, 0), Section("myIPE", from_str="IPE400")) a = Assembly("Test", creator="Kristoffer H. Andersen") / [Part("MyPart") / bm] h = 0.2 r = 0.02 # Polygon Extrusions origin = np.array([0.1, 0.1, -0.1]) normal = np.array([0, -1, 0]) xdir = np.array([1, 0, 0]) points = [(0, 0), (0.05, 0.1), (0.1, 0)] bm.add_penetration(PrimExtrude("my_pen", points, h, normal, origin, xdir)) origin = np.array([0.3, 0.1, -0.1]) points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)] bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir)) origin = np.array([0.5, 0.1, -0.1]) points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)] bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir)) # Cylinder Extrude x = 0.8 bm.add_penetration(PrimCyl("my_pen5", (x, -0.1, 0), (x, 0.1, 0), 0.1)) # Box Extrude x = 1.0 bm.add_penetration(PrimBox("my_pen6", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1))) a.to_ifc(test_folder / "penetrations_mix.ifc")
def beam_ex1(p1=(0, 0, 0), p2=(1.5, 0, 0), profile="IPE400"): """ :return: :rtype: ada.Assembly """ bm = Beam("MyBeam", p1, p2, profile, Material("S355")) a = Assembly("Test", user=User("krande")) / [Part("MyPart") / bm] h = 0.2 r = 0.02 normal = [0, 1, 0] xdir = [-1, 0, 0] # Polygon Extrusions origin = np.array([0.2, -0.1, -0.1]) points = [(0, 0), (0.1, 0), (0.05, 0.1)] bm.add_penetration(PrimExtrude("Poly1", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)] bm.add_penetration(PrimExtrude("Poly2", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)] bm.add_penetration(PrimExtrude("Poly3", points, h, normal, origin, xdir)) # Cylinder Extrude x = origin[0] + 0.2 bm.add_penetration(PrimCyl("cylinder", (x, -0.1, 0), (x, 0.1, 0), 0.1)) # Box Extrude x += 0.2 bm.add_penetration(PrimBox("box", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1))) # Create a FEM analysis of the beam as a cantilever subjected to gravity loads p = a.get_part("MyPart") create_beam_mesh(bm, p.fem, "shell") # Add a set containing ALL elements (necessary for Calculix loads). fs = p.fem.add_set(FemSet("Eall", [el for el in p.fem.elements], "elset")) step = a.fem.add_step( Step("gravity", "static", nl_geom=True, init_incr=100.0, total_time=100.0)) step.add_load(Load("grav", "gravity", -9.81 * 800, fem_set=fs)) fix_set = p.fem.add_set(FemSet("bc_nodes", get_beam_end_nodes(bm), "nset")) a.fem.add_bc(Bc("Fixed", fix_set, [1, 2, 3])) return a
def test_poly_revolve(self): bm = Beam("MyBeam", (0, 0, 0), (2, 0, 0), Section("myIPE", from_str="IPE400")) a = Assembly("Test") / [Part("MyPart") / bm] origin = (1.5, 0, 0.05) normal = (1, 0, 0) xdir = (0, 1, 0) rev_angle = 180 points2d = [(1, 0.0), (1.2, 0.0), (1.1, 0.2)] bm.add_penetration(PrimRevolve("my_pen_revolved", points2d, origin, xdir, normal, rev_angle)) a.to_stp(test_folder / "penetrations_revolve.stp") a.to_ifc(test_folder / "penetrations_revolve.ifc")
def test_poly_extrude(): bm = Beam("MyBeam", (0, 0, 0), (2, 0, 0), Section("myIPE", from_str="IPE400")) a = Assembly("Test") / [Part("MyPart") / bm] h = 0.2 r = 0.02 origin = np.array([0.1, 0.1, -0.1]) normal = np.array([0, -1, 0]) xdir = np.array([1, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)] bm.add_penetration(PrimExtrude("my_pen1", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0, 0.2, r)] bm.add_penetration(PrimExtrude("my_pen2", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.2, 0, r), (0.25, 0.1, r), (0.25, 0.25, r), (0, 0.25, r)] bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir)) origin += np.array([0.4, 0, 0]) points = [ (0, 0, r), (0.2, 0, r), (0.25, 0.1, r), (0.5, 0.0, r), (0.5, 0.25, r), (0, 0.25, r), ] bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir)) _ = a.to_ifc(test_dir / "penetrations_poly.ifc", return_file_obj=True)
def test_beam_mesh(self): import gmsh try: gmsh.finalize() except: pass bm = Beam(f"bm1", n1=[0, 0, 0], n2=[1, 0, 0], sec="IPE220") bm.add_penetration( PrimCyl("Cylinder", (0.5, -0.5, 0), (0.5, 0.5, 0), 0.05)) p = Part('MyFem') p.add_beam(bm) create_beam_mesh(bm, p.fem, "solid", interactive=False) a = Assembly('Test') / p a.to_fem('my_test', 'xdmf', scratch_dir=test_folder, fem_converter='meshio', overwrite=True)
def test_beam_mesh(self): import gmsh try: gmsh.finalize() except BaseException as e: logging.error(e) pass bm = Beam("bm1", n1=[0, 0, 0], n2=[1, 0, 0], sec="IPE220") bm.add_penetration( PrimCyl("Cylinder", (0.5, -0.5, 0), (0.5, 0.5, 0), 0.05)) p = Part("MyFem") p.add_beam(bm) create_beam_mesh(bm, p.fem, "solid", interactive=False) a = Assembly("Test") / p a.to_fem("my_test", "xdmf", scratch_dir=test_folder, fem_converter="meshio", overwrite=True)
def _cut_intersecting_member(self, mem_base: Beam, mem_incoming: Beam): from ada import PrimBox p1, p2 = mem_base.bbox.minmax mem_incoming.add_penetration(PrimBox(f"{self.name}_neg", p1, p2))