CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   strange in computation of normal vector (https://www.cfd-online.com/Forums/openfoam-programming-development/223162-strange-computation-normal-vector.html)

ndtrong December 28, 2019 08:44

strange in computation of normal vector
 
3 Attachment(s)
Dear everyone,

I tried to plot the gradient of alpha.water and normal vector of interface using gradient of alpha.water with interFoam solver. And I found a thing that is quite strange for me as shown in the attached file.
Variables are defined as:
gradAlpha = fvc::grad(alpha1)
nAlphaVec = gradAlpha/(mag(gradAlpha) + epsilon)

with epsilon = 1.0e-8

I think that alpha1, gradAlpha and nAlphaVec should have the same contours, however, the contour of nAlphaVec is very different compare to 2 other ones.

Could someone help me to explain what is the reason for that.

I thank you very much

Santiago December 29, 2019 04:21

the calculation of the surface normal should be confined to a certain alpha, representing the surface for which you wish to obtain the normal. the results you obtain make sense to me (they are not what you want, but you got what you asked for).

ndtrong December 29, 2019 07:39

Quote:

Originally Posted by Santiago (Post 753367)
the calculation of the surface normal should be confined to a certain alpha, representing the surface for which you wish to obtain the normal. the results you obtain make sense to me (they are not what you want, but you got what you asked for).

Thank you Santiago for your comment.
However, I think that I do not need to confine value of alpha for surface normal, because obviously we define as:
\begin{cases} 
= 0, & \mbox{ in phase 1} \\
0 < \alpha < 1, & \mbox{in interface } \\
=1,  &\mbox{ in phase 2} \end{cases}
then out of the interface, nAlphaVec should be zero because its gradient become zero, therefore it should have the same contour as gradAlpha and alpha.water.

Thanks

Santiago December 29, 2019 09:13

Quote:

Originally Posted by ndtrong (Post 753378)
Thank you Santiago for your comment.
However, I think that I do not need to confine value of alpha for surface normal, because obviously we define as:
\begin{cases} 
= 0, & \mbox{ in phase 1} \\
0 < \alpha < 1, & \mbox{in interface } \\
=1,  &\mbox{ in phase 2} \end{cases}
then out of the interface, nAlphaVec should be zero because its gradient become zero, therefore it should have the same contour as gradAlpha and alpha.water.

Thanks

Good that you grasp the theory! But the matter here is not about how the normal vector is defined, but where is defined. A surface normal is defined, well, in a surface. In other words, in your case, the field is 2 dimensional, defined over a line (representing a free surface).

Seen in other way, the value of gradAlpha is seldom truly "machine zero", hence dividing it by a rather small value may produce spurious results. by confining the operator to where it "makes sense", the problems you see may be avoided alltogether.

ndtrong December 29, 2019 17:17

Quote:

Originally Posted by Santiago (Post 753391)
Good that you grasp the theory! But the matter here is not about how the normal vector is defined, but where is defined. A surface normal is defined, well, in a surface. In other words, in your case, the field is 2 dimensional, defined over a line (representing a free surface).

Seen in other way, the value of gradAlpha is seldom truly "machine zero", hence dividing it by a rather small value may produce spurious results. by confining the operator to where it "makes sense", the problems you see may be avoided alltogether.

Thanks for your suggestions


All times are GMT -4. The time now is 12:56.