Salome HOME
Remapper: added new P1P1 method: MappedBarycentric. See doc
[tools/medcoupling.git] / doc / user / doxygen / doxfiles / reference / interpolation / mapped_bary.dox
1 /*!
2 \page mapped_bary Mapped barycentric coordinates algorithm
3
4 Mapped barycentric intersection type ('MappedBarycentric') can be selected in space dim 2 (resp. 3) when
5 working with quadrangle only (resp. hexaedrons only).
6
7 It can only be used for P1P1 projection: for any point P within the quadrangle or the hexaedron, the 
8 set of reduced coordinates is computed (x, y, z all comprised between 0 and 1).
9 Then the field value at P is computed using the usual form functions of finite element method 
10 ((1-x)*(1-y), x*(1-y), (1-x)*y and x*y in 2D for example). 
11
12 The algorithm used to compute the reduced coordinates differs in dim 2 and dim 3.
13
14 \section mapped_bary2d Dimension 2
15
16 Let O, A, B, C the four points of the quadrangle, clockwise. Without loss of generality 
17 O is assumed to be the origin.
18 A point P within the quadrangle is identified with vector OP and simply denoted P.
19
20 A suitable mapping is such that, if (x,y) is the couple of reduced coordinates (with x and y both in [0,1])
21  of a point P, then:
22 \f[   \mathbf{P} = x\mathbf{C} + y\mathbf{A} + xy(\mathbf{B}- \mathbf{A}-\mathbf{C}) \f]
23
24 This forms is the simplest one having a gradient which x component is constant in x, and similarly in y. 
25 Furthermore the reduced coordinates 
26 (0,0) (resp. (0,1), (1,0), and (1,1)) map to point O (resp. A, B, and C).
27
28 Calling \f$\mathbf{N} = \mathbf{B}-\mathbf{A}-\mathbf{C}\f$ and developping for the 2 compos:
29
30 \f[   p_x = C_x x + A_x y + N_x xy \f]
31 \f[   p_y = C_y x + A_y y + N_y xy \f]
32
33 Solving the first eq for x:
34 \f[ x = \frac{p_x - y A_x }{C_x+yN_x}  \f]
35
36 and injecting in second eq:
37 \f[   (A_yN_x -N_yA_x)y^2 + (-p_yN_x -A_xC_y +A_yC_x+N_yp_x)y + (p_x C_y-p_yC_x)=0   \f] 
38 solved in:
39 \f[  y = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2a} \f]
40 where a, b and c are the coeffs of the 2nd order eq.
41
42 This gives two possible couples of solution among which only one is in \f$[0,1]^2\f$.
43
44 In case where \f$A_yN_x -N_yA_x = 0 \f$ we have a degenerated unique solution for $y$
45 \f[ y = \frac{c}{b} \f]
46
47 \subsection{Rectangle}
48
49 Finally it is worth puting aside the case \f$\mathbf{N} = 0\f$ (rectangle), which boils down to solving an ordinary
50 2-unknows system:
51 \f[ x = \frac{p_x A_y - p_y A_x}{C_x A_y - C_y A_x}, y = \frac{C_x p_y-C_y p_x}{C_x A_y - C_y A_x} \f]
52
53
54 \section mapped_bary3d Dimension 3  
55
56 In three dimensions, adopting the same approach as above would lead to a 4th order equation to solve.
57 A simpler approach has been chosen: the distance to each pair of parallel faces in the hexaedron is computed.   
58 The ratios to the sum of the two distances is computed giving again a number between 0 and 1 for each of 
59 the 3 directions.
60
61 */