Skip to content

Commit

Permalink
fix tile boundary bug
Browse files Browse the repository at this point in the history
  • Loading branch information
natj committed Aug 3, 2019
1 parent 2f127be commit 506f742
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
1 change: 0 additions & 1 deletion em-fields/filters/digital.c++
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void fields::Binomial2<2>::solve(
mesh.jx(i , j+1, k)*wts +
mesh.jx(i+1, j+1, k)*wtc;
}

mesh.jx = tmp; // then copy from scratch to original arrays

// Jy
Expand Down
23 changes: 21 additions & 2 deletions em-fields/tile.c++
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ void copy_vert_yee(
lhs.by.copy_vert(rhs.by, lhsI, rhsI);
lhs.bz.copy_vert(rhs.bz, lhsI, rhsI);

//TODO: separate into own function
lhs.jx.copy_vert(rhs.jx, lhsI, rhsI);
lhs.jy.copy_vert(rhs.jy, lhsI, rhsI);
lhs.jz.copy_vert(rhs.jz, lhsI, rhsI);
}


Expand Down Expand Up @@ -144,7 +148,12 @@ void copy_horz_yee(
lhs.bx.copy_horz(rhs.bx, lhsJ, rhsJ);
lhs.by.copy_horz(rhs.by, lhsJ, rhsJ);
lhs.bz.copy_horz(rhs.bz, lhsJ, rhsJ);
}

//TODO: separate into own function
lhs.jx.copy_horz(rhs.jx, lhsJ, rhsJ);
lhs.jy.copy_horz(rhs.jy, lhsJ, rhsJ);
lhs.jz.copy_horz(rhs.jz, lhsJ, rhsJ);
}


/// Quick helper function to add everything inside Yee lattice
Expand All @@ -171,6 +180,11 @@ void copy_face_yee(
lhs.bx.copy_face(rhs.bx, lhsK, rhsK);
lhs.by.copy_face(rhs.by, lhsK, rhsK);
lhs.bz.copy_face(rhs.bz, lhsK, rhsK);

//TODO: separate into own function
lhs.jx.copy_face(rhs.jx, lhsK, rhsK);
lhs.jy.copy_face(rhs.jy, lhsK, rhsK);
lhs.jz.copy_face(rhs.jz, lhsK, rhsK);
}


Expand Down Expand Up @@ -200,6 +214,11 @@ void copy_z_pencil_yee(
lhs.bx.copy_z_pencil(rhs.bx, lhsI, lhsJ, rhsI, rhsJ);
lhs.by.copy_z_pencil(rhs.by, lhsI, lhsJ, rhsI, rhsJ);
lhs.bz.copy_z_pencil(rhs.bz, lhsI, lhsJ, rhsI, rhsJ);

//TODO: separate into own function
lhs.jx.copy_z_pencil(rhs.jx, lhsI, lhsJ, rhsI, rhsJ);
lhs.jy.copy_z_pencil(rhs.jy, lhsI, lhsJ, rhsI, rhsJ);
lhs.jz.copy_z_pencil(rhs.jz, lhsI, lhsJ, rhsI, rhsJ);
}

void add_z_pencil_yee(
Expand Down Expand Up @@ -284,7 +303,7 @@ void Tile<2>::update_boundaries(corgi::Grid<2>& grid)


/*
FIXME: this is how we should loop over H>1 halo boundaries
FIXME: this is how we should loop over H>1 halo boundaries
for(int h=1; h<= halo; h++)
copy_vert_yee(mesh, mleft, -h, mleft.Nx-h);
Expand Down
1 change: 1 addition & 0 deletions pic/boundaries/piston.c++
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void pic::Piston<2>::field_bc(
yee.ey(i,j,k) = 0.0;
yee.ez(i,j,k) = 0.0;

//TODO: suppress also parallel current?
//yee.jx(i,j,k) = 0.0;
yee.jy(i,j,k) = 0.0;
yee.jz(i,j,k) = 0.0;
Expand Down
16 changes: 9 additions & 7 deletions projects/shocks/pic.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ def insert_em(grid, conf):
timer.start_comp("clear_vir_cur")
debug_print(grid, "clear_vir_cur")

#clear virtual current arrays for easier addition after mpi
for cid in grid.get_virtual_tiles():
tile = grid.get_tile(cid)
tile.clear_current()
Expand Down Expand Up @@ -665,26 +666,27 @@ def insert_em(grid, conf):
for fj in range(conf.npasses):

#filter each tile
for cid in grid.get_tile_ids():
for cid in grid.get_local_tiles():
tile = grid.get_tile(cid)
flt.solve(tile)

#clean current behind piston
#TODO: is this needed now after filtering only?
piston.field_bc(tile)

#mpi
grid.send_data(0)
grid.recv_data(0)
grid.wait_data(0)

#get halo boundaries
for cid in grid.get_tile_ids():
for cid in grid.get_local_tiles():
tile = grid.get_tile(cid)
tile.exchange_currents(grid)
tile.update_boundaries(grid)

MPI.COMM_WORLD.barrier() # sync everybody

#clean current behind piston
for cid in grid.get_local_tiles():
tile = grid.get_tile(cid)
piston.field_bc(tile)

#--------------------------------------------------
timer.stop_comp("filter")

Expand Down

0 comments on commit 506f742

Please sign in to comment.