function [mapW, vmapW, mapI, vmapI, mapO, vmapO] = BuildBCMaps_PML()

% create boundary maps

Globals2D;

boundary_points = length(mapB);
mapW = zeros(boundary_points,1);
mapF = zeros(boundary_points,1);
wall_temp = 0;
far_temp = 0;
for i = 1:boundary_points
    if (((y(vmapB(i)) >= y_u - NODETOL) && (n_y(mapB(i)) == 1)) || ((y(vmapB(i)) <= y_l + NODETOL) && (n_y(mapB(i)) == -1)))
        wall_temp = wall_temp + 1;
        mapW(wall_temp) = mapB(i);
    end
    if (((x(vmapB(i)) >= x_u + D_PML - NODETOL) && (n_x(mapB(i)) == 1)) || ((x(vmapB(i)) <= x_l - D_PML + NODETOL) && (n_x(mapB(i)) == -1)))
        far_temp = far_temp + 1;
        mapF(far_temp) = mapB(i);
    end
end
mapW((wall_temp + 1):boundary_points) = [];
mapF((far_temp + 1):boundary_points) = [];
vmapW = vmapM(mapW);
vmapF = vmapM(mapF);

% vybrani prvku z mapW, ktere lezi v PML zone
mapW_PML = intersect(mapPML_M,mapW);
vmapW_PML = vmapM(mapW_PML);
% mapW = setdiff(mapW,mapW_PML);
% vmapW = vmapM(mapW);

% rozdeleni mapF na mapI (inflow) a mapO (outflow)
dotproducts = u_0 * n_x(mapF) + v_0 * n_y(mapF);
mapI_ind = find(dotproducts < -NODETOL); % pro jistotu, protoze Matlab vyhodnocuje, ze -0 < 0
mapI = mapF(mapI_ind);
vmapI = vmapM(mapI);
mapO = setdiff(mapF,mapI);
% mapO = union(mapO,mapW_PML); % prvky mapW_PML nebudou brany jako stena, ale jako outflow hranice
vmapO = vmapM(mapO);

end