|
1 | 1 | import numpy as np |
2 | 2 | import pytest |
3 | | - |
4 | 3 | from ansys import dpf |
5 | 4 | from ansys.dpf import core |
6 | 5 | from ansys.dpf.core import FieldDefinition |
7 | 6 | from ansys.dpf.core import operators as ops |
8 | 7 | from ansys.dpf.core.common import locations, shell_layers |
| 8 | + |
9 | 9 | from conftest import local_server |
10 | 10 |
|
11 | 11 |
|
@@ -1005,99 +1005,6 @@ def test_dot_operator_field(): |
1005 | 1005 | assert np.allclose(out.data, -field.data) |
1006 | 1006 |
|
1007 | 1007 |
|
1008 | | -def test_add_operator_server_field(): |
1009 | | - field = dpf.core.fields_factory.create_3d_vector_field(2, server=local_server) |
1010 | | - field.data = [0., 1., 2., 3., 4., 5.] |
1011 | | - field.scoping.ids = [1, 2] |
1012 | | - |
1013 | | - # field+op |
1014 | | - forward = ops.utility.forward_field(field, server=local_server) |
1015 | | - add = field + forward |
1016 | | - assert isinstance(add, ops.math.add) |
1017 | | - out = add.outputs.field() |
1018 | | - assert out.scoping.ids == [1, 2] |
1019 | | - assert np.allclose(out.data, np.array(field.data) * 2.0) |
1020 | | - |
1021 | | - # field + list |
1022 | | - add = field + [0., 1., 2.] |
1023 | | - assert isinstance(add, ops.math.add) |
1024 | | - out = add.outputs.field() |
1025 | | - assert len(out) == 6 |
1026 | | - assert out.scoping.ids == [1, 2] |
1027 | | - assert np.allclose(out.data, field.data + np.array([[0., 1., 2.], [0., 1., 2.]])) |
1028 | | - |
1029 | | - # field + float |
1030 | | - add = field + 1.0 |
1031 | | - assert isinstance(add, ops.math.add) |
1032 | | - out = add.outputs.field() |
1033 | | - assert out.scoping.ids == [1, 2] |
1034 | | - assert np.allclose(out.data, np.array([[1., 2., 3.], [4., 5., 6.]])) |
1035 | | - |
1036 | | - |
1037 | | -def test_minus_operator_server_field(): |
1038 | | - field = dpf.core.fields_factory.create_3d_vector_field(2, server=local_server) |
1039 | | - field.data = [0., 1., 2., 3., 4., 5.] |
1040 | | - field.scoping.ids = [1, 2] |
1041 | | - |
1042 | | - # field-op |
1043 | | - forward = ops.utility.forward_field(field, server=local_server) |
1044 | | - add = field - forward |
1045 | | - assert isinstance(add, ops.math.minus) |
1046 | | - out = add.outputs.field() |
1047 | | - assert len(out) == 6 |
1048 | | - assert out.scoping.ids == [1, 2] |
1049 | | - assert np.allclose(out.data, np.zeros((2, 3))) |
1050 | | - |
1051 | | - # fc - list |
1052 | | - add = field - [0., 1., 2.] |
1053 | | - assert isinstance(add, ops.math.minus) |
1054 | | - out = add.outputs.field() |
1055 | | - assert out.scoping.ids == [1, 2] |
1056 | | - assert np.allclose(out.data, np.array([[0., 0., 0.], [3., 3., 3.]])) |
1057 | | - |
1058 | | - # operator - float |
1059 | | - add = field - 1.0 |
1060 | | - assert isinstance(add, ops.math.minus) |
1061 | | - out = add.outputs.field() |
1062 | | - assert out.scoping.ids == [1, 2] |
1063 | | - assert np.allclose(out.data, np.array([[-1., 0., 1.], [2., 3., 4.]])) |
1064 | | - |
1065 | | - |
1066 | | -def test_dot_operator_server_field(): |
1067 | | - field = dpf.core.fields_factory.create_3d_vector_field(2, server=local_server) |
1068 | | - field.data = [0., 1., 2., 3., 4., 5.] |
1069 | | - field.scoping.ids = [1, 2] |
1070 | | - |
1071 | | - # field * op |
1072 | | - forward = ops.utility.forward_field(field, server=local_server) |
1073 | | - add = field * forward |
1074 | | - assert type(add) == ops.math.generalized_inner_product |
1075 | | - out = add.outputs.field() |
1076 | | - assert out.scoping.ids == [1, 2] |
1077 | | - assert np.allclose(out.data, np.array([5., 50.])) |
1078 | | - |
1079 | | - # field * field |
1080 | | - add = field * field |
1081 | | - assert isinstance(add, ops.math.generalized_inner_product) |
1082 | | - out = add.outputs.field() |
1083 | | - assert out.scoping.ids == [1, 2] |
1084 | | - assert np.allclose(out.data, np.array([5., 50.])) |
1085 | | - |
1086 | | - # field * list |
1087 | | - add = field * [0., 1., 2.] |
1088 | | - assert isinstance(add, ops.math.generalized_inner_product) |
1089 | | - out = add.outputs.field() |
1090 | | - assert out.scoping.ids == [1, 2] |
1091 | | - assert np.allclose(out.data, np.array([5., 14.])) |
1092 | | - |
1093 | | - # field * float |
1094 | | - add = field * -1.0 |
1095 | | - assert isinstance(add, ops.math.generalized_inner_product) |
1096 | | - out = add.outputs.field() |
1097 | | - assert out.scoping.ids == [1, 2] |
1098 | | - assert np.allclose(out.data, -field.data) |
1099 | | - |
1100 | | - |
1101 | 1008 | def test_add_operator_server_field(): |
1102 | 1009 | field = dpf.core.fields_factory.create_3d_vector_field(2, server=local_server) |
1103 | 1010 | field.data = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] |
|
0 commit comments