3333
3434class CuboidMesh (object ):
3535 def __init__ (self , dx = 1 , dy = 1 , dz = 1 , nx = 1 , ny = 1 , nz = 1 , x0 = 0 , y0 = 0 , z0 = 0 ,
36- periodicity = (False , False , False ), unit_length = 1.0 ):
36+ periodicity = (False , False , False ), unit_length = 1.0 , pbc = None ):
3737 """
3838 Create mesh with cells of size dx * dy * dz.
3939
@@ -48,6 +48,8 @@ def __init__(self, dx=1, dy=1, dz=1, nx=1, ny=1, nz=1, x0=0, y0=0, z0=0,
4848 mesh = CuboidMesh(2, 2, 2, 250, 25, 2, periodicity=(True, False, False))
4949 # create a mesh of dimensions 500 x 50 x 4 nm, with cellsize
5050 # of 2 nm in any direction and periodic along the x-axis.
51+ # Alternatively, the periodicity can be set through the option 'pbc',
52+ # acceptable parameters could be '1d' or '2d'.
5153
5254 """
5355 self .dx = dx
@@ -72,10 +74,16 @@ def __init__(self, dx=1, dy=1, dz=1, nx=1, ny=1, nz=1, x0=0, y0=0, z0=0,
7274 self .mesh_type = "cuboid"
7375 self .unit_length = unit_length
7476
77+ if pbc == '1d' :
78+ self .periodicity = (True , False , False )
79+ elif pbc == '2d' :
80+ self .periodicity = (True , True , False )
81+
7582 self .coordinates = self .init_coordinates ()
7683 self .neighbours = self .init_neighbours ()
7784 self .grid = self .init_grid () # for vtk export
7885
86+
7987 def init_coordinates (self ):
8088 coordinates = np .zeros ((self .n , 3 ))
8189 for i in range (self .nz ):
0 commit comments