Skip to content

Commit 6b45ee8

Browse files
author
Weiwei Wang
committed
change neighbours for cuboid mesh with periodic boundary conditions
1 parent 09af800 commit 6b45ee8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

fidimag/common/cuboid_mesh.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,24 @@ def init_neighbours(self):
147147
self.index(k, j, i + 1), # over
148148
]]
149149

150-
n_neighbours = [other for other in [
150+
nngbs = [other for other in [
151151
self.index(k - 2, j, i), # left
152152
self.index(k + 2, j, i), # right
153153
self.index(k, j - 2, i), # behind
154154
self.index(k, j + 2, i), # in front
155155
self.index(k, j, i - 2), # under
156156
self.index(k, j, i + 2), # over
157157
]]
158+
159+
# July 1st, 2016 Weiwei: I think it's okay for a cell with its neighbour is itself
160+
# if periodic boundary conditions are used. For example, if we only have cell and enable
161+
# periodic boundary condition in x-direction, then we got a rod.
162+
# therefore, I commented two lines below.
158163
# no cell should be its own neighbour
159-
neighbours = [other if other != cell
160-
else -1 for other in ngbs]
161-
next_neighbours = [other if other != cell
162-
else -1 for other in n_neighbours]
163-
connectivity.append(neighbours)
164-
connectivity_next.append(next_neighbours)
164+
# neighbours = [other if other != cell
165+
# else -1 for other in ngbs]
166+
connectivity.append(ngbs)
167+
connectivity_next.append(nngbs)
165168

166169
return np.array(connectivity, dtype=np.int32), np.array(connectivity_next, dtype=np.int32)
167170

fidimag/common/cuboid_mesh_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def test_neighbours_x_periodic_all():
125125
126126
"""
127127
mesh = CuboidMesh(1, 1, 1, 2, 1, 1, periodicity=(True, True, True))
128-
assert allclose(mesh.neighbours, np.array(((1, 1, -1, -1, -1, -1), (0, 0, -1, -1, -1, -1))))
128+
#assert allclose(mesh.neighbours, np.array(((1, 1, -1, -1, -1, -1), (0, 0, -1, -1, -1, -1))))
129+
assert allclose(mesh.neighbours, np.array(((1, 1, 0, 0, 0, 0), (0, 0, 1, 1, 1, 1))))
129130

130131

131132
def test_neighbours_y():

0 commit comments

Comments
 (0)