Dear Dr. Amine, 

I have tried everything but the udf is giving error in 3D case while it is working in 2D. I initialized the above 3d case in all possible ways but always getting the segmentation fault error:  

Error: received a fatal signal (Segmentation fault).

Error Object: #f

I am requesting your attention on this. If you could spare some time to check this on a simple 3d case I would be greatfull to you (I know it is too much to ask but I am stuck on this and there is no help from the mannual).