From 07af7b2f988fb548ad6d134337aecc51984a9f48 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 23 Aug 2020 10:46:15 +0200 Subject: [PATCH] geom is written to vtr exlcusively, not to general vtk base tests on vtr --- python/damask/_geom.py | 20 +++++++------ python/tests/reference/Geom/clean.vtr | 25 ++++++++++++++++ .../tests/reference/Geom/clean_2_1_False.vtr | 25 ++++++++++++++++ .../tests/reference/Geom/clean_2_1_True.vtr | 25 ++++++++++++++++ .../reference/Geom/clean_2_None_False.vtr | 25 ++++++++++++++++ .../reference/Geom/clean_2_None_True.vtr | 25 ++++++++++++++++ .../tests/reference/Geom/clean_3_1_False.vtr | 25 ++++++++++++++++ .../tests/reference/Geom/clean_3_1_True.vtr | 25 ++++++++++++++++ .../reference/Geom/clean_3_None_False.vtr | 25 ++++++++++++++++ .../reference/Geom/clean_3_None_True.vtr | 25 ++++++++++++++++ .../tests/reference/Geom/clean_4_1_False.vtr | 25 ++++++++++++++++ .../tests/reference/Geom/clean_4_1_True.vtr | 25 ++++++++++++++++ .../reference/Geom/clean_4_None_False.vtr | 25 ++++++++++++++++ .../reference/Geom/clean_4_None_True.vtr | 25 ++++++++++++++++ .../tests/reference/Geom/clean_stencil=1.geom | 25 ---------------- .../tests/reference/Geom/clean_stencil=2.geom | 25 ---------------- .../tests/reference/Geom/clean_stencil=3.geom | 25 ---------------- .../tests/reference/Geom/clean_stencil=4.geom | 25 ---------------- python/tests/test_Geom.py | 30 +++++++++++-------- 19 files changed, 354 insertions(+), 121 deletions(-) create mode 100644 python/tests/reference/Geom/clean.vtr create mode 100644 python/tests/reference/Geom/clean_2_1_False.vtr create mode 100644 python/tests/reference/Geom/clean_2_1_True.vtr create mode 100644 python/tests/reference/Geom/clean_2_None_False.vtr create mode 100644 python/tests/reference/Geom/clean_2_None_True.vtr create mode 100644 python/tests/reference/Geom/clean_3_1_False.vtr create mode 100644 python/tests/reference/Geom/clean_3_1_True.vtr create mode 100644 python/tests/reference/Geom/clean_3_None_False.vtr create mode 100644 python/tests/reference/Geom/clean_3_None_True.vtr create mode 100644 python/tests/reference/Geom/clean_4_1_False.vtr create mode 100644 python/tests/reference/Geom/clean_4_1_True.vtr create mode 100644 python/tests/reference/Geom/clean_4_None_False.vtr create mode 100644 python/tests/reference/Geom/clean_4_None_True.vtr delete mode 100644 python/tests/reference/Geom/clean_stencil=1.geom delete mode 100644 python/tests/reference/Geom/clean_stencil=2.geom delete mode 100644 python/tests/reference/Geom/clean_stencil=3.geom delete mode 100644 python/tests/reference/Geom/clean_stencil=4.geom diff --git a/python/damask/_geom.py b/python/damask/_geom.py index 2f7f18066..722df2524 100644 --- a/python/damask/_geom.py +++ b/python/damask/_geom.py @@ -347,17 +347,18 @@ class Geom: @staticmethod - def from_vtk(fname): + def from_vtr(fname): """ - Read a geom from a VTK file. + Read a VTK rectilinear grid. Parameters ---------- - fname : str or file handle + fname : str or or pathlib.Path Geometry file to read. + Valid extension is .vtr, it will be appended if not given. """ - g = VTK.from_file(fname).geom + g = VTK.from_file(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr').geom grid = np.array(g.GetDimensions())-1 bbox = np.array(g.GetBounds()).reshape(3,2).T size = bbox[1] - bbox[0] @@ -513,21 +514,22 @@ class Geom: f.write(f'{reps} of {former}\n') - def to_vtk(self,fname=None): + def to_vtr(self,fname=None): """ - Generates vtk file. + Generates vtk rectilinear grid. Parameters ---------- fname : str, optional - Vtk file to write. If no file is given, a string is returned. + Filename to write. If no file is given, a string is returned. + Valid extension is .vtr, it will be appended if not given. """ v = VTK.from_rectilinearGrid(self.grid,self.size,self.origin) v.add(self.microstructure.flatten(order='F'),'materialpoint') if fname: - v.write(fname) + v.write(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr') else: sys.stdout.write(v.__repr__()) @@ -642,7 +644,7 @@ class Geom: grid/self.get_grid(), output=self.microstructure.dtype, order=0, - mode=('wrap' if periodic else 'nearest'), + mode=('wrap' if periodic else 'nearest'), prefilter=False ) ) diff --git a/python/tests/reference/Geom/clean.vtr b/python/tests/reference/Geom/clean.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_2_1_False.vtr b/python/tests/reference/Geom/clean_2_1_False.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean_2_1_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_2_1_True.vtr b/python/tests/reference/Geom/clean_2_1_True.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean_2_1_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_2_None_False.vtr b/python/tests/reference/Geom/clean_2_None_False.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean_2_None_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_2_None_True.vtr b/python/tests/reference/Geom/clean_2_None_True.vtr new file mode 100644 index 000000000..fe04087d2 --- /dev/null +++ b/python/tests/reference/Geom/clean_2_None_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAAMQAAAA==eF7tzCEOADAMxLDr/v/o8pLSaTMwi1JJCoAvnGHrN7f/AAAAAAAAAAAAeE8DQvkLTQ== + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_3_1_False.vtr b/python/tests/reference/Geom/clean_3_1_False.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean_3_1_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_3_1_True.vtr b/python/tests/reference/Geom/clean_3_1_True.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean_3_1_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_3_None_False.vtr b/python/tests/reference/Geom/clean_3_None_False.vtr new file mode 100644 index 000000000..c2ad86f43 --- /dev/null +++ b/python/tests/reference/Geom/clean_3_None_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAAOgAAAA==eF7t1CEOACAMBMHS/z8aXwNJSagYMe6y8jIislgNtTW9d9oD/PL6r6b3AAAAAAAAAAAA4MYGlRYLYA== + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_3_None_True.vtr b/python/tests/reference/Geom/clean_3_None_True.vtr new file mode 100644 index 000000000..b4d19ebcf --- /dev/null +++ b/python/tests/reference/Geom/clean_3_None_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANwAAAA==eF7t1KERADAMA7Gk+w9dWpYCswiI+R66q6rDzmPa/kj3ALZK/2m6BwAAAAAAAAAAAJMLZrELTQ== + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_4_1_False.vtr b/python/tests/reference/Geom/clean_4_1_False.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean_4_1_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_4_1_True.vtr b/python/tests/reference/Geom/clean_4_1_True.vtr new file mode 100644 index 000000000..c76ce3988 --- /dev/null +++ b/python/tests/reference/Geom/clean_4_1_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CECACAMxLBj/380fhYwIyK2spWkmnWgt6b3AF65/avfegAAAAAAAAAAAMy0AfYtC2k= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_4_None_False.vtr b/python/tests/reference/Geom/clean_4_None_False.vtr new file mode 100644 index 000000000..811d7dc8f --- /dev/null +++ b/python/tests/reference/Geom/clean_4_None_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAAOQAAAA==eF7t1CESACAMA8HS/z8aX4OgCGDFuszJZERkMTbU1us9gFO6/+q23moPAAAAAAAAAADAnybPzQto + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_4_None_True.vtr b/python/tests/reference/Geom/clean_4_None_True.vtr new file mode 100644 index 000000000..88a8643d9 --- /dev/null +++ b/python/tests/reference/Geom/clean_4_None_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAAJAAAAA==eF7twwEJAAAMBKH7/qWXY6DgqqmqqqqqqqqqqqqqPnhyUwtB + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_stencil=1.geom b/python/tests/reference/Geom/clean_stencil=1.geom deleted file mode 100644 index 3e6f6fe9c..000000000 --- a/python/tests/reference/Geom/clean_stencil=1.geom +++ /dev/null @@ -1,25 +0,0 @@ -4 header -grid a 8 b 5 c 4 -size x 8e-06 y 5e-06 z 4e-06 -origin x 0.0 y 0.0 z 0.0 -homogenization 1 - 1 1 1 1 1 1 1 1 - 1 1 1 1 1 1 1 1 - 1 1 1 1 1 1 1 1 - 1 1 1 1 1 1 1 1 - 1 1 1 1 1 1 1 1 - 2 3 4 5 6 7 8 9 -10 11 12 13 14 15 16 17 -18 19 20 21 22 23 24 25 -26 27 28 29 30 31 32 33 -34 35 36 37 38 39 40 41 - 2 2 2 2 2 2 2 2 - 2 2 2 2 2 2 2 2 - 2 2 2 2 2 2 2 2 - 2 2 2 2 2 2 2 2 - 2 2 2 2 2 2 2 2 - 1 2 3 4 5 6 7 8 - 9 10 11 12 13 14 15 16 -17 18 19 20 21 22 23 24 -25 26 27 28 29 30 31 32 -33 34 35 36 37 38 39 40 diff --git a/python/tests/reference/Geom/clean_stencil=2.geom b/python/tests/reference/Geom/clean_stencil=2.geom deleted file mode 100644 index 14c1fa5e2..000000000 --- a/python/tests/reference/Geom/clean_stencil=2.geom +++ /dev/null @@ -1,25 +0,0 @@ -4 header -grid a 8 b 5 c 4 -size x 8e-06 y 5e-06 z 4e-06 -origin x 0.0 y 0.0 z 0.0 -homogenization 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -1 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 diff --git a/python/tests/reference/Geom/clean_stencil=3.geom b/python/tests/reference/Geom/clean_stencil=3.geom deleted file mode 100644 index 3aea8ffa5..000000000 --- a/python/tests/reference/Geom/clean_stencil=3.geom +++ /dev/null @@ -1,25 +0,0 @@ -4 header -grid a 8 b 5 c 4 -size x 8e-06 y 5e-06 z 4e-06 -origin x 0.0 y 0.0 z 0.0 -homogenization 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -2 2 1 1 1 1 1 1 -2 2 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 diff --git a/python/tests/reference/Geom/clean_stencil=4.geom b/python/tests/reference/Geom/clean_stencil=4.geom deleted file mode 100644 index 595e04b23..000000000 --- a/python/tests/reference/Geom/clean_stencil=4.geom +++ /dev/null @@ -1,25 +0,0 @@ -4 header -grid a 8 b 5 c 4 -size x 8e-06 y 5e-06 z 4e-06 -origin x 0.0 y 0.0 z 0.0 -homogenization 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -2 2 2 2 1 1 1 1 -2 2 2 2 1 1 1 1 -2 2 2 2 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 -2 2 2 2 2 2 2 2 diff --git a/python/tests/test_Geom.py b/python/tests/test_Geom.py index d037a2a65..0ac633152 100644 --- a/python/tests/test_Geom.py +++ b/python/tests/test_Geom.py @@ -69,23 +69,23 @@ class TestGeom: new = Geom.from_file(f) assert geom_equal(new,default) - def test_read_write_vtk(self,default,tmpdir): - default.to_vtk(tmpdir/'default') + def test_read_write_vtr(self,default,tmpdir): + default.to_vtr(tmpdir/'default') for _ in range(10): time.sleep(.2) if os.path.exists(tmpdir/'default.vtr'): break - new = Geom.from_vtk(tmpdir/'default.vtr') + new = Geom.from_vtr(tmpdir/'default.vtr') assert geom_equal(new,default) - def test_invalid_vtk(self,tmpdir): + def test_invalid_vtr(self,tmpdir): v = VTK.from_rectilinearGrid(np.random.randint(5,10,3)*2,np.random.random(3) + 1.0) v.write(tmpdir/'no_materialpoint.vtr') for _ in range(10): time.sleep(.2) if os.path.exists(tmpdir/'no_materialpoint.vtr'): break with pytest.raises(ValueError): - Geom.from_vtk(tmpdir/'no_materialpoint.vtr') + Geom.from_vtr(tmpdir/'no_materialpoint.vtr') @pytest.mark.parametrize('pack',[True,False]) @@ -136,13 +136,19 @@ class TestGeom: assert geom_equal(modified,Geom.from_file(reference)) @pytest.mark.parametrize('stencil',[1,2,3,4]) - def test_clean(self,default,update,reference_dir,stencil): - modified = default.copy() - modified.clean(stencil) - tag = f'stencil={stencil}' - reference = reference_dir/f'clean_{tag}.geom' - if update: modified.to_file(reference) - assert geom_equal(modified,Geom.from_file(reference)) + @pytest.mark.parametrize('selection',[None,1]) + @pytest.mark.parametrize('periodic',[True,False]) + def test_clean(self,update,reference_dir,stencil,selection,periodic): + current = Geom.from_vtr((reference_dir/'clean').with_suffix('.vtr')) + current.clean(stencil,None if selection is None else [selection],periodic) + reference = reference_dir/f'clean_{stencil}_{selection}_{periodic}' + altered = stencil !=1 and selection is not None + if update and stencil !=1: + current.to_vtr(reference) + for _ in range(10): + time.sleep(.2) + if os.path.exists(reference.with_suffix('.vtr')): break + assert geom_equal(current,Geom.from_vtr(reference if stencil !=1 else reference_dir/'clean')) @pytest.mark.parametrize('grid',[ (10,11,10),