Exemplo n.º 1
0
 def test_read_write_code_aster_to_xdmf(self):
     a = Assembly("meshio_from_ca", "temp")
     a.read_fem(example_files / "fem_files/meshes/med/box.med",
                fem_converter="meshio")
     a.to_fem("box_analysis_xdmf",
              fem_format="xdmf",
              fem_converter="meshio")
Exemplo n.º 2
0
 def test_read_R3D4(self):
     from ada import Assembly
     a = Assembly('my_assembly', 'temp')
     a.read_fem(
         os.path.join(this_dir,
                      example_files / 'fem_files/abaqus/box_rigid.inp'))
     assert len(a.fem.constraints) == 1
Exemplo n.º 3
0
 def test_read_write_code_aster_to_abaqus(self):
     a = Assembly('meshio_from_ca', 'temp')
     a.read_fem(os.path.join(this_dir, example_files /
                             'fem_files/meshes/med/box.med'),
                fem_converter='meshio')
     a.to_fem('box_analysis_abaqus',
              fem_format='abaqus',
              fem_converter='meshio')
Exemplo n.º 4
0
 def test_read_C3D20(self):
     from ada import Assembly
     a = Assembly('my_assembly', 'temp')
     a.read_fem(
         os.path.join(this_dir,
                      example_files / 'fem_files/calculix/contact2e.inp'))
     beams = list(a.parts.values())[0]
     vol = beams.fem.nodes.vol_cog
     assert vol == (0.49999999627471, 1.2499999925494, 3.9999999701977)
Exemplo n.º 5
0
    def test_write_cantilever(self):

        name = "cantilever_code_aster"

        a = beam_ex1()

        a.to_fem(name, fem_format="code_aster", overwrite=True)

        b = Assembly()
        b.read_fem((Settings.scratch_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)
Exemplo n.º 6
0
    def test_read_write_portal_frame(self):

        name = "portal"

        a = Assembly()
        a.read_fem(example_files / "fem_files/code_aster/portal_01.med", "code_aster", name=name)
        a.to_fem(name, "code_aster", overwrite=True)

        b = Assembly()
        b.read_fem((Settings.scratch_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)
Exemplo n.º 7
0
    def test_read_write_box(self):

        name = "box"

        a = Assembly()
        a.read_fem(example_files / "fem_files/meshes/med/box.med", "code_aster", name="box")
        a.to_fem(name, "code_aster", overwrite=True)

        b = Assembly()
        b.read_fem((Settings.scratch_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)
Exemplo n.º 8
0
def get_fem_stats(fem_file, dest_md_file, data_file="data.json"):
    """

    :param fem_file:
    :param dest_md_file:
    :param data_file: Destination of data.json file (keeping track of last modified status etc..)
    """
    import json
    import os

    from ada import Assembly
    from ada.fem.utils import get_eldata

    dest_md_file = pathlib.Path(dest_md_file)
    data_file = pathlib.Path(data_file)
    a = Assembly()
    a.read_fem(fem_file)

    out_str = ""

    for name, part in a.parts.items():
        fem = part.fem
        r = get_eldata(fem_source=fem)
        if len(r.keys()) == 0:
            continue
        out_str += f"* **{name}**: ("

        el_data = ""
        for el_type, el_num in r.items():
            el_data += f"{el_type}: {el_num}, "

        out_str += el_data[:-2] + ")\n"

    os.makedirs(dest_md_file.parent, exist_ok=True)

    with open(dest_md_file, "w") as f:
        f.write(out_str)

    if data_file.exists():
        with open(data_file, "r") as f:
            data = json.load(f)
    else:
        data = dict()
    print(data)
Exemplo n.º 9
0
 def test_read_abaqus(self):
     b = Assembly("my_assembly", "temp")
     b.read_fem(example_files / "fem_files/meshes/abaqus/element_elset.inp",
                fem_converter="meshio")
Exemplo n.º 10
0
    def test_read_C3D20(self):
        from ada import Assembly

        a = Assembly("my_assembly", "temp")
        a.read_fem(example_files / "fem_files/calculix/contact2e.inp",
                   fem_converter="meshio")
Exemplo n.º 11
0
 def test_read_R3D4(self):
     a = Assembly("my_assembly", "temp")
     a.read_fem(example_files / "fem_files/abaqus/box_rigid.inp")
     assert len(a.fem.constraints) == 1
Exemplo n.º 12
0
 def test_read_code_aster(self):
     a = Assembly('meshio_from_ca', 'temp')
     a.read_fem(os.path.join(this_dir, example_files /
                             'fem_files/meshes/med/box.med'),
                fem_converter='meshio')
Exemplo n.º 13
0
 def test_read_abaqus(self):
     b = Assembly('my_assembly', 'temp')
     b.read_fem(os.path.join(
         this_dir,
         example_files / 'fem_files/meshes/abaqus/element_elset.inp'),
                fem_converter='meshio')
Exemplo n.º 14
0
 def test_read_C3D20(self):
     from ada import Assembly
     a = Assembly('my_assembly', 'temp')
     a.read_fem(os.path.join(
         this_dir, example_files / 'fem_files/calculix/contact2e.inp'),
                fem_converter='meshio')
Exemplo n.º 15
0
def test_read_C3D20(example_files):
    a = Assembly()
    a.read_fem(example_files / "fem_files/calculix/contact2e.inp")
    beams = list(a.parts.values())[0]
    vol = beams.fem.nodes.vol_cog
    assert vol == (0.49999999627471, 1.2499999925494, 3.9999999701977)
Exemplo n.º 16
0
 def test_read_code_aster(self):
     a = Assembly("meshio_from_ca", "temp")
     a.read_fem(example_files / "fem_files/meshes/med/box.med",
                fem_converter="meshio")
Exemplo n.º 17
0
 def test_read_C3D20(self):
     from ada import Assembly
     a = Assembly('my_assembly', 'temp')
     a.read_fem(
         os.path.join(this_dir, example_files / 'fem_files/abaqus/box.inp'))
Exemplo n.º 18
0
 def test_read_C3D20(self):
     a = Assembly("my_assembly", "temp")
     a.read_fem(example_files / "fem_files/abaqus/box.inp")