OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
i12_nearest_seg.F
Go to the documentation of this file.
1Copyright> OpenRadioss
2Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3Copyright>
4Copyright> This program is free software: you can redistribute it and/or modify
5Copyright> it under the terms of the GNU Affero General Public License as published by
6Copyright> the Free Software Foundation, either version 3 of the License, or
7Copyright> (at your option) any later version.
8Copyright>
9Copyright> This program is distributed in the hope that it will be useful,
10Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12Copyright> GNU Affero General Public License for more details.
13Copyright>
14Copyright> You should have received a copy of the GNU Affero General Public License
15Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16Copyright>
17Copyright>
18Copyright> Commercial Alternative: Altair Radioss Software
19Copyright>
20Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21Copyright> software under a commercial license. Contact Altair to discuss further if the
22Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23!||====================================================================
24!|| i12_nearest_seg ../engine/source/interfaces/inter3d/i12_nearest_seg.F
25!||--- called by ------------------------------------------------------
26!|| i12msr3 ../engine/source/interfaces/inter3d/i12msr3.F
27!||====================================================================
28 SUBROUTINE i12_nearest_seg(XS, XM, IS, M1, M2, M3, LSEG, LSEG_NEW, BMIN, BMAX)
29C
30C COMPUTE BARYCENTRIC COORDINATES OF PROJECTION OF NODE IS ON TRIANGLE M1 M2 M3
31C WOLFGANG HEIDRICH, 2005
32C-----------------------------------------------
33C I m p l i c i t T y p e s
34C-----------------------------------------------
35#include "implicit_f.inc"
36C-----------------------------------------------
37C D u m m y A r g u m e n t s
38C-----------------------------------------------
39 INTEGER, INTENT(IN) :: IS, M1, M2, M3, LSEG
40 INTEGER, INTENT(OUT) :: LSEG_NEW
41 my_real, INTENT(IN) :: xs(3,*), xm(3,*)
42 my_real, INTENT(OUT) :: bmin
43 my_real, INTENT(INOUT) :: bmax
44C-----------------------------------------------
45C L o c a l V a r i a b l e s
46C-----------------------------------------------
47 my_real n(3), u(3), v(3), w(3), uw(3), wv(3)
48 my_real b0, b1, b2, fac
49C-------------------------------------------------
50 u(1)=xm(1,m2)-xm(1,m1)
51 u(2)=xm(2,m2)-xm(2,m1)
52 u(3)=xm(3,m2)-xm(3,m1)
53C
54 v(1)=xm(1,m3)-xm(1,m1)
55 v(2)=xm(2,m3)-xm(2,m1)
56 v(3)=xm(3,m3)-xm(3,m1)
57C
58 n(1)=u(2)*v(3)-u(3)*v(2)
59 n(2)=u(3)*v(1)-u(1)*v(3)
60 n(3)=u(1)*v(2)-u(2)*v(1)
61C
62 w(1)=xs(1,is)-xm(1,m1)
63 w(2)=xs(2,is)-xm(2,m1)
64 w(3)=xs(3,is)-xm(3,m1)
65C
66 uw(1)=u(2)*w(3)-u(3)*w(2)
67 uw(2)=u(3)*w(1)-u(1)*w(3)
68 uw(3)=u(1)*w(2)-u(2)*w(1)
69C
70 wv(1)=w(2)*v(3)-w(3)*v(2)
71 wv(2)=w(3)*v(1)-w(1)*v(3)
72 wv(3)=w(1)*v(2)-w(2)*v(1)
73C
74 fac=one/(n(1)*n(1)+n(2)*n(2)+n(3)*n(3))
75 b2 =(uw(1)*n(1)+uw(2)*n(2)+uw(3)*n(3))*fac
76 b1 =(wv(1)*n(1)+wv(2)*n(2)+wv(3)*n(3))*fac
77 b0 = one - b1 - b2
78 bmin=min(b0,b1,b2)
79C BMIN > 0 Projection est a l'interieur du triangle
80C BMIN = 0 Projection est sur un cote du triangle
81C BMIN < 0 Projection est a l'exterieur du triangle
82 IF(bmin > bmax) THEN
83 lseg_new=lseg
84 bmax=bmin
85 ENDIF
86 RETURN
87 END
#define my_real
Definition cppsort.cpp:32
subroutine i12_nearest_seg(xs, xm, is, m1, m2, m3, lseg, lseg_new, bmin, bmax)
#define min(a, b)
Definition macros.h:20