0
$\begingroup$

I am writing code to simulate a cylinder (with symmetric axis on "z-plane"), containing a fluid (meeting at a boundary). One of the physics equations requires using the divergence theorem, where I think the required "outward" unit normal at the solid/fluid interface will be the "inward" unit normal from the lateral surface going into the fluid.

Here is what I tried

Equation of cylinder of radius r and length h is $F(x,y,z) = x^2 + y^2 - r^2$

Normal is $$\vec{n} = \frac{\nabla{F}}{\sqrt{(\frac{\partial{F}}{\partial{x}})^2 + (\frac{\partial{F}}{\partial{y}})^2 + (\frac{\partial{F}}{\partial{z}})^2}}$$ $$ = \begin{bmatrix}(\frac{x}{r}) \\ (\frac{y}{r}) \\ 0\end{bmatrix}$$

but my calculus is rusty and I am not confident about this.

(1) Is this correct, including the sign?

(2) How can I obtain the two unit tangential vectors from this?

(3) Also, when I did this for 2D using a rectangle for the solid and a rectangle for the fluid, then at the boundary, this outward unit normal was simply (-1,0) pointing into the fluid from the solid part, and the corresponding unit tangential vector was (1,0). I am not sure how to do something similar in 3D.

$\endgroup$

1 Answer 1

1
$\begingroup$

In general for the normal of a level set of some scalar function $F$, you need to know whether $F$ is bigger inside or outside the level set in order to know whether the gradient of $F$ points in or out. In your case $F$ is bigger on the outside, so the gradient points outward.

If you want to simply use the normal to find a pair of tangent vectors, you can do that by obtaining two independent solutions to $n \cdot v=0$. So here you have

$$\frac{x}{r} v_1 + \frac{y}{r} v_2 + 0 v_3 = 0.$$

One solution is obtained by taking $v_2=1,v_3=0$, another is obtained by taking $v_2=0,v_3=1$. So assuming $x \neq 0$, two tangent vectors are $\begin{bmatrix} -\frac{y}{x} \\ 1 \\ 0 \end{bmatrix}$ and $\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}$. The latter is of course already unit. Attempting to make the former unit reveals a way to simplify it to remove the assumption $x \neq 0$, giving $\begin{bmatrix} -y/r \\ x/r \\ 0 \end{bmatrix}$.

You could also have come up with this last vector by noticing that $\begin{bmatrix} x/r \\ y/r \\ 0 \end{bmatrix}=\begin{bmatrix} \cos(\theta) \\ \sin(\theta) \\ 0 \end{bmatrix}$, and then you can "take the negative reciprocal of the slope" by exchanging the $x$ and $y$ components and flipping one of the signs. This also avoids any need to normalize.

I don't really understand your third question.

$\endgroup$
7
  • $\begingroup$ Thank you! I am accepting this because you have gotten me really close to what I need. I only have a couple of things left unclear. (a) First, no I don't only need the normal, I need both the tangent and the normal. Since the normal I found is outward facing, will the inward one simply be that vector multiplied by -1? (b) My third question was that in the 2D case, the tangential vector at the "boundary" between solid and fluid was not dependent on x or y, but rather only numerical. Must the tangents and normals in the 3D case depend on x and y at that boundary? Sorry this isn't my background. $\endgroup$
    – Cogicero
    Mar 11, 2020 at 23:06
  • 1
    $\begingroup$ @Cogicero Sure, you can flip the sign to get the inward normal. As for the other thing, if there is a flat face then you can have a constant normal and constant tangent vectors on that flat face. Of course that can't be true over a whole closed surface. (For example, the outward unit normal of a square is $(-1,0)$ on the left, $(1,0)$ on the right, $(0,1)$ on the top, and $(0,-1)$ on the bottom. It is not well-defined at the corners.) $\endgroup$
    – Ian
    Mar 11, 2020 at 23:07
  • $\begingroup$ Thank you so much! I wish I had time on this project, to brush up on multivariable calculus. I appreciate this a lot. $\endgroup$
    – Cogicero
    Mar 11, 2020 at 23:08
  • $\begingroup$ P.S. I have realized that I made a mistake. The cylinder of radius r and height h, which I'm working with, is actually also hollow with a thickness T, so my original equation for the cylinder is wrong. I have googled to no avail and can't seem to find an equation for such a cylinder. Please do you have any pointers? Then I can re-do all the calculations that you did above. Thanks again. $\endgroup$
    – Cogicero
    Mar 12, 2020 at 12:39
  • $\begingroup$ @Cogicero So what do you need now? The normals and tangent vectors on the inner and outer (mathematical) cylinders? A parametrization of the solid interior? If the former, say the outer cylinder has radius $R$ then the inner cylinder has radius $R-T$ and basically everything goes the same on the inner cylinder except that out and in are reversed on the inner cylinder. $\endgroup$
    – Ian
    Mar 12, 2020 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .