Relative position of a particle in a cell
From MohidWiki
A fundamental in the "MOHID system" lagrangian approach is to know the relative position of the tracer in the hydrodynamic cell to speed up the interpolation procedure. This is quite easy for square cells however this not the case for cells of curvilinear grids . In this case was develop a subroutine that is able to compute the generic position of a tracer in a generic cell (see subroutine RelativePosition4VertPolygon in module functions). The algorithm used is described below.
<mathtex> y_1 = a_1 + b_1 x_1 \wedge a_1 = {{x_d y_c - x_c y_d } \over {x_d - x_c }} \wedge b_1 = {{y_d - y{}_c} \over {x_d - x_c }} </mathtex>
if (b1==b2) then else endif
if (b3==b4) then else endif