function b = applyDirichletBoundaryConditionsRightSide(b, mesh, pGroup, f)

accessRow = mesh.BoundaryEdges(mesh.GBoundaryEdges == pGroup);
firstNode  = mesh.edges(accessRow ,1);
secondNode = mesh.edges(accessRow ,2);
allNodes = vertcat(firstNode, secondNode);
accessRow = unique(allNodes);

if isa(f,'function_handle')
  for i=accessRow'
    x = mesh.P(1,i);
    y = mesh.P(2,i);
    b(i) = f(x,y);
  end
else
  for i=accessRow'
    b(i) = f(i);
  end
end