Ejemplo n.º 1
0
def test_mat_time_fc():
    model = dpf.Model(examples.download_all_kinds_of_complexity_modal())
    fc = model.results.stress.on_all_time_freqs.split_by_body.eval()
    assert isinstance(fc, BodyFieldsContainer)
    assert len(fc.get_fields_by_mat_id(45)) == 45
    assert np.allclose(
        fc.get_fields_by_mat_id(45)[0].data,
        fc.get_field_by_mat_id(45, 1).data)
    assert len(fc.get_mat_scoping().ids) == 32
Ejemplo n.º 2
0
def test_result_stress_model():
    model = dpf.core.Model(examples.download_all_kinds_of_complexity_modal())
    results = model.results
    assert isinstance(results.stress(), dpf.core.Operator)
    assert len(results.stress.on_all_time_freqs.eval()) == 45
    assert results.stress.on_first_time_freq.eval().get_label_scoping().ids == [1]
    assert results.stress.on_last_time_freq.eval().get_label_scoping().ids == [45]
    assert len(results.stress.split_by_body.eval()) == 32
    assert len(results.stress.split_by_shape.eval()) == 4
    assert len(results.stress.on_named_selection("_FIXEDSU").eval()[0].scoping) == 222
    all_time_ns = results.stress.on_named_selection("_FIXEDSU").on_all_time_freqs.eval()
    assert len(all_time_ns) == 45
    assert len(all_time_ns[0].scoping) == 222
    assert len(all_time_ns[19].scoping) == 222
Ejemplo n.º 3
0
def test_el_shape_time_fc():
    model = dpf.Model(examples.download_all_kinds_of_complexity_modal())
    fc = model.results.stress.on_all_time_freqs.split_by_shape.eval()
    assert isinstance(fc, ElShapeFieldsContainer)
    assert len(fc.beam_fields()) == 45
    assert len(fc.shell_fields()) == 45
    assert len(fc.solid_fields()) == 45
    assert len(fc.beam_fields(1)) == 1
    assert len(fc.shell_fields(3)) == 1
    assert len(fc.solid_fields(20)) == 1
    mesh = model.metadata.meshed_region

    f = fc.beam_field(3)
    for id in f.scoping.ids:
        assert mesh.elements.element_by_id(id).shape == "beam"

    f = fc.shell_field(4)
    for id in f.scoping.ids:
        assert mesh.elements.element_by_id(id).shape == "shell"

    f = fc.solid_field(5)
    for id in f.scoping.ids:
        assert mesh.elements.element_by_id(id).shape == "solid"
Ejemplo n.º 4
0
Use Result Helpers to compare mode shapes for solids and then shells
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The `Result` class which instances are created by the `Model` gives access to
helpers to request results on specific mesh and time scopings.
With those helpers, working on a custom spatial and temporal subset of the
model is straightforward.
"""

from ansys.dpf import core as dpf
from ansys.dpf.core import examples

###############################################################################
# First, create a model object to establish a connection with an
# example result file
model = dpf.Model(examples.download_all_kinds_of_complexity_modal())
print(model)

###############################################################################
# Visualize specific mode shapes
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Choose the modes to visualize
modes = [1, 5, 10, 15]

###############################################################################
# Choose to split the displacement on solid/shell/beam to only focus on shell
# elements
disp = model.results.displacement
for mode in modes:
    fc = disp.on_time_scoping(mode).split_by_shape.eval()
    model.metadata.meshed_region.plot(fc.shell_field())
Ejemplo n.º 5
0
def test_download_all_kinds_of_complexity_modal():
    path = examples.download_all_kinds_of_complexity_modal()
    assert isinstance(Model(path), Model)