OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
vw_smooth.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!|| vw_smooth ../starter/source/tools/curve/vw_smooth.F
25!||--- called by ------------------------------------------------------
26!|| law70_table ../starter/source/materials/mat/mat070/law70_table.F
27!|| law70_upd ../starter/source/materials/mat/mat070/law70_upd.F
28!||====================================================================
29 SUBROUTINE vw_smooth(NPT,NTARGET,X,Y)
30C-----------------------------------------------
31C I m p l i c i t T y p e s
32C-----------------------------------------------
33#include "implicit_f.inc"
34C-----------------------------------------------
35 INTEGER ,INTENT(INOUT) :: NPT ! number of input function points
36 INTEGER ,INTENT(IN) :: NTARGET ! target length of abscissa vector
37 my_real ,DIMENSION(NPT) ,INTENT(INOUT) :: x,y
38C-----------------------------------------------
39C L o c a l V a r i a b l e s
40C-----------------------------------------------
41 INTEGER :: I,I0,I1,I2,IDX,IMIN,IPREV,INEXT,ITER,NITER,IZERO
42 my_real :: amin,aa,s,t
43 INTEGER ,DIMENSION(NPT) :: PREV,NEXT
44 my_real ,DIMENSION(NPT) :: area
45c-----------------------------------------------
46c smooth input curve using Visvalingam-Whyatt algorithm
47c reduce number of points from NPT to NTARGET
48c first and last points are never eliminated, as well as (0,0)
49c=======================================================================
50 niter = npt - ntarget
51 IF (niter < 1) RETURN
52
53 prev(1) = 0
54 next(1) = 2
55 area(1) = infinity / ten
56 prev(npt) = npt - 1
57 next(npt) = 10000000
58 area(npt) = infinity / ten
59c
60 DO i = 2,npt-1
61 i1 = i-1
62 i2 = i+1
63 prev(i) = i1
64 next(i) = i2
65 IF (x(i) == zero .and. y(i) == zero) THEN
66 area(i) = infinity / ten
67 ELSE
68 area(i) = x(i1)*y(i) + x(i)*y(i2) + x(i2)*y(i1)
69 . - x(i1)*y(i2) - x(i)*y(i1) - x(i2)*y(i)
70 area(i) = abs(area(i))
71 END IF
72 END DO
73c----------------------------------------------------
74c eliminate points with min area until NPT = target number of points
75c----------------------------------------------------
76 imin = 1
77 DO iter = 1,niter
78 amin = infinity
79 idx = 1
80 DO i=1,npt
81 IF (area(i) < amin) THEN
82 amin = area(i)
83 imin = i
84 ENDIF
85 END DO
86c
87 iprev = prev(imin)
88 inext = next(imin)
89 next(iprev) = inext
90 prev(inext) = iprev
91 area(imin) = infinity
92c
93 ! recalculate PREV POINT AREA
94 i0 = iprev
95 i1 = prev(iprev)
96 i2 = inext
97 IF (i1 > 0) THEN
98 aa = x(i0)*y(i0) + x(i0)*y(i2) + x(i2)*y(i1)
99 . - x(i0)*y(i2) - x(i0)*y(i1) - x(i2)*y(i0)
100 area(i0) = abs(aa)
101 END IF
102c
103 ! recalculate NEXT POINT AREA
104 i0 = inext
105 i1 = iprev
106 i2 = next(inext)
107 IF (i2 < npt) THEN
108 aa = x(i0)*y(i0) + x(i0)*y(i2) + x(i2)*y(i1)
109 . - x(i0)*y(i2) - x(i0)*y(i1) - x(i2)*y(i0)
110 area(i0) = abs(aa)
111 END IF
112 END DO ! ITER
113c------------
114 idx = 0
115 DO i=1,npt
116 IF (area(i) < infinity) THEN
117 idx = idx + 1
118 x(idx) = x(i)
119 y(idx) = y(i)
120 END IF
121 END DO
122 npt = 0
123 izero = 0
124 DO i = 1,idx
125 s = x(i)
126 t = y(i)
127 IF (s < zero .and. t > zero .or.
128 . s > zero .and. t < zero .or.
129 . s == zero .and. t /= zero) THEN
130 IF (izero == 1) CONTINUE
131 s = zero
132 t = zero
133 izero = 1
134 ELSE IF (s < zero .and. t < zero .and.
135 . x(i+1) > zero .and. y(i+1) > zero) THEN ! .or.
136! . S > ZERO .and. T > ZERO .and.
137! . X(I-1) < ZERO .and. Y(I-1) < ZERO .and. I > 1) THEN
138 IF (izero == 1) CONTINUE
139 s = zero
140 t = zero
141 izero = 1
142 END IF
143 npt = npt + 1
144 x(npt) = s
145 y(npt) = t
146 END DO
147c-----------
148 RETURN
149 END
150
#define my_real
Definition cppsort.cpp:32
subroutine area(d1, x, x2, y, y2, eint, stif0)
subroutine vw_smooth(npt, ntarget, x, y)
Definition vw_smooth.F:30