Hello Dr Amine,

Thanks for quick reply. I am happy to know this is working for your small case and this gives me hope that I will also be able to use it.

But I am not able to understand what you mean by valid gradients to use that function. It it related to mesh refinement? or solution initialization? or distribution of phases in the domain? or Should I put a condition on the gradient instead of volume fraction in if statement?

Could you please elaborate what do you mean by “you need to have the gradients valid to use that function” ? 


Just to let you know the test case I am trying to check this UDF is: 

A domain Box ranging from (-5mm,-5mm,0) to (5mm,5mm,100mm). This domain is meshed in 10 equal cubic cells with edge size of 10mm. So these are only 10cells in the domain.

Then I  initialize the solution with as from z ranging from 0 to 40, water is one, from 40 to 50 water is 0.75 and from 50 to 100 water is 0. I run the simulation for few time step without hooking the udf. Then I hook the udf and run again but following error appears

Error: received a fatal signal (Segmentation fault).

Error Object: #f

Looking forward for your answer