OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
dist_node_seg3n.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!|| dist_node_seg3n ../engine/source/tools/sensor/dist_node_seg3n.F
25!||--- called by ------------------------------------------------------
26!|| sensor_dist_surf0 ../engine/source/tools/sensor/sensor_dist_surf0.F
27!||====================================================================
28 SUBROUTINE dist_node_seg3n (
29 . DIST,DMIN,DMAX,NOD_X,NOD_Y,NOD_Z,
30 . AX,AY,AZ,BX,BY,BZ,CX,CY,CZ)
31c-----------------------------------------------------------------------
32c Calculates distance between NODE(NOD_X,NOD_Y,NOD_Z) and a 3 node segment (A-B-C)
33c returns distance to plane if node projection is inside the segment
34c otherwise : check closest distance to edges and segment points
35c-----------------------------------------------------------------------
36C I m p l i c i t T y p e s
37C-----------------------------------------------
38#include "implicit_f.inc"
39C-----------------------------------------------
40C D u m m y A r g u m e n t s
41C-----------------------------------------------
42 my_real , INTENT(IN) :: dmin,dmax,nod_x,nod_y,nod_z,
43 . ax,ay,az,bx,by,bz,cx,cy,cz
44 my_real , INTENT(OUT) :: dist
45C----------------------------------------------------------
46C Local Variables
47C----------------------------------------------------------
48 my_real :: abx,aby,abz,acx,acy,acz,bcx,bcy,bcz,vecx,vecy,vecz,nx,ny,nz,
49 . ux,uy,uz,vx,vy,vz,wx,wy,wz,qx,qy,qz,qa_x,qa_y,qa_z,qb_x,qb_y,qb_z,
50 . qc_x,qc_y,qc_z,area,a1,a2,sx,sy,sz,alpha,alpha2,d1,d2,d3,len,norm
51C=======================================================================
52c vect AB = P1-P2
53c vect AC = P1-P3
54 abx = bx - ax
55 aby = by - ay
56 abz = bz - az
57 acx = cx - ax
58 acy = cy - ay
59 acz = cz - az
60 bcx = cx - bx
61 bcy = cy - by
62 bcz = cz - bz
63 ux = nod_x - ax
64 uy = nod_y - ay
65 uz = nod_z - az
66c normal to segment plane
67 nx = aby*acz - abz*acy
68 ny = abz*acx - abx*acz
69 nz = abx*acy - aby*acx
70 norm = sqrt(nx*nx + ny*ny + nz*nz)
71c distance to plane
72 dist = abs(nx*ux + ny*uy + nz*uz) / norm
73
74 IF (dist > dmax .or. dist < dmin) RETURN ! distance is outside of valid range
75c---------------------------------------------------
76c Check if projection on segment plane is inside
77c Q = projection of NODE on segment plane using normal(NPX,NPY,NPZ)
78c---------------------------------------------------
79 qx = nod_x - dist*nx / norm
80 qy = nod_y - dist*ny / norm
81 qz = nod_z - dist*nz / norm
82 qa_x = ax - qx
83 qa_y = ay - qy
84 qa_z = az - qz
85 qb_x = bx - qx
86 qb_y = by - qy
87 qb_z = bz - qz
88 qc_x = cx - qx
89 qc_y = cy - qy
90 qc_z = cz - qz
91c
92c Surfaces de sous-triangles
93c
94 sx = qa_y * qb_z - qa_z * qb_y
95 sy = qa_z * qb_x - qa_x * qb_z
96 sz = qa_x * qb_y - qa_y * qb_x
97 a1 = sqrt(sx*sx + sy*sy + sz*sz) * half
98 sx = qc_y * qa_z - qc_z * qa_y
99 sy = qc_z * qa_x - qc_x * qa_z
100 sz = qc_x * qa_y - qc_y * qa_x
101 a2 = sqrt(sx*sx + sy*sy + sz*sz) * half
102 area = half*norm ! total segment area
103c
104 IF (a1 + a2 > area) THEN
105 ! Point projection on plane is outside the segment
106 ! calculate distance to segment nodes
107 d1 = sqrt(ux**2 + uy**2 + uz**2)
108 vx = nod_x - bx
109 vy = nod_y - by
110 vz = nod_z - bz
111 d2 = sqrt(vx**2 + vy**2 + vz**2)
112 dist = min(d1, d2)
113 wx = nod_x - cx
114 wy = nod_y - cy
115 wz = nod_z - cz
116 d3 = sqrt(wx**2 + wy**2 + wz**2)
117 dist = min(dist, d2)
118 ! calculate distance to edges
119 len = sqrt(abx**2 + aby**2 + abz**2)
120 alpha = (ux*abx + uy*aby + uz*abz) / len
121 IF (alpha > 0 .and. alpha < one) THEN
122 qx = ax + alpha * abx
123 qy = ay + alpha * aby
124 qz = az + alpha * abz
125 d1 = sqrt((nod_x - qx)**2 + (nod_y - qy)**2 + (nod_z - qz)**2)
126 dist = min(dist, d1)
127 END IF
128c
129 len = sqrt(bcx**2 + bcy**2 + bcz**2)
130 alpha = (vx*bcx + vy*bcy + vz*bcz) / len
131 IF (alpha > 0 .and. alpha < one) THEN
132 qx = bx + alpha * bcx
133 qy = by + alpha * bcy
134 qz = bz + alpha * bcz
135 d2 = sqrt((nod_x - qx)**2 + (nod_y - qy)**2 + (nod_z - qz)**2)
136 dist = min(dist, d2)
137 END IF
138c
139 len = sqrt(acx**2 + acy**2 + acz**2)
140 alpha = (ux*acx + uy*acy + uz*acz) / len
141 IF (alpha > 0 .and. alpha < one) THEN
142 qx = ax + alpha * acx
143 qy = ay + alpha * acy
144 qz = az + alpha * acz
145 d3 = sqrt((nod_x - qx)**2 + (nod_y - qy)**2 + (nod_z - qz)**2)
146 dist = min(dist, d3)
147 END IF
148c
149 END IF
150c-----------
151 RETURN
152 END SUBROUTINE
153
#define my_real
Definition cppsort.cpp:32
norm(diag(diag(diag(inv(mat))) -id.SOL), 2) % destroy mumps instance id.JOB
subroutine dist_node_seg3n(dist, dmin, dmax, nod_x, nod_y, nod_z, ax, ay, az, bx, by, bz, cx, cy, cz)
#define alpha2
Definition eval.h:48
#define alpha
Definition eval.h:35
subroutine area(d1, x, x2, y, y2, eint, stif0)
#define min(a, b)
Definition macros.h:20