A general algorithm for accurate computation of field variables and its derivatives near the boundary in BEM