			
			if (k==0){ // Top layer of verticies: Affects only the top layer of cells
				if ((i>0) && (i < (Nx-1))) {
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==0){
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
				}
				else if (i==0) {
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==0){
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
				}
				else if (i==(Nx-1)){
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==0){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
				}
			}
			else if (k==1){ // Middle layer of verticies : Affects both the top and the bottom layer of cells
				if ((i>0) && (i < (Nx-1))) {
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
					else if (j==0){
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
				}
				else if (i==0) {
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = -1;
					}
					else if (j==0){
						V_cells[id_tmp][0] = Cell_Id_Z(i, j, 0, Nx, Ny);
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = Cell_Id_Z(i, j-1, 0, Nx, Ny);
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = -1;
					}
				}
				else if (i==(Nx-1)){
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
					else if (j==0){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = Cell_Id_Z(i-1, j, 0, Nx, Ny);
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = Cell_Id_Z(i-1, j-1, 0, Nx, Ny);
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
				}
			}
			else { // Top layer of verticies
				if ((i>0) && (i < (Nx-1))) {
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
					else if (j==0){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
				}
				else if (i==0) {
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = -1;
					}
					else if (j==0){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = Cell_Id_Z(i, j, 1, Nx, Ny);
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = Cell_Id_Z(i, j-1, 1, Nx, Ny);
						V_cells[id_tmp][7] = -1;
					}
				}
				else if (i==(Nx-1)){
					if ((j>0) && (j<(Ny-1))) {
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
					else if (j==0){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = Cell_Id_Z(i-1, j, 1, Nx, Ny);
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = -1;
					}
					else if (j==(Ny-1)){
						V_cells[id_tmp][0] = -1;
						V_cells[id_tmp][1] = -1;
						V_cells[id_tmp][2] = -1;
						V_cells[id_tmp][3] = -1;
						
						V_cells[id_tmp][4] = -1;
						V_cells[id_tmp][5] = -1;
						V_cells[id_tmp][6] = -1;
						V_cells[id_tmp][7] = Cell_Id_Z(i-1, j-1, 1, Nx, Ny);
					}
				}
			}


