OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
test_splines.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!|| test_spline ../starter/source/materials/tools/test_splines.F
25!||--- calls -----------------------------------------------------
26!|| spline_interpol_2d ../starter/source/materials/tools/spline_interpol_2d.F
27!||====================================================================
28 SUBROUTINE test_spline(NPT0,NSUB,XF,YF,XX,YY)
29C-----------------------------------------------
30C D e s c r i p t i o n
31C-----------------------------------------------
32 !compute SPLINE length with third order method (SIMPSON)
33 ! INPUT - LOCAL_PT : 4 control points P0,P1,P2,P3
34 ! INPUT - ALPHA : CCR SPLINE PARAMETER
35 ! INPUT - T : position [0,1] on SPLINE [T1,T2]. 1.0 means full spline length
36 ! OUTPUT - LEN : length of the curve parametrised with t in [0,T] T<=1.0
37C-----------------------------------------------
38C I m p l i c i t T y p e s
39C-----------------------------------------------
40#include "implicit_f.inc"
41C-----------------------------------------------
42C D u m m y A r g u m e n t s
43C-----------------------------------------------
44 INTEGER ,INTENT(IN) :: NPT0 ! number of points of input function
45 INTEGER ,INTENT(IN) :: NSUB !
46 my_real ,DIMENSION(NPT0) ,INTENT(IN) :: xf,yf ! initial curve coordinates
47 my_real ,DIMENSION((NPT0-1)*NSUB+1) ,INTENT(OUT) :: xx,yy ! curve coordinates build with splines
48C-----------------------------------------------
49C L o c a l V a r i a b l e s
50C-----------------------------------------------
51 INTEGER :: I,J,K,NPTS,NSEG
52 my_real :: tt,dx,dy,nx,ny
53 my_real ,DIMENSION(:,:) ,ALLOCATABLE :: spline_knots
54 my_real ,DIMENSION(:) ,ALLOCATABLE :: ctrl_ptx,ctrl_pty
55 my_real ,DIMENSION(4) :: ptx,pty,knots
56 my_real ,PARAMETER :: alpha = 0.5
57C-----------------------------------------------
58C S o u r c e L i n e s
59c=======================================================================
60 npts = npt0 + 2
61 nseg = npt0 - 1
62
63 ALLOCATE (ctrl_ptx(npts))
64 ALLOCATE (ctrl_pty(npts))
65 ALLOCATE (spline_knots(nseg,4))
66
67c calculate spline control points
68 ctrl_ptx(2:npts-1) = xf(1:npt0)
69 ctrl_pty(2:npts-1) = yf(1:npt0)
70 ! Add start point - minimum of bending energy
71 ctrl_ptx(1) = (half*ctrl_ptx(2) - four*ctrl_ptx(3) + ctrl_ptx(4)) * half
72 ctrl_pty(1) = (half*ctrl_pty(2) - four*ctrl_pty(3) + ctrl_pty(4)) * half
73 ! Add end point - minimum of bending energy
74 ctrl_ptx(npts) = (ctrl_ptx(npts-3) - four*ctrl_ptx(npts-2) + five*ctrl_ptx(npts-1)) * half
75 ctrl_pty(npts) = (ctrl_pty(npts-3) - four*ctrl_pty(npts-2) + five*ctrl_pty(npts-1)) * half
76c
77 k = 0
78 DO i = 1,nseg
79 ptx(1) = ctrl_ptx(i)
80 ptx(2) = ctrl_ptx(i+1)
81 ptx(3) = ctrl_ptx(i+2)
82 ptx(4) = ctrl_ptx(i+3)
83 pty(1) = ctrl_pty(i)
84 pty(2) = ctrl_pty(i+1)
85 pty(3) = ctrl_pty(i+2)
86 pty(4) = ctrl_pty(i+3)
87c
88 knots(1) = zero
89 dx = ptx(2) - ptx(1)
90 dy = pty(2) - pty(1)
91 knots(2) = spline_knots(i,1) + exp(alpha*log(sqrt(dx**2 + dy**2)))
92 dx = ptx(3) - ptx(2)
93 dy = pty(3) - pty(2)
94 knots(3) = knots(2) + exp(alpha*log(sqrt(dx**2 + dy**2)))
95 dx = ptx(4) - ptx(3)
96 dy = pty(4) - pty(3)
97 knots(4) = knots(3) + exp(alpha*log(sqrt(dx**2 + dy**2)))
98 spline_knots(i,1:4) = knots(1:4)
99c
100 DO j = 1,nsub
101 tt = (j-one) / nsub
102 k = k + 1
103 CALL spline_interpol_2d(ptx, pty ,knots, tt, nx ,ny )
104 xx(k) = nx
105 yy(k) = ny
106 ENDDO
107
108 ENDDO
109 ! last point
110 tt = one
111 k = k + 1
112 xx(k) = xf(npt0)
113 yy(k) = yf(npt0)
114
115c CALL SPLINE_INTERPOL_2D(PTX, PTY ,KNOTS, TT, NX ,NY )
116c XX(K) = NX
117c YY(K) = NY
118c
119 DEALLOCATE (spline_knots)
120 DEALLOCATE (ctrl_pty)
121 DEALLOCATE (ctrl_ptx)
122c-----------
123 RETURN
124 END SUBROUTINE
#define my_real
Definition cppsort.cpp:32
#define alpha
Definition eval.h:35
subroutine spline_interpol_2d(ptx, pty, knots, t, nx, ny)
subroutine test_spline(npt0, nsub, xf, yf, xx, yy)