On Thu, 27 Aug 2009, matei wrote:
>
> Jimmy,
> I have just uploaded a working script called shockCD_EZ that shows the
> problem of a shock passing over a triangle. Remember that PSI gives
> the distance from any grid point to the closest solid boundary. Based
> on this rationale, you can easily construct any desired shape.
> matei
Your simulation looks fine, but your definition of PSI is actually
incorrect. From the apex of the triangle the level set should appear as a
sector of concentric arcs and not as a sharp corner as you have it. This
sector is bounded by the normals to the front and back sides of
the obstacle.
Jimmy, first try plotting Matei's PSI. You can do this by adding:
rgb<1,0,0>
plot PSI[] contours
to the end of the procedure DrawObstacleBody. You should then convince
yourself that the distance to the apex, in the aforementioned sector, is
indeed a series of concentric arcs. When you've done that, try modifying
the PSI function to give the correct distance function. Don't worry if you
get stuck, as I will post a model solution next week. But it's important
that you try it yourself first.
In this particular instance Matei's error in the distance function
is probably unimportant. Nevertheless, for completeness I
thought I should point it out.
James
>
> Thank you all,
>
> I uploaded the working script "Shock_triangle", which produces
> concentric circles at the triangle apex for the shortest distance
> function.
>
> Let me know if there are other ways of doing it.
Your approach is about the best that can be done, although
I would have written the script slightly differently.
For instance, I would lean towards using:
S1 ::= cos(rad($alpha+90))*(Y[]-$Y2)-sin(rad($alpha+90))*(X[]-($X1+$Y2/tan(rad($alpha))))
S2 ::= ($Y2-Y[])
PSI1 ::= -cos(rad($alpha))*(Y[]-$Y1)+sin(rad($alpha))*(X[]-$X1)
PSI2 ::= -sqrt((Y[]-$Y2)**2+(X[]-($X1+$Y2/tan(rad($alpha))))**2)
PSI3 ::= ($X1+$Y2/tan(rad($alpha)))-X[]
PSI ::= S1[]<0 && S2[]<0 ? PSI2[] : min(PSI1[],PSI3[])
where S1 and S2 mark the sector in which one needs to consider the
distance to the apex.
I would then have refactored it to:
set X2 #= $X1+$Y2/tan(rad($alpha))
S1 ::= cos(rad($alpha+90))*(Y[]-$Y2)-sin(rad($alpha+90))*(X[]-$X2)
S2 ::= ($Y2-Y[])
PSI1 ::= -cos(rad($alpha))*(Y[]-$Y1)+sin(rad($alpha))*(X[]-$X1)
PSI2 ::= -sqrt((Y[]-$Y2)**2+(X[]-$X2)**2)
PSI3 ::= $X2-X[]
PSI ::= S1[]<0 && S2[]<0 ? PSI2[] : min(PSI1[],PSI3[])
which, with the aid of complex variables, can then be reduced to:
set alpha = rad($alpha)
set X2 #= $X1+$Y2/tan($alpha)
Z ::= {X[]-$X2,Y[]-$Y2}
S1 ::= Im(Z[]*exp({0,PI+$alpha})))
S2 ::= -Im(Z[])
PSI1 ::= Im(Z[]*exp({0,PI-$alpha}))
PSI2 ::= -abs(Z[])
PSI3 ::= -Re(Z[])
PSI ::= S1[]<0 && S2[]<0 ? PSI2[] : min(PSI1[],PSI3[])
James
>
> Jimmy