Skip to content

Commit

Permalink
Correct values to account for the issue in the mesh_skin operator
Browse files Browse the repository at this point in the history
  • Loading branch information
rafacanton committed Oct 13, 2023
1 parent 7675dc6 commit d71c794
Showing 1 changed file with 154 additions and 43 deletions.
197 changes: 154 additions & 43 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0,
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_6_2,
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0,
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1,
)


Expand Down Expand Up @@ -663,7 +664,10 @@ def test_skin_layer3(self, static_simulation: post.StaticMechanicalSimulation):
result = static_simulation.elastic_strain_eqv_von_mises_elemental(
skin=[1, 2, 3]
)
assert len(result.index.mesh_index) == 18
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 14
else:
assert len(result.index.mesh_index) == 18

def test_skin_layer4(self, static_simulation: post.StaticMechanicalSimulation):
result = static_simulation.stress_principal_nodal(skin=[1, 2, 3])
Expand All @@ -675,7 +679,10 @@ def test_skin_layer5(self, static_simulation: post.StaticMechanicalSimulation):

def test_skin_layer6(self, static_simulation: post.StaticMechanicalSimulation):
result = static_simulation.stress_principal_elemental(skin=[1, 2, 3])
assert len(result.index.mesh_index) == 18
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 14
else:
assert len(result.index.mesh_index) == 18


