Exemple #1
0
def test_read_write_code_aster_to_abaqus(example_files, test_meshio_dir):
    a = ada.from_fem(example_files / "fem_files/meshes/med/box.med",
                     fem_converter="meshio")
    a.to_fem("box_abaqus",
             fem_format="abaqus",
             fem_converter="meshio",
             overwrite=True,
             scratch_dir=test_meshio_dir)
def test_read_write_portal_frame(example_files, code_aster_test_dir):

    name = "portal"

    a = ada.from_fem(example_files / "fem_files/code_aster/portal_01.med",
                     "code_aster",
                     name=name)
    a.to_fem(name,
             "code_aster",
             overwrite=True,
             scratch_dir=code_aster_test_dir)

    b = ada.from_fem((code_aster_test_dir / name / name).with_suffix(".med"),
                     fem_format="code_aster")

    p_a = a.parts[name]
    p_b = b.parts[name]

    compare_fem_objects(p_a.fem, p_b.fem)
def test_read_write_box(example_files, code_aster_test_dir):

    name = "box"

    a = ada.from_fem(example_files / "fem_files/meshes/med/box.med",
                     "code_aster",
                     name="box")
    a.to_fem(name,
             "code_aster",
             overwrite=True,
             scratch_dir=code_aster_test_dir)

    b = ada.from_fem((code_aster_test_dir / name / name).with_suffix(".med"),
                     fem_format="code_aster")

    p_a = a.parts["box"]
    p_b = b.parts["box"]

    compare_fem_objects(p_a.fem, p_b.fem)
def test_read_write_cylinder(example_files, code_aster_test_dir):

    name = "cylinder"

    a = ada.from_fem(example_files / "fem_files/meshes/med/cylinder.med",
                     "code_aster",
                     name="cylinder_rewritten")
    a.to_fem(name,
             "code_aster",
             overwrite=True,
             scratch_dir=code_aster_test_dir)

    b = ada.from_fem((code_aster_test_dir / name / name).with_suffix(".med"),
                     fem_format="code_aster")

    p_a = a.parts["cylinder_rewritten"]
    p_b = b.parts["cylinder"]
    # TODO: Fix failing tests. For some reason, FemSets are twice as large when they are reimported.
    compare_fem_objects(p_a.fem, p_b.fem)
def test_read_hinged_beams_and_mass(example_files):
    a = ada.from_fem(example_files / "fem_files/sesam/beamMassT1.FEM")
    p = list(a.parts.values())[0]
    assert len(list(p.fem.elements.masses)) == 1
    assert len(list(p.fem.elements.shell)) == 4
    assert len(list(p.fem.elements.lines)) == 11

    cog = p.fem.elements.calc_cog()
    assert cog.tot_mass == pytest.approx(54093.9)
    assert cog.p[0] == pytest.approx(5.21773)
    assert cog.p[1] == pytest.approx(4.78227)
    assert cog.p[2] == pytest.approx(0.884281)

    assert len(p.fem.sections.lines) == 11
    p.fem.sections.merge_by_properties()
    assert len(p.fem.sections.lines) == 4
    assert len(p.materials) == 1
def test_write_cantilever(code_aster_test_dir):

    name = "cantilever_code_aster"

    a = beam_ex1()

    a.to_fem(name,
             fem_format="code_aster",
             overwrite=True,
             scratch_dir=code_aster_test_dir)
    b = ada.from_fem((code_aster_test_dir / name / name).with_suffix(".med"),
                     fem_format="code_aster")

    p_a = a.parts["MyPart"]
    p_b = b.parts["cantilever_code_aster"]

    compare_fem_objects(p_a.fem, p_b.fem)
Exemple #7
0
def test_merge_fem_sections(test_merge_sections_dir):
    bm1 = ada.Beam("Bm1", (0, 0, 0), (10, 0, 0), "IPE300")
    bm2 = ada.Beam("Bm2", (10, 0, 0), (10, 10, 0), "IPE400")
    a = ada.Assembly() / (ada.Part("MyPart") / [bm1, bm2])

    p = a.get_part("MyPart")
    p.fem = p.to_fem_obj(2, "line")
    assert len(p.fem.sections) == 2

    name = "Merges_Sections"
    fem_format = "sesam"

    a.to_fem(name, fem_format, overwrite=True, scratch_dir=test_merge_sections_dir)

    inp_path = default_fem_inp_path(name, test_merge_sections_dir)[fem_format]
    b = ada.from_fem(inp_path)
    pb = b.get_part("T1")
    assert len(pb.fem.sections) == 10

    pb.fem.sections.merge_by_properties()

    assert len(pb.fem.sections) == 2
Exemple #8
0
def test_read_code_aster(example_files):
    a = ada.from_fem(example_files / "fem_files/meshes/med/box.med",
                     fem_converter="meshio")
    print(a)
Exemple #9
0
def test_read_abaqus(example_files):
    b = ada.from_fem(example_files /
                     "fem_files/meshes/abaqus/element_elset.inp",
                     fem_converter="meshio")
    print(b)
Exemple #10
0
def test_read_C3D20(example_files):
    a = ada.from_fem(example_files / "fem_files/calculix/contact2e.inp",
                     fem_converter="meshio")
    print(a)
Exemple #11
0
def test_read_R3D4(example_files):
    a = ada.from_fem(example_files / "fem_files/abaqus/box_rigid.inp")
    assert len(a.fem.constraints.values()) == 1
Exemple #12
0
def test_read_C3D20(example_files):
    a = ada.from_fem(example_files / "fem_files/abaqus/box.inp")
    print(a)