Non-parametric optimal shape design of a magnetic device for biomedical applications