class TestTransientMechanicalSimulation:
Expand Down Expand Up @@ -1305,7 +1312,10 @@ def test_external_layer(
def test_skin_layer(self, transient_simulation: post.TransientMechanicalSimulation):
result = transient_simulation.displacement(all_sets=True, skin=True)
assert len(result.columns.set_ids) == 20
assert len(result.index.mesh_index) == 393
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 374
else:
assert len(result.index.mesh_index) == 393
assert np.allclose(
result.select(set_ids=[2]).max(axis="node_ids").array,
[5.14806800e-07, 1.63151192e-03, 9.78100326e-06],
Expand All @@ -1323,29 +1333,41 @@ def test_skin_layer3(
result = transient_simulation.stress_principal_elemental(
skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 240
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 124
else:
assert len(result.index.mesh_index) == 240

def test_skin_layer4(
self, transient_simulation: post.TransientMechanicalSimulation
):
result = transient_simulation.elastic_strain_eqv_von_mises_elemental(
skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 240
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 124
else:
assert len(result.index.mesh_index) == 240

def test_skin_layer5(
self, transient_simulation: post.TransientMechanicalSimulation
):
result = transient_simulation.stress_principal_nodal(skin=list(range(1, 100)))
assert len(result.index.mesh_index) == 393
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 374
else:
assert len(result.index.mesh_index) == 393

def test_skin_layer6(
self, transient_simulation: post.TransientMechanicalSimulation
):
result = transient_simulation.elastic_strain_eqv_von_mises_nodal(
skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 393
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 374
else:
assert len(result.index.mesh_index) == 393


class TestModalMechanicalSimulation:
Expand Down Expand Up @@ -1967,7 +1989,10 @@ def test_strain_external_layer3(
def test_disp_skin(self, frame_modal_simulation: post.ModalMechanicalSimulation):
result = frame_modal_simulation.displacement(set_ids=[1], skin=True)
result_all = frame_modal_simulation.displacement(set_ids=[1], skin=False)
assert len(result.index.mesh_index) == 5828
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4068
else:
assert len(result.index.mesh_index) == 5828
assert np.allclose(
result.max(axis="node_ids").array, [0.05656421, 9.59989137, 1.08656671]
)
Expand All @@ -1978,44 +2003,81 @@ def test_disp_skin(self, frame_modal_simulation: post.ModalMechanicalSimulation)
)

def test_stress_skin(self, frame_modal_simulation: post.ModalMechanicalSimulation):
if frame_modal_simulation._model._server.meet_version("6.2"):
if frame_modal_simulation._model._server.meet_version("7.1"):
result = frame_modal_simulation.stress_elemental(all_sets=True, skin=True)
assert len(result.index.mesh_index) == 2048
assert len(result.columns.set_ids) == 6
elif frame_modal_simulation._model._server.meet_version("6.2"):
result = frame_modal_simulation.stress_elemental(all_sets=True, skin=True)
assert len(result.index.mesh_index) == 11146
assert len(result.columns.set_ids) == 6
result = frame_modal_simulation.stress_elemental(
set_ids=[1], skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 110
assert len(result.columns.set_ids) == 1
assert np.allclose(
result.max(axis="element_ids").array,
[
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 36
assert np.allclose(
result.max(axis="element_ids").array,
[
36.52192259,
58.73246002,
371.72294617,
25.97949378,
139.83338165,
69.25232569,
]
],
)
[
36.52192259,
58.73246002,
371.72294617,
12.80614456,
134.60557556,
38.0447108,
]
],
)
else:
assert len(result.index.mesh_index) == 110
assert np.allclose(
result.max(axis="element_ids").array,
[
[
36.52192259,
58.73246002,
371.72294617,
25.97949378,
139.83338165,
69.25232569,
]
],
)

def test_stress_skin2(self, frame_modal_simulation: post.ModalMechanicalSimulation):
result = frame_modal_simulation.stress_eqv_von_mises_nodal(
set_ids=[1], skin=frame_modal_simulation.mesh.element_ids
)
assert len(result.index.mesh_index) == 5828
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4068
assert np.allclose(result.max(axis="node_ids").array, [1295.83764693])
else:
assert len(result.index.mesh_index) == 5828
assert np.allclose(result.max(axis="node_ids").array, [1285.17926915])
assert len(result.columns.set_ids) == 1
assert np.allclose(result.max(axis="node_ids").array, [1285.17926915])
result = frame_modal_simulation.stress_eqv_von_mises_nodal(
set_ids=[1], skin=True
)
assert len(result.index.mesh_index) == 5828
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4068
else:
assert len(result.index.mesh_index) == 5828
assert len(result.columns.set_ids) == 1

def test_strain_skin(self, frame_modal_simulation: post.ModalMechanicalSimulation):
if frame_modal_simulation._model._server.meet_version("6.2"):
if frame_modal_simulation._model._server.meet_version("7.1"):
result = frame_modal_simulation.stress_principal_elemental(
all_sets=True, skin=True
)
assert len(result.index.mesh_index) == 2048
assert len(result.columns.set_ids) == 6
assert np.allclose(
result.select(set_ids=[1]).max(axis="element_ids").array,
[1339.75343629],
)
elif frame_modal_simulation._model._server.meet_version("6.2"):
result = frame_modal_simulation.stress_principal_elemental(
all_sets=True, skin=True
)
Expand All @@ -2028,32 +2090,48 @@ def test_strain_skin(self, frame_modal_simulation: post.ModalMechanicalSimulatio
result = frame_modal_simulation.stress_principal_elemental(
set_ids=[1], skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 110
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 36
else:
assert len(result.index.mesh_index) == 110
assert len(result.columns.set_ids) == 1

def test_strain_skin2(self, frame_modal_simulation: post.ModalMechanicalSimulation):
result = frame_modal_simulation.elastic_strain_eqv_von_mises_nodal(
set_ids=[1], skin=frame_modal_simulation.mesh.element_ids
)
assert len(result.index.mesh_index) == 5828
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4068
assert np.allclose(result.max(axis="node_ids").array, [0.00695066])
else:
assert len(result.index.mesh_index) == 5828
assert np.allclose(result.max(axis="node_ids").array, [0.00684776])
assert len(result.columns.set_ids) == 1
assert np.allclose(result.max(axis="node_ids").array, [0.00684776])

def test_strain_skin3(self, frame_modal_simulation: post.ModalMechanicalSimulation):
result = frame_modal_simulation.elastic_strain_eqv_von_mises_nodal(
set_ids=[1], skin=True
)
assert len(result.index.mesh_index) == 5828
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4068
else:
assert len(result.index.mesh_index) == 5828
assert len(result.columns.set_ids) == 1
result = frame_modal_simulation.elastic_strain_principal_nodal(
set_ids=[1], skin=frame_modal_simulation.mesh.element_ids
)
assert len(result.index.mesh_index) == 5828
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4068
else:
assert len(result.index.mesh_index) == 5828
assert len(result.columns.set_ids) == 1
result = frame_modal_simulation.elastic_strain_eqv_von_mises_elemental(
set_ids=[1], skin=True
)
assert len(result.index.mesh_index) == 11146
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 2048
else:
assert len(result.index.mesh_index) == 11146
assert len(result.columns.set_ids) == 1


Expand Down Expand Up @@ -2665,7 +2743,10 @@ def test_disp_skin(self, harmonic_simulation: post.HarmonicMechanicalSimulation)
if harmonic_simulation._model._server.meet_version("6.2"):
result = harmonic_simulation.displacement(set_ids=[1], skin=True)
result_all = harmonic_simulation.displacement(set_ids=[1], skin=False)
assert len(result.index.mesh_index) == 4802
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4184
else:
assert len(result.index.mesh_index) == 4802
assert np.allclose(
result.select(complex=0).max(axis="node_ids").array,
[2.76941713e-09, 2.76940199e-09, 4.10914311e-10],
Expand All @@ -2676,58 +2757,88 @@ def test_disp_skin(self, harmonic_simulation: post.HarmonicMechanicalSimulation)
def test_stress_skin(self, harmonic_simulation: post.HarmonicMechanicalSimulation):
if harmonic_simulation._model._server.meet_version("6.2"):
result = harmonic_simulation.stress_elemental(all_sets=True, skin=True)
assert len(result.index.mesh_index) == 3942
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 1394
else:
assert len(result.index.mesh_index) == 3942
assert len(result.columns.set_ids) == 1
result = harmonic_simulation.stress_elemental(
set_ids=[1], skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 192
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 122
else:
assert len(result.index.mesh_index) == 192
assert len(result.columns.set_ids) == 1
result = harmonic_simulation.stress_eqv_von_mises_nodal(
set_ids=[1], skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 530
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 520
else:
assert len(result.index.mesh_index) == 530
assert len(result.columns.set_ids) == 1
result = harmonic_simulation.stress_eqv_von_mises_nodal(
set_ids=[1], skin=True
)
assert len(result.index.mesh_index) == 4802
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4184
else:
assert len(result.index.mesh_index) == 4802
assert len(result.columns.set_ids) == 1

def test_strain_skin(self, harmonic_simulation: post.HarmonicMechanicalSimulation):
if harmonic_simulation._model._server.meet_version("6.2"):
result = harmonic_simulation.stress_principal_elemental(
all_sets=True, skin=True
)
assert len(result.index.mesh_index) == 3942
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 1394
else:
assert len(result.index.mesh_index) == 3942
assert len(result.columns.set_ids) == 1
result = harmonic_simulation.stress_principal_elemental(
set_ids=[1], skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 192
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 122
else:
assert len(result.index.mesh_index) == 192
assert len(result.columns.set_ids) == 1
result = harmonic_simulation.elastic_strain_eqv_von_mises_nodal(
set_ids=[1], skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 530
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 520
else:
assert len(result.index.mesh_index) == 530
assert len(result.columns.set_ids) == 1
assert np.allclose(
result.select(complex=0).max(axis="node_ids").array, [1.34699501e-06]
)
result = harmonic_simulation.elastic_strain_eqv_von_mises_nodal(
set_ids=[1], skin=True
)
assert len(result.index.mesh_index) == 4802
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 4184
else:
assert len(result.index.mesh_index) == 4802
assert len(result.columns.set_ids) == 1
result = harmonic_simulation.elastic_strain_principal_nodal(
set_ids=[1], skin=list(range(1, 100))
)
assert len(result.index.mesh_index) == 530
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 520
else:
assert len(result.index.mesh_index) == 530
assert len(result.columns.set_ids) == 1
result = harmonic_simulation.elastic_strain_eqv_von_mises_elemental(
set_ids=[1], skin=True
)
assert len(result.index.mesh_index) == 3942
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1:
assert len(result.index.mesh_index) == 1394
else:
assert len(result.index.mesh_index) == 3942
assert len(result.columns.set_ids) == 1


Expand Down

0 comments on commit d71c794

Please sign in to comment.