1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998-2021 Guido Dhondt
4!
5!     This program is free software; you can redistribute it and/or
6!     modify it under the terms of the GNU General Public License as
7!     published by the Free Software Foundation(version 2);
8!
9!
10!     This program is distributed in the hope that it will be useful,
11!     but WITHOUT ANY WARRANTY; without even the implied warranty of
12!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!     GNU General Public License for more details.
14!
15!     You should have received a copy of the GNU General Public License
16!     along with this program; if not, write to the Free Software
17!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18!
19      subroutine anisomaxwavspd(elas,rho,iorth,wavspd)
20!
21!     Calculates the propagation wave speed in a material, up to its 21
22!     constants. Subroutine for calcmatwavsps.f
23
24!     Based on the procedure in:
25!     C. Lane. The Development of a 2D Ultrasonic Array Inspection
26!     for Single Crystal Turbine Blades.
27!     Switzerland: Springer International Publishing, 2014.
28!
29!      CARLO MONJARAZ TEC (CMT)
30!
31!       INPUT:
32!
33!       elas: double(21) - The elasticity vector, containing 21 entries.
34!             Non used are zero. If material is orthotropic, values are
35!             rearranged to match indexes from anisotropic
36!             material card.
37!
38!        rho: double - Density of the material
39!
40!       iorth: INTEGER - if the value is 1 : material is iorthtropic
41!                        for other vaules:   material is anisotropic
42!
43!       OUTPUT:
44!
45!       wavspd
46!
47      implicit none
48!
49      integer i,j,k,im,imin,jm,jmin,iorth
50!
51      real*8 elas(21),c(3,3,3,3),rho,xi(-1:1,-1:1),et(-1:1,-1:1),
52     &       wavspd,d1,distmin,a
53!
54!
55!
56c      write(*,*)'++cMT: calculating max. speed in ANISOTROPIC...'
57!
58!--------IF IORTHTROPIC-----------------------------
59      if(iorth.eq.1)then
60!
61         elas(10)=elas(9)
62         elas(15)=elas(8)
63         elas(21)=elas(7)
64         elas(9)=0.d0
65         elas(8)=0.d0
66         elas(7)=0.d0
67!
68      endif
69!
70!--------FIlling  c voigt Matrix-----------------------------
71!
72      call anisotropic(elas,c)
73!
74      d1=1.d0
75!
76      xi(0,0)=0.d0
77      et(0,0)=0.d0
78      call inversewavspd(xi(0,0),et(0,0),c,rho,a)
79      distmin=a
80      imin=0
81      jmin=0
82!
83      do k=1,8
84!
85!     initialisation
86!
87         d1=d1/10.d0
88!
89         do i=-1,1
90            do j=-1,1
91               if((i.eq.0).and.(j.eq.0)) cycle
92!
93               xi(i,j)=xi(0,0)+i*d1
94               et(i,j)=et(0,0)+j*d1
95!
96!              check whether inside the (-1,1)x(-1,1) domain
97!
98               if((xi(i,j).le.1.d0).and.
99     &              (xi(i,j).ge.-1.d0).and.
100     &              (et(i,j).le.1.d0).and.
101     &              (et(i,j).ge.-1.d0)) then
102                  call inversewavspd(xi(i,j),et(i,j),c,rho,a)
103!
104!                 checking for smallest initial distance
105!
106                  if(a.lt.distmin) then
107                     distmin=a
108                     imin=i
109                     jmin=j
110                  endif
111               endif
112!
113            enddo
114         enddo
115!
116!     minimizing the distance from the face to the node
117!
118         do
119!
120!     exit if minimum found
121!
122            if((imin.eq.0).and.(jmin.eq.0)) exit
123!
124!           new center of 3x3 matrix
125!
126            xi(0,0)=xi(imin,jmin)
127            et(0,0)=et(imin,jmin)
128!
129            im=imin
130            jm=jmin
131!
132            imin=0
133            jmin=0
134!
135            do i=-1,1
136               do j=-1,1
137                  if((i+im.lt.-1).or.(i+im.gt.1).or.
138     &                 (j+jm.lt.-1).or.(j+jm.gt.1)) then
139!
140                     xi(i,j)=xi(0,0)+i*d1
141                     et(i,j)=et(0,0)+j*d1
142!
143!              check whether inside the (-1,1)x(-1,1) domain
144!
145                     if((xi(i,j).le.1.d0).and.
146     &                  (xi(i,j).ge.-1.d0).and.
147     &                  (et(i,j).le.1.d0).and.
148     &                  (et(i,j).ge.-1.d0)) then
149                        call inversewavspd(xi(i,j),et(i,j),c,rho,a)
150!
151!                       check for new minimum
152!
153                        if(a.lt.distmin) then
154                           distmin=a
155                           imin=i
156                           jmin=j
157                        endif
158                     endif
159!
160                  endif
161               enddo
162            enddo
163         enddo
164      enddo
165!
166      call inversewavspd(xi(0,0),et(0,0),c,rho,a)
167!
168      wavspd=1.d0/a
169!
170      return
171      end
172
173