55 subroutine get_cfl4cases(time_step, nn_loc, loc_n_num, nm, tm, pm, sdeg, &
56 xx_loc, yy_loc, zz_loc, cs_nnz_loc, cs_loc, &
57 time_step_cfl, fmax, deltat_fixed, &
58 mpi_comm, mpi_np, mpi_id, &
59 ncase,vcase, tcase, zs_elev, zs_all, vs_tria, thick_tria, sub_tag_all, b_failCFL, &
69 character*3 :: deltat_fixed
71 integer*4 :: nm, im, nn_loc, cs_nnz_loc, mpi_comm, mpi_np, mpi_err
72integer*4 :: ie, i, j, k, nn, mcode, smcode, sdeg_deltat_cfl, sdeg_npoints
73 integer*4 :: damping_type, ncase, icase
74 integer*4 :: nel_loc, ic1, ic2, n1, n2, istart, ifin
76 integer*4,
dimension(1) :: pos, pos2
77 integer*4,
dimension(nm) :: tm, sdeg
78 integer*4,
dimension(nn_loc) :: loc_n_num
79 integer*4,
dimension(nn_loc) :: sub_tag_all
80 integer*4,
dimension(0:cs_nnz_loc) :: cs_loc
81 integer*4,
dimension(ncase) :: tcase, vcase
83 real*8 :: time_step, time_step_cfl,
fmax
84 real*8 :: length_min,length,vs_length_min,vs_length,length_vp_min
85 real*8 :: percent_deltat
86 real*8 :: num_of_points,vs_npoints,vp_deltat_cfl
87 real*8 :: rho,lambda,mu,vs,vp
88 real*8 :: x1_length_vp_min,y1_length_vp_min,z1_length_vp_min
89 real*8 :: x2_length_vp_min,y2_length_vp_min,z2_length_vp_min
91 real*8,
dimension(:),
allocatable :: ct,ww
92 real*8,
dimension(:),
allocatable :: time_step_glo, vs_length_glo
93 real*8,
dimension(nn_loc) :: xx_loc, yy_loc, zz_loc
94 real*8,
dimension(nn_loc) ::
zs_elev
95 real*8,
dimension(nn_loc) ::
zs_all
96 real*8,
dimension(nn_loc) ::
vs_tria, thick_tria
99 real*8,
dimension(nm,4) :: pm
100 real*8,
dimension(:,:),
allocatable :: dd
101 real*8,
dimension(nm) ::
qs,
qp
103 real*8,
dimension(:,:,:),
allocatable :: rho_el, lambda_el, mu_el
105 logical :: b_failCFL, b_CFL_failure = .false.
107 nel_loc = cs_loc(0) - 1
109 length_vp_min = 1.d30
110 vs_length_min = 1.d30
116 im = cs_loc(cs_loc(ie -1) +0)
119 allocate(rho_el(nn,nn,nn), lambda_el(nn,nn,nn),mu_el(nn,nn
128 if (vcase(icase) .eq. tm(im))
then
130 nn, rho_el, lambda_el,
132 cs_nnz_loc, cs_loc, ie
133 sub_tag_all, zz_loc, mpi_id
134 damping_type,
qs(im),
qp
148 rho = rho + rho_el(i,j,k)
149 lambda = lambda + lambda_el(i,j,k)
150 mu = mu + mu_el(i,j,k)
156 lambda = lambda/(nn**3)
160 vp = dsqrt((lambda+2*mu)/rho)
162 n1 = nn*nn*(1 -1) +nn*(1 -1) +1
163 n2 = nn*nn*(nn -1) +nn*(nn -1) +nn
164 istart = cs_loc(ie -1) +n1
165 ifin = cs_loc(ie -1) +n2
168 do ic1 = istart, ifin
169 do ic2 = ic1 + 1, ifin
171 if(cs_loc(ic1) .ne. 0 .and. cs_loc(ic2) .ne. 0)
then
173 length=dsqrt((xx_loc(cs_loc(ic1))-xx_loc(cs_loc(ic2
174 (yy_loc(cs_loc(ic1))-yy_loc(cs_loc(ic2
175 (zz_loc(cs_loc(ic1))-zz_loc(cs_loc(ic2
177 length_vp = length/vp
179 if (length_vp_min .gt. length_vp)
then
180 length_vp_min = length_vp
181 x1_length_vp_min = xx_loc(cs_loc(ic1))
182 y1_length_vp_min = yy_loc(cs_loc(ic1))
183 z1_length_vp_min = zz_loc(cs_loc(ic1))
184 x2_length_vp_min = xx_loc(cs_loc(ic2))
185 y2_length_vp_min = yy_loc(cs_loc(ic2))
186 z2_length_vp_min = zz_loc(cs_loc(ic2))
188 sdeg_deltat_cfl = smcode
193 vs_length = vs/length
195 if (vs_length_min.gt.vs_length)
then
196 vs_length_min = vs_length
198 sdeg_npoints = smcode
206 deallocate(lambda_el, gamma_el, mu_el, rho_el)
210 nn = sdeg_deltat_cfl + 1
212 time_step_cfl = length_vp_min
219 allocate(time_step_glo(mpi_np),vs_length_glo(mpi_np))
221 call mpi_barrier(mpi_comm, mpi_err)
222 call mpi_allgather(time_step_cfl, 1, speed_double, time_step_glo
223 call mpi_allgather(vs_length_min, 1, speed_double, vs_length_glo
225 pos = minloc(time_step_glo)
226 pos2 = minloc(vs_length_glo)
231 deallocate(time_step_glo, vs_length_glo)
233 if((mpi_id + 1) .eq. pos(1))
then
236 write(*,
'(A)')
'--------Stability for time advancing algorithm --------'
237 write(*,
'(A,E12.4)')
'Mininum distance beteween grid nodes :'
238 write(*,
'(A,E12.4)')
'Vp for CFL condition :', vp_deltat_cfl
239 write(*,
'(A,E12.4,E12.4,E12.4)')
'Min. node 1 : ',x1_length_vp_min
240 write(*,
'(A,E12.4,E12.4,E12.4)')
'Min. node 2 : ',x2_length_vp_min
241 write(*,
'(A)')
'-------------------------------------------------------'
243 if (time_step.le.time_step_cfl)
then
244 percent_deltat=time_step/time_step_cfl*100
245 if (percent_deltat.le.1)
then
246 write(*,
'(A,E12.4)')
'WARNING!!! deltat CFL ='
248 write(*,
'(A,F6.2,A)')
'You are using ',percent_deltat
249 '% of critical time step.'
250 write(*,
'(A)')
'This time step is excedingly lower the deltat CFL'
251 if (deltat_fixed.eq.
'not')
then
252 write(*,
'(A)')
'deltat chosen will be substituted with 10% of deltat CFL'
253 time_step=time_step_cfl*0.1
254 write(*,
'(A,E12.4)')
'deltat chosen :'
256 elseif (percent_deltat.le.25)
then
257 write(*,
'(A,E12.4)')
'OK!!! deltat CFL ='
259 write(*,
'(A,F6.2,A)')
'You are using ',percent_deltat
260 '% of critical time step.'
262 write(*,
'(A,E12.4)')
'WARNING!!! deltat CFL ='
264 write(*,
'(A,F6.2,A)')
'You are using ',percent_deltat
265 '% of critical time step.'
266 write(*,
'(A)')
'This could be not enough for the correct working of ABC'
267 if (deltat_fixed.eq.
'not')
then
268 write(*,
'(A)')
'deltat chosen will be substituted with 20% of deltat CFL'
269 time_step=time_step_cfl*0.2
270 write(*,
'(A,E12.4)')
'deltat chosen :'
274 elseif (time_step .gt. time_step_cfl)
then
275 write(*,
'(2X,A,E12.4)')
'ERROR!!! deltat CFL = ',
276 time_step_cfl,
' < deltat = ',time_step
277 write(*,
'(A)')
'The time advancing scheme will be unstable!'
278 if (deltat_fixed.eq.
'not')
then
279 write(*,
'(A)')
'deltat chosen will be substituted with 20% of deltat CFL'
280 time_step=time_step_cfl*0.2
281 write(*,
'(A,E12.4)')
'deltat chosen :',time_step
283 b_cfl_failure = .true.
287 write(*,
'(A)')
'-------------------------------------------------------'
290 if (b_failcfl .and. b_cfl_failure)
then
291 write(*,*)
'CFL does NOT hold, asked to quit. Program finished.'
292 call mpi_finalize(mpi_err)
300 call mpi_barrier(mpi_comm, mpi_err)
302 allocate(ct(nn),ww(nn),dd(nn,nn))
305 num_of_points = vs_length_min*(ct(1)-ct(nn))/(ct(int(nn/2))-ct(int
310 if((mpi_id + 1) .eq. pos2(1))
then
311 write(*,
'(A)')
'-----------Number of points per wave length------------'
313 write(*,
'(A,E12.4)')
'Minum vs wrt max frequency :',vs_npoints
314 write(*,
'(A,E12.4)')
'Points per wavelength :',num_of_points
320 call mpi_barrier(mpi_comm, mpi_err)
325 end subroutine get_cfl4cases
subroutine make_eltensor_for_cases(tcase, vcase, nn, rho_el, lambda_el, mu_el, gamma_el, nn_loc, zs_elev, zs_all, vs_nodes, thic
Assignes material properties node by node.
subroutine make_lgl_nw(nb_pnt, xq, wq, dd)
Makes Gauss-Legendre-Lobatto nodes, weigths and spectral derivatives.
integer, parameter exit_cfl
Contains SPEED PARAMETERS used in (SPEED, READ_INPUT_FILES, MAKE_PARTION_AND_MPI_FILES,...
real *8, dimension(:), allocatable qs
integer *4 label_testcase
real *8, dimension(:), allocatable vs_tria
real *8, dimension(:), allocatable qp
real *8, dimension(:), allocatable zs_elev
real *8, dimension(:), allocatable zs_all