From 3216565681bd89c29776e8fde22c927f78566553 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 20:37:20 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pymech/meshtools.py | 4 ++-- pymech/neksuite/mesh.py | 10 +++++----- tests/test_all.py | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pymech/meshtools.py b/pymech/meshtools.py index 49bacf0..8951bab 100644 --- a/pymech/meshtools.py +++ b/pymech/meshtools.py @@ -100,7 +100,7 @@ def extrude(mesh: HexaData, z, bc1="P", bc2="P", internal_bcs=True): # fix the internal boundary conditions # the end boundary conditions will be overwritten later with the proper ones if internal_bcs: - for (iel, el) in enumerate(mesh3d.elem): + for iel, el in enumerate(mesh3d.elem): for ibc in range(nbc): el.bcs[ibc, 4][0] = "E" el.bcs[ibc, 4][1] = iel + 1 @@ -1091,7 +1091,7 @@ def generate_internal_bcs(mesh, tol=1e-3): # First generate a length scale for each element, equal to the smallest edge of that element. scales = np.zeros((mesh.nel,)) - for (iel, el) in enumerate(mesh.elem): + for iel, el in enumerate(mesh.elem): scales[iel] = el.smallest_edge() # check if there is a zero length edge; in this case the mesh is invalid and there is no point continuing. diff --git a/pymech/neksuite/mesh.py b/pymech/neksuite/mesh.py index b2f8d5b..c934c80 100644 --- a/pymech/neksuite/mesh.py +++ b/pymech/neksuite/mesh.py @@ -664,7 +664,7 @@ def readre2(fname): # This is the reason for the +1 here, then the first number is ignored. buf = infile.read((ndim * npel + 1) * wdsz * nel) # elem_shape = [ndim, ndim-1, 2, 2] # nvar, lz, ly, lx - for (iel, el) in enumerate(data.elem): + for iel, el in enumerate(data.elem): fi = np.frombuffer( buf, dtype=emode + realtype, @@ -869,7 +869,7 @@ def write_data_to_file(a): # write curve sides data # locate curved edges curved_edges = [] - for (iel, el) in enumerate(data.elem): + for iel, el in enumerate(data.elem): for iedge in range(12): if el.ccurv[iedge] != "": curved_edges.append((iel, iedge)) @@ -883,7 +883,7 @@ def write_data_to_file(a): write_data_to_file(ncurvf) # format curve data cdata = np.zeros((ncurv,), dtype="f8, f8, f8, f8, f8, f8, f8, S8") - for (cdat, (iel, iedge)) in zip(cdata, curved_edges): + for cdat, (iel, iedge) in zip(cdata, curved_edges): el = data.elem[iel] cdat[0] = iel + 1 cdat[1] = iedge + 1 @@ -899,7 +899,7 @@ def write_data_to_file(a): for ifield in range(data.nbc): # locate faces with boundary conditions bc_faces = [] - for (iel, el) in enumerate(data.elem): + for iel, el in enumerate(data.elem): for iface in range(2 * ndim): bctype = el.bcs[ifield, iface][0] # internal boundary conditions are not written to .re2 files by reatore2 @@ -911,7 +911,7 @@ def write_data_to_file(a): write_data_to_file(nbcsf) # initialize and format data bcdata = np.zeros((nbcs,), dtype="f8, f8, f8, f8, f8, f8, f8, S8") - for (bc, (iel, iface)) in zip(bcdata, bc_faces): + for bc, (iel, iface) in zip(bcdata, bc_faces): el = data.elem[iel] bc[0] = iel + 1 bc[1] = iface + 1 diff --git a/tests/test_all.py b/tests/test_all.py index f10f2e7..ce4518e 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -294,7 +294,7 @@ def test_merge(test_data_dir): # check if the element/faces indices in the boundary conditions are right too, even if it may not matter assert mesh1.nbc > 0 for ibc in range(mesh1.nbc): - for (iel, el) in enumerate(mesh1.elem): + for iel, el in enumerate(mesh1.elem): for iface in range(6): assert el.bcs[ibc, iface][1] == iel + 1 assert el.bcs[ibc, iface][2] == iface + 1 @@ -327,7 +327,7 @@ def test_readre2(test_data_dir): assert meshre2.var == meshrea.var assert meshre2.lr1 == meshrea.lr1 assert meshre2.wdsz == 8 - for (el, elw) in zip(meshrea.elem, meshre2.elem): + for el, elw in zip(meshrea.elem, meshre2.elem): npt.assert_allclose(elw.pos, el.pos) npt.assert_array_equal(elw.bcs, el.bcs) npt.assert_allclose(elw.curv, el.curv) @@ -358,7 +358,7 @@ def test_readre2_3d(test_data_dir): assert meshre2.var == meshrea.var assert meshre2.lr1 == meshrea.lr1 assert meshre2.wdsz == 8 - for (el, elw) in zip(meshrea.elem, meshre2.elem): + for el, elw in zip(meshrea.elem, meshre2.elem): npt.assert_allclose(elw.pos, el.pos) npt.assert_array_equal(elw.bcs, el.bcs) npt.assert_allclose(elw.curv, el.curv) @@ -384,7 +384,7 @@ def test_writere2(test_data_dir, tmpdir): assert meshw.var == mesh.var assert meshw.lr1 == mesh.lr1 assert meshw.wdsz == 8 - for (el, elw) in zip(mesh.elem, meshw.elem): + for el, elw in zip(mesh.elem, meshw.elem): npt.assert_array_equal(elw.pos, el.pos) npt.assert_array_equal(elw.bcs, el.bcs) npt.assert_array_equal(elw.curv, el.curv) @@ -410,7 +410,7 @@ def test_writere2_3d(test_data_dir, tmpdir): assert meshw.var == mesh.var assert meshw.lr1 == mesh.lr1 assert meshw.wdsz == 8 - for (el, elw) in zip(mesh.elem, meshw.elem): + for el, elw in zip(mesh.elem, meshw.elem): npt.assert_array_equal(elw.pos, el.pos) npt.assert_array_equal(elw.bcs, el.bcs) npt.assert_array_equal(elw.curv, el.curv) @@ -429,7 +429,7 @@ def test_generate_internal_bcs(test_data_dir): meshre2 = ns.readre2(fre2) nconnect = mt.generate_internal_bcs(meshre2) assert nconnect == 54 # This is a 3x3x3 box - for (ela, el2) in zip(meshrea.elem, meshre2.elem): + for ela, el2 in zip(meshrea.elem, meshre2.elem): npt.assert_array_equal(el2.bcs, ela.bcs) assert meshre2.check_connectivity() @@ -447,7 +447,7 @@ def test_delete_internal_bcs(test_data_dir): assert ( ndelete == 108 ) # This is a 3x3x3 box, and each connection is deleted twice, one for each connected element - for (ela, el2) in zip(meshrea.elem, meshre2.elem): + for ela, el2 in zip(meshrea.elem, meshre2.elem): npt.assert_array_equal(el2.bcs, ela.bcs) assert meshrea.check_connectivity()