33 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in
34 REAL(KIND=8),
DIMENSION(:,:,:),
ALLOCATABLE :: v_out
37 INTEGER,
OPTIONAL :: opt_nb_plane
38 INTEGER :: np, bloc_size, nb_field, &
39 m_max, m_max_c, rang, nb_procs, mpid, m_max_pad, n_r_pad
40 INTEGER(KIND=8) :: fftw_plan_multi_c2r
41 COMPLEX(KIND=8),
ALLOCATABLE,
DIMENSION(:,:,:) :: cu
42 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
43 REAL(KIND=8),
ALLOCATABLE,
DIMENSION(:,:,:) :: dist_field, combined_field
44 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
45 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
48 #include "petsc/finclude/petsc.h"
49 mpi_comm :: communicator
51 CALL mpi_comm_size(communicator, nb_procs, code)
52 CALL mpi_comm_rank(communicator, rang, code)
55 nb_field =
SIZE(v1_in,2)
56 m_max_c =
SIZE(v1_in,3)
57 m_max = m_max_c*nb_procs
58 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
59 CALL
error_petsc(.OR.
'Bug in FFT_PAR_REAL: MOD(nb_field,2)/=0 m_max_c==0')
64 IF (modulo(np,nb_procs)==0)
THEN
65 bloc_size = np/nb_procs
67 CALL
error_petsc(
'Bug in FFT_PAR_REAL: np is not a multiple of nb_procs')
70 IF (present(opt_nb_plane))
THEN
71 IF (opt_nb_plane> 2*m_max-1)
THEN
72 m_max_pad = (opt_nb_plane+1)/2
81 ALLOCATE(cu(m_max_pad,nb_field/2, bloc_size))
82 ALLOCATE(dist_field(m_max_c,nb_field,np))
83 ALLOCATE(combined_field(m_max_c,nb_field,np))
86 dist_field(i,:,:) = transpose(v1_in(:,:,i))
89 longueur_tranche=bloc_size*m_max_c*nb_field
91 mpid=mpi_double_precision
92 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
93 mpid, communicator, code)
98 shiftc = (nb-1)*bloc_size
99 shiftl = (nb-1)*m_max_c
101 DO nf = 1, nb_field/2
106 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
107 -combined_field(:,2*nf,jindex),kind=8)
111 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
123 onembed(1)= m_max_pad
124 howmany = bloc_size*nb_field/2
130 IF (
ALLOCATED(v_out))
DEALLOCATE(v_out)
131 ALLOCATE(v_out(n_r_pad,nb_field/2,bloc_size))
133 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
134 onembed, ostride, odist, v_out, inembed, istride, idist, fftw_estimate)
135 CALL dfftw_execute(fftw_plan_multi_c2r)
138 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
140 DEALLOCATE(cu, dist_field, combined_field)
151 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in
152 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v_out
153 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
154 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
155 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
156 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
157 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(V1_in,2), bloc_size) :: cu
158 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2),bloc_size) :: ru
159 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu
160 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru
161 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size) :: intermediate
162 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2),bloc_size*nb_procs) :: dist_field, combined_field
163 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu
164 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu
166 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
169 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
170 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
173 #include "petsc/finclude/petsc.h"
174 mpi_comm :: communicator
176 IF (present(temps)) temps = 0.d0
179 nb_field=
SIZE(v1_in,2)
180 m_max_c =
SIZE(v1_in,3)
181 m_max = m_max_c*nb_procs
182 n_r_pad=2*m_max_pad-1
183 np_tot = nb_procs*bloc_size
185 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
203 dist_field(i,1:nb_field,1:np) = transpose(v1_in(:,:,i))
204 dist_field(i,nb_field+1:2*nb_field,1:np) = transpose(v2_in(:,:,i))
206 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
208 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
210 longueur_tranche=bloc_size*m_max_c*nb_field*2
213 mpid=mpi_double_precision
214 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
215 mpid, communicator, code)
216 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
224 shiftc = (nb-1)*bloc_size
225 shiftl = (nb-1)*m_max_c
233 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
234 -combined_field(:,2*nf,jindex),kind=8)
238 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
244 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
247 fft_dim=1; istride=1; ostride=1;
251 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
252 odist=m_max_pad; onembed(1)=m_max_pad
255 howmany=bloc_size*nb_field
258 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
259 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
261 CALL dfftw_execute(fftw_plan_multi_c2r)
264 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
267 IF (nb_field==6)
THEN
268 prod_ru(:,1,:) = ru(:,2,:)*ru(:,6,:) - ru(:,3,:)*ru(:,5,:)
269 prod_ru(:,2,:) = ru(:,3,:)*ru(:,4,:) - ru(:,1,:)*ru(:,6,:)
270 prod_ru(:,3,:) = ru(:,1,:)*ru(:,5,:) - ru(:,2,:)*ru(:,4,:)
275 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
276 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
278 CALL dfftw_execute(fftw_plan_multi_r2c)
281 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
285 prod_cu = (1.d0/n_r_pad)*prod_cu
287 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
292 combined_prod_cu(:,:,1)=prod_cu(1,:,:)
295 combined_prod_cu(:,:,n)=2*conjg(prod_cu(n,:,:))
298 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
301 longueur_tranche=bloc_size*m_max_c*nb_field
302 mpid=mpi_double_precision
303 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
304 mpid,communicator,code)
305 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
310 shiftc = (nb-1)*bloc_size
311 shiftl = (nb-1)*m_max_c
312 intermediate = dist_prod_cu(:,:,shiftl+i)
314 IF (n+shiftc > np ) cycle
315 DO i_field = 1, nb_field/2
316 v_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate(i_field,n),kind=8)
317 v_out(n+shiftc, i_field*2 , i) = aimag(intermediate(i_field,n))
323 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
335 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in
336 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: c_out
337 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
338 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad
339 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(V1_in,2), bloc_size) :: cu
340 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2),bloc_size) :: ru
341 COMPLEX(KIND=8),
DIMENSION(m_max_pad,bloc_size) :: prod_cu
342 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: prod_ru
343 COMPLEX(KIND=8),
DIMENSION(bloc_size) :: intermediate
344 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2),bloc_size*nb_procs) :: dist_field, combined_field
345 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu
346 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu
347 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
348 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
349 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
352 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
353 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
356 #include "petsc/finclude/petsc.h"
357 mpi_comm :: communicator
359 IF (present(temps)) temps = 0.d0
362 nb_field=
SIZE(v1_in,2)
363 m_max_c =
SIZE(v1_in,3)
364 m_max = m_max_c*nb_procs
365 np_tot = nb_procs*bloc_size
366 n_r_pad=2*m_max_pad-1
368 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
381 dist_field(i,1:nb_field,1:np) = transpose(v1_in(:,:,i))
382 dist_field(i,nb_field+1:2*nb_field,1:np) = transpose(v2_in(:,:,i))
384 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
386 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
388 longueur_tranche=bloc_size*m_max_c*nb_field*2
391 mpid=mpi_double_precision
392 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
393 mpid, communicator, code)
394 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
402 shiftc = (nb-1)*bloc_size
403 shiftl = (nb-1)*m_max_c
411 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
412 -combined_field(:,2*nf,jindex),kind=8)
416 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
422 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
425 fft_dim=1; istride=1; ostride=1;
429 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
430 odist=m_max_pad; onembed(1)=m_max_pad
433 howmany=bloc_size*nb_field
437 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
438 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
440 CALL dfftw_execute(fftw_plan_multi_c2r)
443 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
446 IF (nb_field==6)
THEN
447 prod_ru(:,:) = ru(:,1,:)*ru(:,4,:) + ru(:,2,:)*ru(:,5,:) + ru(:,3,:)*ru(:,6,:)
451 howmany = bloc_size*1
452 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
453 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
455 CALL dfftw_execute(fftw_plan_multi_r2c)
458 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
462 prod_cu = prod_cu*(1.d0/n_r_pad)
464 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
468 combined_prod_cu(:,1)=prod_cu(1,:)
470 combined_prod_cu(:,n)=2*conjg(prod_cu(n,:))
473 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
476 longueur_tranche=bloc_size*m_max_c*2
477 mpid=mpi_double_precision
478 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
479 mpid,communicator,code)
480 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
485 shiftc = (nb-1)*bloc_size
486 shiftl = (nb-1)*m_max_c
487 intermediate = dist_prod_cu(:,shiftl+i)
489 IF (n+shiftc > np ) cycle
490 c_out(n+shiftc, 1, i) =
REAL (intermediate(n),kind=8)
491 c_out(n+shiftc, 2 , i) = aimag(intermediate(n))
495 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
499 SUBROUTINE fft_par_prod_dcl(communicator, c1_in, c2_in, c_out, nb_procs, bloc_size, m_max_pad, temps)
508 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: c1_in, c2_in
509 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: c_out
510 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
511 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad
512 COMPLEX(KIND=8),
DIMENSION(m_max_pad, 2, bloc_size) :: cu
513 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, 2, bloc_size) :: ru
514 COMPLEX(KIND=8),
DIMENSION(m_max_pad, bloc_size) :: prod_cu
515 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: prod_ru
516 REAL(KIND=8),
DIMENSION(SIZE(c1_in,3),4, bloc_size*nb_procs) :: dist_field, combined_field
517 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(c1_in,3)*nb_procs) :: dist_prod_cu, combined_prod_cu
518 COMPLEX(KIND=8),
DIMENSION(bloc_size) :: intermediate
519 INTEGER :: np, np_tot, m_max, m_max_c, mpid, n_r_pad
520 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
521 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
524 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
525 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
528 #include "petsc/finclude/petsc.h"
529 mpi_comm :: communicator
531 IF (present(temps)) temps = 0.d0
534 m_max_c =
SIZE(c1_in,3)
535 m_max = m_max_c*nb_procs
536 np_tot = nb_procs*bloc_size
537 n_r_pad=2*m_max_pad-1
551 dist_field(i,1:2,1:np) = transpose(c1_in(:,:,i))
552 dist_field(i,3:4,1:np) = transpose(c2_in(:,:,i))
554 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
556 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
558 longueur_tranche=bloc_size*m_max_c*4
561 mpid=mpi_double_precision
562 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
563 mpid, communicator, code)
564 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
572 shiftc = (nb-1)*bloc_size
573 shiftl = (nb-1)*m_max_c
581 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
582 -combined_field(:,2*nf,jindex),kind=8)
586 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
592 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
595 fft_dim=1; istride=1; ostride=1;
599 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
600 odist=m_max_pad; onembed(1)=m_max_pad
606 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
607 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
608 CALL dfftw_execute(fftw_plan_multi_c2r)
611 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
614 prod_ru(:,:) = ru(:,1,:)*ru(:,2,:)
617 howmany = bloc_size*1
618 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
619 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
620 CALL dfftw_execute(fftw_plan_multi_r2c)
623 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
627 prod_cu = prod_cu*(1.d0/n_r_pad)
629 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
633 combined_prod_cu(:,1)=prod_cu(1,:)
635 combined_prod_cu(:,n)=2*conjg(prod_cu(n,:))
638 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
641 longueur_tranche=bloc_size*m_max_c*2
642 mpid=mpi_double_precision
643 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
644 mpid,communicator,code)
645 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
650 shiftc = (nb-1)*bloc_size
651 shiftl = (nb-1)*m_max_c
652 intermediate = dist_prod_cu(:,shiftl+i)
654 IF (n+shiftc > np ) cycle
655 c_out(n+shiftc, 1, i) =
REAL (intermediate(n),kind=8)
656 c_out(n+shiftc, 2 , i) = aimag(intermediate(n))
660 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
665 m_max_pad, coeff_tanh, temps)
672 REAL(KIND=8),
DIMENSION(:,:,:,:),
INTENT(IN) :: v1_in
673 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: values
674 REAL(KIND=8),
INTENT(IN) :: coeff_tanh
675 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v_out
676 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
677 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
678 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
679 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
680 COMPLEX(KIND=8),
DIMENSION(m_max_pad, bloc_size) :: cu
681 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size) :: ru
682 COMPLEX(KIND=8),
DIMENSION(m_max_pad,bloc_size) :: prod_cu
683 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: prod_ru
684 COMPLEX(KIND=8),
DIMENSION(bloc_size) :: intermediate
685 REAL(KIND=8),
DIMENSION(SIZE(V1_in,4),SIZE(V1_in,3),bloc_size*nb_procs) :: dist_field, combined_field
686 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,4)*nb_procs) :: combined_prod_cu
687 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,4)*nb_procs) :: dist_prod_cu
688 REAL(KIND=8),
DIMENSION(SIZE(values),2*m_max_pad-1, bloc_size) :: v1_real_loc
690 INTEGER :: nb, shiftc, shiftl, jindex, longueur_tranche, i, n, code, interface_nb
693 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
694 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
697 #include "petsc/finclude/petsc.h"
698 mpi_comm :: communicator
700 IF (present(temps)) temps = 0.d0
703 nb_field=
SIZE(v1_in,3)
704 m_max_c =
SIZE(v1_in,4)
705 m_max = m_max_c*nb_procs
706 n_r_pad=2*m_max_pad-1
707 np_tot = nb_procs*bloc_size
709 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
726 DO interface_nb = 1,
SIZE(values)-1
729 dist_field(i,1:nb_field,1:np) = transpose(v1_in(interface_nb,:,:,i))
731 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
733 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
735 longueur_tranche=bloc_size*m_max_c*nb_field
738 mpid=mpi_double_precision
739 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
740 mpid, communicator, code)
742 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
750 shiftc = (nb-1)*bloc_size
751 shiftl = (nb-1)*m_max_c
758 cu(shiftl+1:shiftl+m_max_c,n) = 0.5d0*cmplx(combined_field(:,1,jindex),&
759 -combined_field(:,2,jindex),kind=8)
762 cu(1,:) = 2*cmplx(
REAL(cu(1,:),KIND=8),0.d0,kind=8)
765 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
768 fft_dim=1; istride=1; ostride=1;
772 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
773 odist=m_max_pad; onembed(1)=m_max_pad
776 howmany=bloc_size*nb_field/2
779 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
780 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
782 CALL dfftw_execute(fftw_plan_multi_c2r)
785 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
786 v1_real_loc(interface_nb,:,:)=ru
790 IF (nb_field==2)
THEN
791 DO n1 = 1, 2*m_max_pad-1
793 prod_ru(n1,n2) = values(1)
794 DO interface_nb = 1,
SIZE(values)-1
796 prod_ru(n1,n2) = prod_ru(n1,n2)*(1.d0-
regul(v1_real_loc(interface_nb,n1,n2),coeff_tanh)) + &
797 values(interface_nb+1)*
regul(v1_real_loc(interface_nb,n1,n2),coeff_tanh)
805 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
806 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
808 CALL dfftw_execute(fftw_plan_multi_r2c)
811 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
815 prod_cu = prod_cu*(1.d0/n_r_pad)
817 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
821 combined_prod_cu(:,1)=prod_cu(1,:)
824 combined_prod_cu(:,n)=2*conjg(prod_cu(n,:))
827 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
830 longueur_tranche=bloc_size*m_max_c*nb_field
831 mpid=mpi_double_precision
832 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
833 mpid,communicator,code)
834 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
839 shiftc = (nb-1)*bloc_size
840 shiftl = (nb-1)*m_max_c
841 intermediate = dist_prod_cu(:,shiftl+i)
843 IF (n+shiftc > np ) cycle
844 v_out(n+shiftc, 1, i) =
REAL (intermediate(n),kind=8)
845 v_out(n+shiftc, 2, i) = aimag(intermediate(n))
849 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
854 bloc_size, m_max_pad, temps)
862 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in
863 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v2_in
864 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v_out
865 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
866 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
867 INTEGER,
INTENT(IN) :: pb
868 INTEGER :: np, np_tot, nb_field1, nb_field2, m_max, m_max_c, mpid, n_r_pad
869 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
870 COMPLEX(KIND=8),
DIMENSION(m_max_pad, (SIZE(V1_in,2)+SIZE(V2_in,2))/2, bloc_size) :: cu
871 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,(SIZE(V1_in,2)+SIZE(V2_in,2))/2,bloc_size) :: ru
872 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu
873 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru
874 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2, bloc_size) :: intermediate
875 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),SIZE(V1_in,2)+SIZE(V2_in,2),bloc_size*nb_procs) :: dist_field
876 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),SIZE(V1_in,2)+SIZE(V2_in,2),bloc_size*nb_procs) :: combined_field
877 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu
878 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu
880 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
883 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
884 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
887 #include "petsc/finclude/petsc.h"
888 mpi_comm :: communicator
890 IF (present(temps)) temps = 0.d0
893 nb_field1=
SIZE(v1_in,2)
894 nb_field2=
SIZE(v2_in,2)
895 m_max_c =
SIZE(v1_in,3)
896 m_max = m_max_c*nb_procs
897 n_r_pad=2*m_max_pad-1
898 np_tot = nb_procs*bloc_size
900 IF (mod(nb_field1,2)/=0 .OR. mod(nb_field2,2)/=0 .OR. m_max_c==0)
THEN
918 dist_field(i,1:nb_field1,1:np) = transpose(v1_in(:,:,i))
919 dist_field(i,nb_field1+1:nb_field1+nb_field2,1:np) = transpose(v2_in(:,:,i))
921 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
923 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
925 longueur_tranche=bloc_size*m_max_c*(nb_field1+nb_field2)
928 mpid=mpi_double_precision
929 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
930 mpid, communicator, code)
931 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
939 shiftc = (nb-1)*bloc_size
940 shiftl = (nb-1)*m_max_c
942 DO nf = 1, (nb_field1+nb_field2)/2
948 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
949 -combined_field(:,2*nf,jindex),kind=8)
953 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
959 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
962 fft_dim=1; istride=1; ostride=1;
966 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
967 odist=m_max_pad; onembed(1)=m_max_pad
970 howmany=bloc_size*(nb_field1+nb_field2)/2
973 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
974 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
976 CALL dfftw_execute(fftw_plan_multi_c2r)
979 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
981 IF (nb_field1 == 6 .AND. nb_field2 == 2)
THEN
983 prod_ru(:,1,:) = ru(:,4,:)*ru(:,1,:)
984 prod_ru(:,2,:) = ru(:,4,:)*ru(:,2,:)
985 prod_ru(:,3,:) = ru(:,4,:)*ru(:,3,:)
987 prod_ru(:,1,:) = 1/ru(:,4,:)*ru(:,1,:)
988 prod_ru(:,2,:) = 1/ru(:,4,:)*ru(:,2,:)
989 prod_ru(:,3,:) = 1/ru(:,4,:)*ru(:,3,:)
991 CALL
error_petsc(
'error in problem type while calling FFT_SCALAR_VECT_DCL ')
994 CALL
error_petsc(
'error in dimension of INPUT variables while calling FFT_SCALAR_VECT_DCL ')
997 howmany = bloc_size*nb_field1/2
999 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
1000 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
1002 CALL dfftw_execute(fftw_plan_multi_r2c)
1004 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
1010 prod_cu = prod_cu*(1.d0/n_r_pad)
1012 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
1017 combined_prod_cu(:,:,1)=prod_cu(1,:,:)
1020 combined_prod_cu(:,:,n)=2*conjg(prod_cu(n,:,:))
1023 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1025 longueur_tranche=bloc_size*m_max_c*nb_field1
1028 mpid=mpi_double_precision
1029 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
1030 mpid,communicator,code)
1032 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1038 shiftc = (nb-1)*bloc_size
1039 shiftl = (nb-1)*m_max_c
1040 intermediate = dist_prod_cu(:,:,shiftl+i)
1042 IF (n+shiftc > np ) cycle
1043 DO i_field = 1, nb_field1/2
1044 v_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate(i_field,n),kind=8)
1045 v_out(n+shiftc, i_field*2 , i) = aimag(intermediate(i_field,n))
1050 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1062 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in
1063 REAL(KIND=8),
INTENT(OUT) :: v_out
1064 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
1065 INTEGER :: np, np_tot, nb_field1, m_max, m_max_c, mpid, n_r_pad
1066 INTEGER(KIND=8) :: fftw_plan_multi_c2r
1067 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(V1_in,2)/2, bloc_size) :: cu
1068 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, SIZE(V1_in,2)/2,bloc_size) :: ru
1069 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),SIZE(V1_in,2),bloc_size*nb_procs) :: dist_field, combined_field
1070 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
1071 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size) :: norm_vel_loc
1072 REAL(KIND=8) :: max_velocity
1074 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
1075 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
1078 #include "petsc/finclude/petsc.h"
1079 mpi_comm :: communicator
1082 nb_field1 =
SIZE(v1_in,2)
1083 m_max_c =
SIZE(v1_in,3)
1084 m_max = m_max_c*nb_procs
1085 n_r_pad = 2*m_max_pad-1
1086 np_tot = nb_procs*bloc_size
1088 IF (mod(nb_field1,2)/=0 .OR. m_max_c==0)
THEN
1105 dist_field(i,1:nb_field1,1:np) = transpose(v1_in(:,:,i))
1108 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 0.d0
1110 longueur_tranche=bloc_size*m_max_c*nb_field1
1112 mpid=mpi_double_precision
1113 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
1114 mpid, communicator, code)
1121 shiftc = (nb-1)*bloc_size
1122 shiftl = (nb-1)*m_max_c
1124 DO nf = 1, nb_field1/2
1130 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
1131 -combined_field(:,2*nf,jindex),kind=8)
1135 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
1142 fft_dim=1; istride=1; ostride=1;
1146 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
1147 odist=m_max_pad; onembed(1)=m_max_pad
1150 howmany=bloc_size*nb_field1/2
1152 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
1153 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
1155 CALL dfftw_execute(fftw_plan_multi_c2r)
1158 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
1161 norm_vel_loc(:,:) = sqrt(ru(:,1,:)**2 + ru(:,2,:)**2 + ru(:,3,:)**2)
1162 max_velocity = maxval(norm_vel_loc)
1163 CALL mpi_allreduce(max_velocity, v_out, 1, mpi_double_precision, &
1164 mpi_max, communicator, code)
1168 SUBROUTINE fft_tensor_dcl(communicator,V1_in, V2_in, V_out, nb_procs, bloc_size, m_max_pad, temps, opt_tension)
1176 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in
1177 REAL(KIND=8),
DIMENSION(:,:,:,:),
INTENT(OUT) :: v_out
1178 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
1179 LOGICAL,
OPTIONAL,
INTENT(IN) :: opt_tension
1180 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
1181 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
1182 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
1183 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(V1_in,2), bloc_size) :: cu
1184 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2),bloc_size) :: ru
1185 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu1, prod_cu2, prod_cu3
1186 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru1, prod_ru2, prod_ru3
1187 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2),bloc_size*nb_procs) :: dist_field
1188 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2),bloc_size*nb_procs) :: combined_field
1189 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu1
1190 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu2
1191 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu3
1192 COMPLEX(KIND=8),
DIMENSION(3,SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_tot
1193 COMPLEX(KIND=8),
DIMENSION(3,SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_tot
1194 COMPLEX(KIND=8),
DIMENSION(3,SIZE(V1_in,2)/2,bloc_size) :: intermediate_tot
1195 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: norm_grad_tension
1197 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
1200 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
1201 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
1204 #include "petsc/finclude/petsc.h"
1205 mpi_comm :: communicator
1207 IF (present(temps)) temps = 0.d0
1210 nb_field=
SIZE(v1_in,2)
1211 m_max_c =
SIZE(v1_in,3)
1212 m_max = m_max_c*nb_procs
1213 n_r_pad=2*m_max_pad-1
1214 np_tot = nb_procs*bloc_size
1216 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
1234 dist_field(i,1:nb_field,1:np) = transpose(v1_in(:,:,i))
1235 dist_field(i,nb_field+1:2*nb_field,1:np) = transpose(v2_in(:,:,i))
1237 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1239 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
1241 longueur_tranche=bloc_size*m_max_c*nb_field*2
1244 mpid=mpi_double_precision
1245 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
1246 mpid, communicator, code)
1247 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1255 shiftc = (nb-1)*bloc_size
1256 shiftl = (nb-1)*m_max_c
1264 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
1265 -combined_field(:,2*nf,jindex),kind=8)
1269 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
1275 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1278 fft_dim=1; istride=1; ostride=1;
1282 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
1283 odist=m_max_pad; onembed(1)=m_max_pad
1286 howmany=bloc_size*nb_field
1290 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
1291 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
1293 CALL dfftw_execute(fftw_plan_multi_c2r)
1296 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
1300 IF(.NOT.present(opt_tension))
THEN
1301 IF (nb_field==6)
THEN
1302 prod_ru1(:,1,:) = ru(:,1,:)*ru(:,4,:)
1303 prod_ru1(:,2,:) = ru(:,1,:)*ru(:,5,:)
1304 prod_ru1(:,3,:) = ru(:,1,:)*ru(:,6,:)
1306 prod_ru2(:,1,:) = ru(:,2,:)*ru(:,4,:)
1307 prod_ru2(:,2,:) = ru(:,2,:)*ru(:,5,:)
1308 prod_ru2(:,3,:) = ru(:,2,:)*ru(:,6,:)
1310 prod_ru3(:,1,:) = ru(:,3,:)*ru(:,4,:)
1311 prod_ru3(:,2,:) = ru(:,3,:)*ru(:,5,:)
1312 prod_ru3(:,3,:) = ru(:,3,:)*ru(:,6,:)
1314 ELSE IF (opt_tension)
THEN
1315 IF (nb_field==6)
THEN
1316 norm_grad_tension = sqrt(ru(:,4,:)**2 + ru(:,5,:)**2 + ru(:,6,:)**2)
1317 prod_ru1(:,1,:) = ru(:,1,:)*ru(:,4,:)/(norm_grad_tension + 1.d-14) &
1319 prod_ru1(:,2,:) = ru(:,1,:)*ru(:,5,:)/(norm_grad_tension + 1.d-14)
1320 prod_ru1(:,3,:) = ru(:,1,:)*ru(:,6,:)/(norm_grad_tension + 1.d-14)
1322 prod_ru2(:,1,:) = ru(:,2,:)*ru(:,4,:)/(norm_grad_tension + 1.d-14)
1323 prod_ru2(:,2,:) = ru(:,2,:)*ru(:,5,:)/(norm_grad_tension + 1.d-14) &
1325 prod_ru2(:,3,:) = ru(:,2,:)*ru(:,6,:)/(norm_grad_tension + 1.d-14)
1327 prod_ru3(:,1,:) = ru(:,3,:)*ru(:,4,:)/(norm_grad_tension + 1.d-14)
1328 prod_ru3(:,2,:) = ru(:,3,:)*ru(:,5,:)/(norm_grad_tension + 1.d-14)
1329 prod_ru3(:,3,:) = ru(:,3,:)*ru(:,6,:)/(norm_grad_tension + 1.d-14) &
1333 CALL
error_petsc(
'BUG in FFT_TENSOR_DCL : opt_tension should be true if used')
1338 fft_dim=1; istride=1; ostride=1;
1342 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
1343 odist=m_max_pad; onembed(1)=m_max_pad
1346 howmany=bloc_size*nb_field/2
1348 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru1, &
1349 inembed, istride, idist, prod_cu1, onembed, ostride, odist, fftw_estimate)
1351 CALL dfftw_execute(fftw_plan_multi_r2c)
1353 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
1355 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru2, &
1356 inembed, istride, idist, prod_cu2, onembed, ostride, odist, fftw_estimate)
1358 CALL dfftw_execute(fftw_plan_multi_r2c)
1360 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
1362 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru3, &
1363 inembed, istride, idist, prod_cu3, onembed, ostride, odist, fftw_estimate)
1365 CALL dfftw_execute(fftw_plan_multi_r2c)
1367 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
1373 prod_cu1 = prod_cu1*(1.d0/n_r_pad)
1374 prod_cu2 = prod_cu2*(1.d0/n_r_pad)
1375 prod_cu3 = prod_cu3*(1.d0/n_r_pad)
1378 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
1382 combined_prod_cu1(:,:,1)=prod_cu1(1,:,:)
1383 combined_prod_cu2(:,:,1)=prod_cu2(1,:,:)
1384 combined_prod_cu3(:,:,1)=prod_cu3(1,:,:)
1387 combined_prod_cu1(:,:,n)=2*conjg(prod_cu1(n,:,:))
1388 combined_prod_cu2(:,:,n)=2*conjg(prod_cu2(n,:,:))
1389 combined_prod_cu3(:,:,n)=2*conjg(prod_cu3(n,:,:))
1392 combined_prod_cu_tot(1,:,:,:) = combined_prod_cu1(:,:,:)
1393 combined_prod_cu_tot(2,:,:,:) = combined_prod_cu2(:,:,:)
1394 combined_prod_cu_tot(3,:,:,:) = combined_prod_cu3(:,:,:)
1396 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1399 longueur_tranche=bloc_size*m_max_c*nb_field*3
1400 mpid=mpi_double_precision
1401 CALL mpi_alltoall(combined_prod_cu_tot,longueur_tranche,mpid, dist_prod_cu_tot,longueur_tranche, &
1402 mpid,communicator,code)
1403 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1408 shiftc = (nb-1)*bloc_size
1409 shiftl = (nb-1)*m_max_c
1410 intermediate_tot = dist_prod_cu_tot(:,:,:,shiftl+i)
1412 IF (n+shiftc > np ) cycle
1413 DO i_field = 1, nb_field/2
1414 v_out(:, n+shiftc, i_field*2-1, i) =
REAL (intermediate_tot(:,i_field,n),kind=8)
1415 v_out(:, n+shiftc, i_field*2 , i) = aimag(intermediate_tot(:,i_field,n))
1420 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1424 c_in, c_out, nb_procs, bloc_size, m_max_pad, time, temps)
1433 FUNCTION eta(H_mesh,angles,nb_angles,nb,ne,time) RESULT(vv)
1439 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: angles
1440 INTEGER,
INTENT(IN) :: nb_angles
1441 INTEGER,
INTENT(IN) :: nb, ne
1442 REAL(KIND=8),
INTENT(IN) :: time
1443 REAL(KIND=8),
DIMENSION(nb_angles,ne-nb+1) :: vv
1446 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad
1447 REAL(KIND=8),
DIMENSION(2*m_max_pad-1) :: angles
1448 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: eta_n
1451 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: c_in
1452 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: c_out
1453 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
1454 REAL(KIND=8) :: time
1455 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(c_in,2)/2, bloc_size) :: cu
1456 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, SIZE(c_in,2)/2, bloc_size) :: ru
1457 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(c_in,2)/2, bloc_size) :: prod_cu
1458 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, SIZE(c_in,2)/2,bloc_size) :: prod_ru
1459 REAL(KIND=8),
DIMENSION(SIZE(c_in,3),SIZE(c_in,2), bloc_size*nb_procs) :: dist_field, combined_field
1460 COMPLEX(KIND=8),
DIMENSION(SIZE(c_in,2)/2,bloc_size,SIZE(c_in,3)*nb_procs):: dist_prod_cu
1461 COMPLEX(KIND=8),
DIMENSION(SIZE(c_in,2)/2,bloc_size,SIZE(c_in,3)*nb_procs):: combined_prod_cu
1462 COMPLEX(KIND=8),
DIMENSION(SIZE(c_in,2)/2,bloc_size) :: intermediate
1463 INTEGER :: np, np_tot, m_max, m_max_c, mpid, n_r_pad, nb_field, i_field
1464 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
1465 INTEGER :: nb, ne, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
1468 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
1469 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
1472 #include "petsc/finclude/petsc.h"
1473 petscerrorcode :: ierr
1474 mpi_comm :: communicator
1476 IF (present(temps)) temps = 0.d0
1479 nb_field =
SIZE(c_in,2)
1480 m_max_c =
SIZE(c_in,3)
1481 m_max = m_max_c*nb_procs
1482 np_tot = nb_procs*bloc_size
1483 n_r_pad = 2*m_max_pad-1
1485 IF (m_max_c==0)
THEN
1492 angles(n) = 2*pi*(n-1)/n_r_pad
1502 dist_field(i,:,1:np) = transpose(c_in(:,:,i))
1504 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1506 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
1508 longueur_tranche=bloc_size*m_max_c*nb_field
1511 mpid=mpi_double_precision
1512 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
1513 mpid, communicator, code)
1514 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1522 shiftc = (nb-1)*bloc_size
1523 shiftl = (nb-1)*m_max_c
1525 DO nf = 1, nb_field/2
1529 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
1530 -combined_field(:,2*nf,jindex),kind=8)
1534 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
1540 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1543 fft_dim=1; istride=1; ostride=1;
1547 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
1548 odist=m_max_pad; onembed(1)=m_max_pad
1551 howmany=bloc_size*nb_field/2
1554 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
1555 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
1556 CALL dfftw_execute(fftw_plan_multi_c2r)
1559 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
1563 CALL mpi_comm_rank(communicator, rank_f, ierr)
1564 IF (rank_f==nb_procs-1)
THEN
1565 IF (np-rank_f*bloc_size.GE.1)
THEN
1566 nb = rank_f*bloc_size+1
1568 eta_n(:,1:np-rank_f*bloc_size) = eta(h_mesh,angles,n_r_pad,nb,ne,time)
1569 eta_n(:,np-rank_f*bloc_size+1:bloc_size) = 1.d0
1574 nb = rank_f*bloc_size+1
1575 ne = rank_f*bloc_size+bloc_size
1576 eta_n(:,:) = eta(h_mesh,angles,n_r_pad,nb,ne,time)
1579 IF (nb_field==2)
THEN
1580 prod_ru(:,1,:) = eta_n*ru(:,1,:)
1581 ELSE IF (nb_field==6)
THEN
1582 prod_ru(:,1,:) = eta_n*ru(:,1,:)
1583 prod_ru(:,2,:) = eta_n*ru(:,2,:)
1584 prod_ru(:,3,:) = eta_n*ru(:,3,:)
1586 CALL
error_petsc(
'error in nb_field of c_in while calling FFT_PAR_VAR_ETA_PROD_T_DCL')
1590 howmany = bloc_size*nb_field/2
1592 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
1593 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
1594 CALL dfftw_execute(fftw_plan_multi_r2c)
1597 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
1601 prod_cu = prod_cu*(1.d0/n_r_pad)
1603 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
1607 combined_prod_cu(:,:,1)=prod_cu(1,:,:)
1609 combined_prod_cu(:,:,n)=2*conjg(prod_cu(n,:,:))
1612 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1615 longueur_tranche=bloc_size*m_max_c*nb_field
1616 mpid=mpi_double_precision
1617 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
1618 mpid,communicator,code)
1619 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1624 shiftc = (nb-1)*bloc_size
1625 shiftl = (nb-1)*m_max_c
1626 intermediate = dist_prod_cu(:,:,shiftl+i)
1628 IF (n+shiftc > np ) cycle
1629 DO i_field = 1, nb_field/2
1630 c_out(n+shiftc, 2*i_field-1, i) =
REAL (intermediate(i_field,n),kind=8)
1631 c_out(n+shiftc, 2*i_field, i) = aimag(intermediate(i_field,n))
1636 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1641 c_in, c_out, nb_procs, bloc_size, m_max_pad, rr_gauss, time, temps)
1650 FUNCTION eta(H_mesh,rr_gauss,angles,nb_angles,nb,ne,time) RESULT(vv)
1656 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: rr_gauss
1657 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: angles
1658 INTEGER,
INTENT(IN) :: nb_angles
1659 INTEGER,
INTENT(IN) :: nb, ne
1660 REAL(KIND=8),
INTENT(IN) :: time
1661 REAL(KIND=8),
DIMENSION(nb_angles,ne-nb+1) :: vv
1664 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad
1665 REAL(KIND=8),
DIMENSION(2*m_max_pad-1) :: angles
1666 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: eta_n
1669 REAL(KIND=8) :: time
1670 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: c_in
1671 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: c_out
1672 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: rr_gauss
1673 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
1674 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(c_in,2)/2, bloc_size) :: cu
1675 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, SIZE(c_in,2)/2, bloc_size) :: ru
1676 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(c_in,2)/2, bloc_size) :: prod_cu
1677 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, SIZE(c_in,2)/2,bloc_size) :: prod_ru
1678 REAL(KIND=8),
DIMENSION(SIZE(c_in,3),SIZE(c_in,2), bloc_size*nb_procs) :: dist_field, combined_field
1679 COMPLEX(KIND=8),
DIMENSION(SIZE(c_in,2)/2,bloc_size,SIZE(c_in,3)*nb_procs):: dist_prod_cu
1680 COMPLEX(KIND=8),
DIMENSION(SIZE(c_in,2)/2,bloc_size,SIZE(c_in,3)*nb_procs):: combined_prod_cu
1681 COMPLEX(KIND=8),
DIMENSION(SIZE(c_in,2)/2,bloc_size) :: intermediate
1682 INTEGER :: np, np_tot, m_max, m_max_c, mpid, n_r_pad, nb_field, i_field
1683 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
1684 INTEGER :: nb, ne, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
1687 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
1688 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
1691 #include "petsc/finclude/petsc.h"
1692 petscerrorcode :: ierr
1693 mpi_comm :: communicator
1695 IF (present(temps)) temps = 0.d0
1698 nb_field =
SIZE(c_in,2)
1699 m_max_c =
SIZE(c_in,3)
1700 m_max = m_max_c*nb_procs
1701 np_tot = nb_procs*bloc_size
1702 n_r_pad = 2*m_max_pad-1
1704 IF (m_max_c==0)
THEN
1711 angles(n) = 2*pi*(n-1)/n_r_pad
1721 dist_field(i,:,1:np) = transpose(c_in(:,:,i))
1723 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1725 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
1727 longueur_tranche=bloc_size*m_max_c*nb_field
1730 mpid=mpi_double_precision
1731 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
1732 mpid, communicator, code)
1733 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1741 shiftc = (nb-1)*bloc_size
1742 shiftl = (nb-1)*m_max_c
1744 DO nf = 1, nb_field/2
1748 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
1749 -combined_field(:,2*nf,jindex),kind=8)
1753 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
1759 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1762 fft_dim=1; istride=1; ostride=1;
1766 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
1767 odist=m_max_pad; onembed(1)=m_max_pad
1770 howmany=bloc_size*nb_field/2
1773 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
1774 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
1775 CALL dfftw_execute(fftw_plan_multi_c2r)
1778 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
1782 CALL mpi_comm_rank(communicator, rank_f, ierr)
1783 IF (rank_f==nb_procs-1)
THEN
1784 IF (np-rank_f*bloc_size.GE.1)
THEN
1785 nb = rank_f*bloc_size+1
1787 eta_n(:,1:np-rank_f*bloc_size) = eta(h_mesh,rr_gauss(:,nb:ne),angles,n_r_pad,nb,ne,time)
1788 eta_n(:,np-rank_f*bloc_size+1:bloc_size) = 1.d0
1793 nb = rank_f*bloc_size+1
1794 ne = rank_f*bloc_size+bloc_size
1795 eta_n(:,:) = eta(h_mesh,rr_gauss(:,nb:ne),angles,n_r_pad,nb,ne,time)
1798 IF (nb_field==2)
THEN
1799 prod_ru(:,1,:) = eta_n*ru(:,1,:)
1800 ELSE IF (nb_field==6)
THEN
1801 prod_ru(:,1,:) = eta_n*ru(:,1,:)
1802 prod_ru(:,2,:) = eta_n*ru(:,2,:)
1803 prod_ru(:,3,:) = eta_n*ru(:,3,:)
1805 CALL
error_petsc(
'error in nb_field of c_in while calling FFT_PAR_VAR_ETA_PROD_GAUSS_DCL')
1809 howmany = bloc_size*nb_field/2
1811 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
1812 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
1813 CALL dfftw_execute(fftw_plan_multi_r2c)
1816 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
1820 prod_cu = prod_cu*(1.d0/n_r_pad)
1822 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
1826 combined_prod_cu(:,:,1)=prod_cu(1,:,:)
1828 combined_prod_cu(:,:,n)=2*conjg(prod_cu(n,:,:))
1831 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1834 longueur_tranche=bloc_size*m_max_c*nb_field
1835 mpid=mpi_double_precision
1836 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
1837 mpid,communicator,code)
1838 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1843 shiftc = (nb-1)*bloc_size
1844 shiftl = (nb-1)*m_max_c
1845 intermediate = dist_prod_cu(:,:,shiftl+i)
1847 IF (n+shiftc > np ) cycle
1848 DO i_field = 1, nb_field/2
1849 c_out(n+shiftc, 2*i_field-1, i) =
REAL (intermediate(i_field,n),kind=8)
1850 c_out(n+shiftc, 2*i_field, i) = aimag(intermediate(i_field,n))
1855 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1861 REAL(KIND=8),
INTENT(IN) :: phi, eps
1862 REAL(KIND=8) :: x, r
1864 IF (x .LE. -eps)
THEN
1866 ELSE IF (x .LE. eps)
THEN
1867 r = (1+ x*(x**2 - 3*eps**2)/(-2*eps**3))/2
1875 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: phi
1876 REAL(KIND=8),
INTENT(IN) :: eps
1878 REAL(KIND=8),
DIMENSION(SIZE(phi)) :: r
1882 IF (x .LE. -eps)
THEN
1884 ELSE IF (x .LE. eps)
THEN
1885 r(n) = (1.d0 + x*(x**2 - 3*eps**2)/(-2*eps**3))/2
1893 nb_procs, bloc_size, m_max_pad, temps)
1901 REAL(KIND=8),
DIMENSION(:,:,:,:),
INTENT(IN) :: v1_in
1902 INTEGER,
INTENT(IN) :: nb_fluids
1903 INTEGER,
INTENT(OUT) :: interface_ok
1904 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
1905 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
1906 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
1907 INTEGER(KIND=8) :: fftw_plan_multi_c2r
1908 COMPLEX(KIND=8),
DIMENSION(m_max_pad, bloc_size) :: cu
1909 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size) :: ru
1910 REAL(KIND=8),
DIMENSION(SIZE(V1_in,4),SIZE(V1_in,3),bloc_size*nb_procs) :: dist_field, combined_field
1911 REAL(KIND=8),
DIMENSION(nb_fluids-1,2*m_max_pad-1, bloc_size) :: v1_real_loc
1913 INTEGER :: nb, shiftc, shiftl, jindex, longueur_tranche, i, n, code, interface_nb
1916 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
1917 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
1920 #include "petsc/finclude/petsc.h"
1921 mpi_comm :: communicator
1923 IF (present(temps)) temps = 0.d0
1926 nb_field=
SIZE(v1_in,3)
1927 m_max_c =
SIZE(v1_in,4)
1928 m_max = m_max_c*nb_procs
1929 n_r_pad=2*m_max_pad-1
1930 np_tot = nb_procs*bloc_size
1932 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
1949 DO interface_nb = 1, nb_fluids-1
1952 dist_field(i,1:nb_field,1:np) = transpose(v1_in(interface_nb,:,:,i))
1954 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1958 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 0.d0
1960 longueur_tranche=bloc_size*m_max_c*nb_field
1963 mpid=mpi_double_precision
1964 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
1965 mpid, communicator, code)
1967 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
1975 shiftc = (nb-1)*bloc_size
1976 shiftl = (nb-1)*m_max_c
1983 cu(shiftl+1:shiftl+m_max_c,n) = 0.5d0*cmplx(combined_field(:,1,jindex),&
1984 -combined_field(:,2,jindex),kind=8)
1987 cu(1,:) = 2*cmplx(
REAL(cu(1,:),KIND=8),0.d0,kind=8)
1990 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
1993 fft_dim=1; istride=1; ostride=1;
1997 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
1998 odist=m_max_pad; onembed(1)=m_max_pad
2001 howmany=bloc_size*nb_field/2
2004 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
2005 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
2007 CALL dfftw_execute(fftw_plan_multi_c2r)
2010 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
2011 v1_real_loc(interface_nb,:,:)=ru
2018 IF (nb_field==2)
THEN
2019 IF (nb_fluids==2)
THEN
2022 DO interface_nb = 1, nb_fluids-2
2023 DO n1 = 1, 2*m_max_pad-1
2024 DO n2 = 1, bloc_size
2025 IF((0.1d0.LE.v1_real_loc(interface_nb,n1,n2)).AND. &
2026 (v1_real_loc(interface_nb,n1,n2).LE.0.9d0))
THEN
2027 IF(v1_real_loc(interface_nb,n1,n2).LT.v1_real_loc(interface_nb+1,n1,n2))
THEN
2037 CALL
error_petsc(
'BUG in FFT_CHECK_INTERFACE: pb with V1_in dimensions')
2044 hloc_gauss, v1_out, v2_out, v3_out, &
2045 nb_procs, bloc_size, m_max_pad, residual_normalization, l_g, temps)
2055 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in, v3_in, v4_in, v5_in
2056 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: hloc_gauss
2057 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v1_out, v2_out, v3_out
2058 REAL(KIND=8),
INTENT(IN) :: residual_normalization
2059 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad, l_g
2060 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
2061 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(V1_in,2)*5/2, bloc_size) :: cu
2062 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)*5/2,bloc_size) :: ru
2063 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: visco_entro
2064 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru_1, prod_ru_2, prod_ru_3
2065 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu_1, prod_cu_2, prod_cu_3
2066 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size) :: intermediate_1
2067 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size) :: intermediate_2
2068 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size) :: intermediate_3
2069 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: norm_vel
2070 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size/l_G) :: norm_vel_int
2071 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),5*SIZE(V1_in,2),bloc_size*nb_procs) :: dist_field
2072 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),5*SIZE(V1_in,2),bloc_size*nb_procs) :: combined_field
2073 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_1
2074 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_2
2075 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_3
2076 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_1
2077 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_2
2078 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_3
2079 REAL(KIND=8),
DIMENSION(bloc_size*nb_procs) :: hloc_gauss_tot
2080 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
2081 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
2082 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code, rank, l, i_field
2083 REAL(KIND=8) ::
t, hh, x
2084 REAL(KIND=8) :: max_norm_vel_loc, max_norm_vel_loc_f, max_norm_vel_tot
2086 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
2087 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
2090 #include "petsc/finclude/petsc.h"
2091 mpi_comm :: communicator
2092 mpi_comm :: communicator_s
2093 CALL mpi_comm_rank(communicator, rank, code)
2095 IF (present(temps)) temps = 0.d0
2098 nb_field=
SIZE(v1_in,2)
2099 m_max_c =
SIZE(v1_in,3)
2100 m_max = m_max_c*nb_procs
2101 np_tot = nb_procs*bloc_size
2102 n_r_pad=2*m_max_pad-1
2104 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
2117 dist_field(i, 1:nb_field, 1:np) = transpose(v1_in(:,:,i))
2118 dist_field(i, nb_field+1:2*nb_field,1:np) = transpose(v2_in(:,:,i))
2119 dist_field(i,2*nb_field+1:3*nb_field,1:np) = transpose(v3_in(:,:,i))
2120 dist_field(i,3*nb_field+1:4*nb_field,1:np) = transpose(v4_in(:,:,i))
2121 dist_field(i,4*nb_field+1:5*nb_field,1:np) = transpose(v5_in(:,:,i))
2123 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2127 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 0.d0
2130 hloc_gauss_tot(1:np) = hloc_gauss
2131 IF (np/=np_tot) hloc_gauss_tot(np+1:np_tot) = 1.d100
2133 longueur_tranche=bloc_size*m_max_c*nb_field*5
2136 mpid=mpi_double_precision
2137 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
2138 mpid, communicator, code)
2139 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
2147 shiftc = (nb-1)*bloc_size
2148 shiftl = (nb-1)*m_max_c
2150 DO nf = 1, nb_field*5/2
2156 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
2157 -combined_field(:,2*nf,jindex),kind=8)
2161 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
2167 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2170 fft_dim=1; istride=1; ostride=1;
2174 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
2175 odist=m_max_pad; onembed(1)=m_max_pad
2178 howmany=bloc_size*nb_field*5/2
2181 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
2182 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
2184 CALL dfftw_execute(fftw_plan_multi_c2r)
2187 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
2196 norm_vel(:,:) = sqrt(ru(:,1,:)**2 + ru(:,2,:)**2 + ru(:,3,:)**2)
2197 DO i = 1, 2*m_max_pad - 1
2198 DO l = 1, bloc_size/l_g
2199 x = maxval(norm_vel(i,(l-1)*l_g+1:l*l_g))
2200 norm_vel_int(i,l) = x
2203 IF (2*m_max_pad - 1 .GE. 3)
THEN
2204 DO l = 1, bloc_size/l_g
2205 DO i = 2, 2*m_max_pad - 2
2206 norm_vel(i,(l-1)*l_g+1:l*l_g) = maxval(norm_vel_int(i-1:i+1,l))
2208 norm_vel(1,(l-1)*l_g+1:l*l_g) = max(norm_vel_int(1,l),norm_vel_int(2,l),norm_vel_int(2*m_max_pad - 1,l))
2209 norm_vel(2*m_max_pad - 1,(l-1)*l_g+1:l*l_g) = &
2210 max(norm_vel_int(2*m_max_pad - 2,l),norm_vel_int(2*m_max_pad - 1,l),norm_vel_int(1,l))
2213 DO l = 1, bloc_size/l_g
2214 norm_vel(1,(l-1)*l_g+1:l*l_g) = norm_vel_int(1,l)
2220 max_norm_vel_loc=maxval(norm_vel)
2221 CALL mpi_allreduce(max_norm_vel_loc,max_norm_vel_loc_f,1,mpi_double_precision, mpi_max, communicator, code)
2222 CALL mpi_allreduce(max_norm_vel_loc_f,max_norm_vel_tot,1,mpi_double_precision, mpi_max, communicator_s, code)
2227 hh = hloc_gauss_tot(n+rank*bloc_size)
2228 visco_entro(:,n) = -inputs%LES_coeff1 + min(inputs%LES_coeff4*norm_vel(:,n), &
2229 inputs%LES_coeff2*hh*abs(ru(:,1,n)*ru(:,4,n) + ru(:,2,n)*ru(:,5,n) + ru(:,3,n)*ru(:,6,n))&
2230 /(residual_normalization+1.d-14))
2235 prod_ru_1(:,1,:) = visco_entro*ru(:,7,:)
2236 prod_ru_1(:,2,:) = visco_entro*ru(:,8,:)
2237 prod_ru_1(:,3,:) = visco_entro*ru(:,9,:)
2239 prod_ru_2(:,1,:) = visco_entro*ru(:,10,:)
2240 prod_ru_2(:,2,:) = visco_entro*ru(:,11,:)
2241 prod_ru_2(:,3,:) = visco_entro*ru(:,12,:)
2243 prod_ru_3(:,1,:) = visco_entro*ru(:,13,:)
2244 prod_ru_3(:,2,:) = visco_entro*ru(:,14,:)
2245 prod_ru_3(:,3,:) = visco_entro*ru(:,15,:)
2248 howmany = bloc_size*nb_field/2
2249 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_1, &
2250 inembed, istride, idist, prod_cu_1, onembed, ostride, odist, fftw_estimate)
2252 CALL dfftw_execute(fftw_plan_multi_r2c)
2254 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
2256 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_2, &
2257 inembed, istride, idist, prod_cu_2, onembed, ostride, odist, fftw_estimate)
2259 CALL dfftw_execute(fftw_plan_multi_r2c)
2261 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
2263 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_3, &
2264 inembed, istride, idist, prod_cu_3, onembed, ostride, odist, fftw_estimate)
2266 CALL dfftw_execute(fftw_plan_multi_r2c)
2268 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
2270 prod_cu_1 = prod_cu_1*(1.d0/n_r_pad)
2271 prod_cu_2 = prod_cu_2*(1.d0/n_r_pad)
2272 prod_cu_3 = prod_cu_3*(1.d0/n_r_pad)
2274 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
2278 combined_prod_cu_1(:,:,1)=prod_cu_1(1,:,:)
2279 combined_prod_cu_2(:,:,1)=prod_cu_2(1,:,:)
2280 combined_prod_cu_3(:,:,1)=prod_cu_3(1,:,:)
2283 combined_prod_cu_1(:,:,n)=2*conjg(prod_cu_1(n,:,:))
2284 combined_prod_cu_2(:,:,n)=2*conjg(prod_cu_2(n,:,:))
2285 combined_prod_cu_3(:,:,n)=2*conjg(prod_cu_3(n,:,:))
2288 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2291 longueur_tranche=bloc_size*m_max_c*nb_field
2292 mpid=mpi_double_precision
2293 CALL mpi_alltoall(combined_prod_cu_1,longueur_tranche,mpid, dist_prod_cu_1,longueur_tranche, &
2294 mpid,communicator,code)
2295 CALL mpi_alltoall(combined_prod_cu_2,longueur_tranche,mpid, dist_prod_cu_2,longueur_tranche, &
2296 mpid,communicator,code)
2297 CALL mpi_alltoall(combined_prod_cu_3,longueur_tranche,mpid, dist_prod_cu_3,longueur_tranche, &
2298 mpid,communicator,code)
2299 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
2304 shiftc = (nb-1)*bloc_size
2305 shiftl = (nb-1)*m_max_c
2306 intermediate_1 = dist_prod_cu_1(:,:,shiftl+i)
2307 intermediate_2 = dist_prod_cu_2(:,:,shiftl+i)
2308 intermediate_3 = dist_prod_cu_3(:,:,shiftl+i)
2310 IF (n+shiftc > np ) cycle
2311 DO i_field = 1, nb_field/2
2312 v1_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate_1(i_field,n),kind=8)
2313 v1_out(n+shiftc, i_field*2 , i) = aimag(intermediate_1(i_field,n))
2314 v2_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate_2(i_field,n),kind=8)
2315 v2_out(n+shiftc, i_field*2 , i) = aimag(intermediate_2(i_field,n))
2316 v3_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate_3(i_field,n),kind=8)
2317 v3_out(n+shiftc, i_field*2 , i) = aimag(intermediate_3(i_field,n))
2322 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2327 c1_real_out, nb_procs, bloc_size, m_max_pad, l_g, opt_c2_real_out, temps)
2337 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in, v3_in
2338 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: c1_in
2339 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: hloc_gauss
2340 REAL(KIND=8),
DIMENSION(:,:),
INTENT(OUT) :: c1_real_out
2341 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad, l_g
2342 REAL(KIND=8),
DIMENSION(:,:),
OPTIONAL,
INTENT(OUT) :: opt_c2_real_out
2343 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
2344 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),3*SIZE(V1_in,2)+SIZE(c1_in,2),bloc_size*nb_procs) :: dist_field
2345 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),3*SIZE(V1_in,2)+SIZE(c1_in,2),bloc_size*nb_procs) :: combined_field
2346 COMPLEX(KIND=8),
DIMENSION(m_max_pad, (3*SIZE(V1_in,2)+SIZE(c1_in,2))/2, bloc_size) :: cu
2347 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,(3*SIZE(V1_in,2)+SIZE(c1_in,2))/2,bloc_size) :: ru
2348 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: norm_vel, norm_mom
2349 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size/l_G) :: norm_vel_int, norm_mom_int
2350 REAL(KIND=8),
DIMENSION(bloc_size*nb_procs) :: hloc_gauss_tot
2351 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: visco_entro
2352 INTEGER :: np, np_tot, nb_field, nb_field2, m_max, m_max_c, mpid, n_r_pad
2353 INTEGER(KIND=8) :: fftw_plan_multi_c2r
2354 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code, rank, l
2355 REAL(KIND=8) ::
t, hh, x, max_vel_loc, max_vel_f, max_vel_tot
2357 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
2358 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
2361 #include "petsc/finclude/petsc.h"
2362 mpi_comm :: communicator
2363 mpi_comm :: communicator_s
2365 CALL mpi_comm_rank(communicator, rank, code)
2367 IF (present(temps)) temps = 0.d0
2370 nb_field =
SIZE(v1_in,2)
2371 nb_field2 =
SIZE(c1_in,2)
2372 m_max_c =
SIZE(v1_in,3)
2373 m_max = m_max_c*nb_procs
2374 np_tot = nb_procs*bloc_size
2375 n_r_pad = 2*m_max_pad-1
2377 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
2390 dist_field(i, 1:nb_field, 1:np) = transpose(v1_in(:,:,i))
2391 dist_field(i, nb_field+1:2*nb_field,1:np) = transpose(v2_in(:,:,i))
2392 dist_field(i,2*nb_field+1:3*nb_field,1:np) = transpose(v3_in(:,:,i))
2393 dist_field(i,3*nb_field+1:3*nb_field+nb_field2,1:np) = transpose(c1_in(:,:,i))
2395 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2397 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 0.d0
2399 hloc_gauss_tot(1:np) = hloc_gauss
2400 IF (np/=np_tot) hloc_gauss_tot(np+1:np_tot) = 1.d100
2402 longueur_tranche=bloc_size*m_max_c*(nb_field*3+nb_field2)
2405 mpid=mpi_double_precision
2406 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
2407 mpid, communicator, code)
2408 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
2416 shiftc = (nb-1)*bloc_size
2417 shiftl = (nb-1)*m_max_c
2419 DO nf = 1, (3*nb_field+nb_field2)/2
2425 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
2426 -combined_field(:,2*nf,jindex),kind=8)
2430 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
2436 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2439 fft_dim=1; istride=1; ostride=1;
2441 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
2442 odist=m_max_pad; onembed(1)=m_max_pad
2445 howmany=bloc_size*(nb_field*3+nb_field2)/2
2448 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
2449 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
2451 CALL dfftw_execute(fftw_plan_multi_c2r)
2454 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
2462 norm_vel(:,:) = sqrt(ru(:,1,:)**2 + ru(:,2,:)**2 + ru(:,3,:)**2)
2463 norm_mom(:,:) = sqrt(ru(:,4,:)**2 + ru(:,5,:)**2 + ru(:,6,:)**2)
2464 DO i = 1, 2*m_max_pad - 1
2465 DO l = 1, bloc_size/l_g
2466 x = maxval(norm_vel(i,(l-1)*l_g+1:l*l_g))
2467 norm_vel_int(i,l) = x
2468 x = maxval(norm_mom(i,(l-1)*l_g+1:l*l_g))
2469 norm_mom_int(i,l) = x
2472 IF (2*m_max_pad - 1 .GE. 3)
THEN
2473 DO l = 1, bloc_size/l_g
2474 DO i = 2, 2*m_max_pad - 2
2475 norm_vel(i,(l-1)*l_g+1:l*l_g) = maxval(norm_vel_int(i-1:i+1,l))
2476 norm_mom(i,(l-1)*l_g+1:l*l_g) = maxval(norm_mom_int(i-1:i+1,l))
2478 norm_vel(1,(l-1)*l_g+1:l*l_g) = max(norm_vel_int(1,l),norm_vel_int(2,l),norm_vel_int(2*m_max_pad - 1,l))
2479 norm_vel(2*m_max_pad - 1,(l-1)*l_g+1:l*l_g) = &
2480 max(norm_vel_int(2*m_max_pad - 2,l),norm_vel_int(2*m_max_pad - 1,l),norm_vel_int(1,l))
2481 norm_mom(1,(l-1)*l_g+1:l*l_g) = max(norm_mom_int(1,l),norm_mom_int(2,l),norm_mom_int(2*m_max_pad - 1,l))
2482 norm_mom(2*m_max_pad - 1,(l-1)*l_g+1:l*l_g) = &
2483 max(norm_mom_int(2*m_max_pad - 2,l),norm_mom_int(2*m_max_pad - 1,l),norm_mom_int(1,l))
2486 DO l = 1, bloc_size/l_g
2487 norm_vel(1,(l-1)*l_g+1:l*l_g) = norm_vel_int(1,l)
2488 norm_mom(1,(l-1)*l_g+1:l*l_g) = norm_mom_int(1,l)
2494 max_vel_loc=maxval(norm_vel)
2495 CALL mpi_allreduce(max_vel_loc,max_vel_f, 1, mpi_double_precision, &
2496 mpi_max, communicator, code)
2497 CALL mpi_allreduce(max_vel_f, max_vel_tot, 1, mpi_double_precision, &
2498 mpi_max, communicator_s, code)
2503 hh = hloc_gauss_tot(n+rank*bloc_size)
2505 visco_entro(:,n) = inputs%LES_coeff2*hh* &
2506 max(abs(ru(:,1,n)*ru(:,7,n) + ru(:,2,n)*ru(:,8,n) + ru(:,3,n)*ru(:,9,n)), &
2507 abs(ru(:,10,n)*(ru(:,1,n)**2 + ru(:,2,n)**2 + ru(:,3,n)**2)))
2512 IF (2*m_max_pad - 1 .GE. 3)
THEN
2513 DO l = 1, bloc_size/l_g
2514 DO i = 2, 2*m_max_pad - 2
2515 norm_vel_int(i,l) = maxval(visco_entro(i-1:i+1,(l-1)*l_g+1:l*l_g))
2517 norm_vel_int(1,l) = max(maxval(visco_entro(1,(l-1)*l_g+1:l*l_g)),maxval(visco_entro(2,(l-1)*l_g+1:l*l_g)),&
2518 maxval(visco_entro(2*m_max_pad - 1,(l-1)*l_g+1:l*l_g)))
2519 norm_vel_int(2*m_max_pad - 1,l) = max(maxval(visco_entro(2*m_max_pad - 2,(l-1)*l_g+1:l*l_g)),&
2520 maxval(visco_entro(2*m_max_pad - 1,(l-1)*l_g+1:l*l_g)),maxval(visco_entro(1,(l-1)*l_g+1:l*l_g)))
2523 DO l = 1, bloc_size/l_g
2524 norm_vel_int(1,l) = maxval(visco_entro(1,(l-1)*l_g+1:l*l_g))
2527 DO i = 1, 2*m_max_pad - 1
2528 DO l = 1, bloc_size/l_g
2529 visco_entro(i,(l-1)*l_g+1:l*l_g)=norm_vel_int(i,l)
2537 c1_real_out(:,n) = min(4*inputs%LES_coeff4*max_vel_tot, &
2538 16*visco_entro(:,n)/(norm_vel(:,n)*norm_mom(:,n)+1.d-14))
2540 c1_real_out(:,n) = min(inputs%LES_coeff4*norm_vel(:,n), &
2541 visco_entro(:,n)/(norm_vel(:,n)*norm_mom(:,n)+1.d-14))
2542 IF (present(opt_c2_real_out))
THEN
2543 opt_c2_real_out(:,n) = min(inputs%LES_coeff4*max_vel_tot, &
2544 visco_entro(:,n)/(norm_vel(:,n)*norm_mom(:,n)+1.d-14))
2550 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2555 v1_out, v2_out, nb_procs, bloc_size, m_max_pad, temps)
2564 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in
2565 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v3_in
2566 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v1_out
2567 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v2_out
2568 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
2569 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
2570 INTEGER :: np, np_tot, nb_field1, nb_field2, nb_field3
2571 INTEGER :: m_max, m_max_c, mpid, n_r_pad
2572 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
2573 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2)+SIZE(V3_in,2), bloc_size*nb_procs) :: dist_field
2574 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2)+SIZE(V3_in,2), bloc_size*nb_procs) :: combined_field
2575 COMPLEX(KIND=8),
DIMENSION(m_max_pad, (2*SIZE(V1_in,2)+SIZE(V3_in,2))/2, bloc_size) :: cu
2576 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,(2*SIZE(V1_in,2)+SIZE(V3_in,2))/2,bloc_size) :: ru
2577 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru_1, prod_ru_2
2578 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu_1, prod_cu_2
2579 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size) :: intermediate_1, intermediate_2
2580 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_1
2581 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_2
2582 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_1
2583 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_2
2584 INTEGER :: i_field, rank
2585 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
2588 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
2589 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
2592 #include "petsc/finclude/petsc.h"
2593 mpi_comm :: communicator
2594 petscerrorcode :: ierr
2596 IF (present(temps)) temps = 0.d0
2598 CALL mpi_comm_rank(communicator, rank, ierr)
2601 nb_field1=
SIZE(v1_in,2)
2602 nb_field2=
SIZE(v2_in,2)
2603 nb_field3=
SIZE(v3_in,2)
2604 m_max_c =
SIZE(v1_in,3)
2605 m_max = m_max_c*nb_procs
2606 n_r_pad = 2*m_max_pad-1
2607 np_tot = nb_procs*bloc_size
2609 IF (mod(nb_field1,2)/=0 .OR. mod(nb_field2,2)/=0 .OR. m_max_c==0)
THEN
2627 dist_field(i,1:nb_field1,1:np) = transpose(v1_in(:,:,i))
2628 dist_field(i,nb_field1+1:2*nb_field1,1:np) = transpose(v2_in(:,:,i))
2629 dist_field(i,2*nb_field1+1:2*nb_field1+nb_field3,1:np) = transpose(v3_in(:,:,i))
2631 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2633 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 0.d0
2635 longueur_tranche=bloc_size*m_max_c*(nb_field1+nb_field2+nb_field3)
2638 mpid=mpi_double_precision
2639 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
2640 mpid, communicator, code)
2641 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
2649 shiftc = (nb-1)*bloc_size
2650 shiftl = (nb-1)*m_max_c
2652 DO nf = 1, (nb_field1+nb_field2+nb_field3)/2
2658 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
2659 -combined_field(:,2*nf,jindex),kind=8)
2663 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
2669 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2672 fft_dim=1; istride=1; ostride=1;
2676 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
2677 odist=m_max_pad; onembed(1)=m_max_pad
2680 howmany=bloc_size*(nb_field1+nb_field2+nb_field3)/2
2683 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
2684 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
2686 CALL dfftw_execute(fftw_plan_multi_c2r)
2689 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
2695 IF (nb_field1==6 .AND. nb_field2==6 .AND. nb_field3==2)
THEN
2697 prod_ru_1(:,1,:) = ru(:,7,:)*ru(:,1,:)
2698 prod_ru_1(:,2,:) = ru(:,7,:)*ru(:,2,:)
2699 prod_ru_1(:,3,:) = ru(:,7,:)*ru(:,3,:)
2701 prod_ru_2(:,1,:) = ru(:,7,:)*ru(:,4,:)
2702 prod_ru_2(:,2,:) = ru(:,7,:)*ru(:,5,:)
2703 prod_ru_2(:,3,:) = ru(:,7,:)*ru(:,6,:)
2706 CALL
error_petsc(
'error on inputs while calling FFT_COMPUTE_DIFFU_MOM')
2709 howmany = bloc_size*nb_field1/2
2710 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_1, &
2711 inembed, istride, idist, prod_cu_1, onembed, ostride, odist, fftw_estimate)
2712 CALL dfftw_execute(fftw_plan_multi_r2c)
2714 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
2716 howmany = bloc_size*nb_field1/2
2717 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_2, &
2718 inembed, istride, idist, prod_cu_2, onembed, ostride, odist, fftw_estimate)
2719 CALL dfftw_execute(fftw_plan_multi_r2c)
2721 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
2725 prod_cu_1 = prod_cu_1*(1.d0/n_r_pad)
2726 prod_cu_2 = prod_cu_2*(1.d0/n_r_pad)
2728 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
2733 combined_prod_cu_1(:,:,1)=prod_cu_1(1,:,:)
2734 combined_prod_cu_2(:,:,1)=prod_cu_2(1,:,:)
2736 combined_prod_cu_1(:,:,n)=2*conjg(prod_cu_1(n,:,:))
2737 combined_prod_cu_2(:,:,n)=2*conjg(prod_cu_2(n,:,:))
2740 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2743 longueur_tranche=bloc_size*m_max_c*nb_field1
2744 mpid=mpi_double_precision
2745 CALL mpi_alltoall(combined_prod_cu_1,longueur_tranche,mpid, dist_prod_cu_1,longueur_tranche, &
2746 mpid,communicator,code)
2747 CALL mpi_alltoall(combined_prod_cu_2,longueur_tranche,mpid, dist_prod_cu_2,longueur_tranche, &
2748 mpid,communicator,code)
2750 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
2755 shiftc = (nb-1)*bloc_size
2756 shiftl = (nb-1)*m_max_c
2757 intermediate_1 = dist_prod_cu_1(:,:,shiftl+i)
2758 intermediate_2 = dist_prod_cu_2(:,:,shiftl+i)
2760 IF (n+shiftc > np ) cycle
2761 DO i_field = 1, nb_field1/2
2762 v1_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate_1(i_field,n),kind=8)
2763 v1_out(n+shiftc, i_field*2 , i) = aimag(intermediate_1(i_field,n))
2764 v2_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate_2(i_field,n),kind=8)
2765 v2_out(n+shiftc, i_field*2 , i) = aimag(intermediate_2(i_field,n))
2771 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2776 coeff1_in_level, v_out, c_out, nb_procs, bloc_size, m_max_pad, temps)
2785 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in
2786 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: c1_in
2787 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: c_in_real
2788 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: hloc_gauss
2789 REAL(KIND=8),
INTENT(IN) :: coeff1_in_level
2790 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v_out
2791 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: c_out
2792 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
2793 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
2794 INTEGER :: np, np_tot, nb_field1, nb_field2, nb_field3
2795 INTEGER :: m_max, m_max_c, mpid, n_r_pad
2796 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
2797 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2)+SIZE(c1_in,2),bloc_size*nb_procs) :: dist_field
2798 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2)+SIZE(c1_in,2),bloc_size*nb_procs) :: combined_field
2799 COMPLEX(KIND=8),
DIMENSION(m_max_pad, (2*SIZE(V1_in,2)+SIZE(c1_in,2))/2, bloc_size) :: cu
2800 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,(2*SIZE(V1_in,2)+SIZE(c1_in,2))/2,bloc_size) :: ru
2801 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size) :: norm_grad_phi
2802 REAL(KIND=8),
DIMENSION(bloc_size*nb_procs) :: hloc_gauss_tot
2803 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size) :: visc_comp, visc_entro
2804 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu
2805 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru
2806 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2, bloc_size) :: intermediate
2807 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu
2808 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu
2809 COMPLEX(KIND=8),
DIMENSION(m_max_pad,bloc_size) :: prod_cu2
2810 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: prod_ru2
2811 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu2
2812 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu2
2813 COMPLEX(KIND=8),
DIMENSION(bloc_size) :: intermediate2
2815 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
2819 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
2820 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
2823 #include "petsc/finclude/petsc.h"
2824 mpi_comm :: communicator
2826 CALL mpi_comm_rank(communicator, rank, code)
2828 IF (present(temps)) temps = 0.d0
2831 nb_field1=
SIZE(v1_in,2)
2832 nb_field2=
SIZE(v2_in,2)
2833 nb_field3=
SIZE(c1_in,2)
2834 m_max_c =
SIZE(v1_in,3)
2835 m_max = m_max_c*nb_procs
2836 n_r_pad = 2*m_max_pad-1
2837 np_tot = nb_procs*bloc_size
2839 IF (mod(nb_field1,2)/=0 .OR. mod(nb_field2,2)/=0 .OR. m_max_c==0)
THEN
2857 dist_field(i,1:nb_field1,1:np) = transpose(v1_in(:,:,i))
2858 dist_field(i,nb_field1+1:2*nb_field1,1:np) = transpose(v2_in(:,:,i))
2859 dist_field(i,2*nb_field1+1:2*nb_field1+nb_field3,1:np) = transpose(c1_in(:,:,i))
2861 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2863 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
2865 hloc_gauss_tot(1:np) = hloc_gauss
2866 IF (np/=np_tot) hloc_gauss_tot(np+1:np_tot) = 1.d100
2868 longueur_tranche=bloc_size*m_max_c*(nb_field1+nb_field2+nb_field3)
2871 mpid=mpi_double_precision
2872 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
2873 mpid, communicator, code)
2874 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
2882 shiftc = (nb-1)*bloc_size
2883 shiftl = (nb-1)*m_max_c
2885 DO nf = 1, (nb_field1+nb_field2+nb_field3)/2
2891 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
2892 -combined_field(:,2*nf,jindex),kind=8)
2896 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
2902 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2905 fft_dim=1; istride=1; ostride=1;
2909 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
2910 odist=m_max_pad; onembed(1)=m_max_pad
2913 howmany=bloc_size*(nb_field1+nb_field2+nb_field3)/2
2916 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
2917 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
2919 CALL dfftw_execute(fftw_plan_multi_c2r)
2922 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
2924 IF (nb_field1 == 6 .AND. nb_field2 == 6 .AND. nb_field3 == 2)
THEN
2931 prod_ru2(:,:) = max(0.d0, ru(:,7,:)*(1.d0 - ru(:,7,:)))
2934 norm_grad_phi(:,:) = sqrt(ru(:,4,:)**2 + ru(:,5,:)**2 + ru(:,6,:)**2) + 1.d-14
2938 visc_entro(:,n) = -coeff1_in_level + c_in_real(:,n)
2939 visc_comp(:,n)= c_in_real(:,n)*inputs%level_set_comp_factor*prod_ru2(:,n)/norm_grad_phi(:,n)
2943 prod_ru(:,1,:) = -visc_entro*ru(:,1,:) + visc_comp*ru(:,4,:)
2944 prod_ru(:,2,:) = -visc_entro*ru(:,2,:) + visc_comp*ru(:,5,:)
2945 prod_ru(:,3,:) = -visc_entro*ru(:,3,:) + visc_comp*ru(:,6,:)
2961 CALL
error_petsc(
'error in problem type while calling FFT_PAR_COMPR_ENTRO_VISC_DCL')
2964 howmany = bloc_size*nb_field1/2
2965 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
2966 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
2967 CALL dfftw_execute(fftw_plan_multi_r2c)
2969 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
2971 howmany = bloc_size*1
2972 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru2, &
2973 inembed, istride, idist, prod_cu2, onembed, ostride, odist, fftw_estimate)
2974 CALL dfftw_execute(fftw_plan_multi_r2c)
2976 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
2980 prod_cu = prod_cu*(1.d0/n_r_pad)
2981 prod_cu2 = prod_cu2*(1.d0/n_r_pad)
2983 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
2988 combined_prod_cu(:,:,1)=prod_cu(1,:,:)
2989 combined_prod_cu2(:,1)=prod_cu2(1,:)
2991 combined_prod_cu(:,:,n)=2*conjg(prod_cu(n,:,:))
2992 combined_prod_cu2(:,n)=2*conjg(prod_cu2(n,:))
2995 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
2998 longueur_tranche=bloc_size*m_max_c*nb_field1
2999 mpid=mpi_double_precision
3000 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
3001 mpid,communicator,code)
3003 longueur_tranche=bloc_size*m_max_c*2
3004 mpid=mpi_double_precision
3005 CALL mpi_alltoall(combined_prod_cu2,longueur_tranche,mpid, dist_prod_cu2,longueur_tranche, &
3006 mpid,communicator,code)
3008 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3014 shiftc = (nb-1)*bloc_size
3015 shiftl = (nb-1)*m_max_c
3016 intermediate = dist_prod_cu(:,:,shiftl+i)
3017 intermediate2 = dist_prod_cu2(:,shiftl+i)
3019 IF (n+shiftc > np ) cycle
3020 DO i_field = 1, nb_field1/2
3021 v_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate(i_field,n),kind=8)
3022 v_out(n+shiftc, i_field*2 , i) = aimag(intermediate(i_field,n))
3024 c_out(n+shiftc, 1, i) =
REAL (intermediate2(n),kind=8)
3025 c_out(n+shiftc, 2, i) = aimag(intermediate2(n))
3030 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3035 v_out, nb_procs, bloc_size, m_max_pad, temps)
3045 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in, v3_in
3046 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: c_in_real
3047 REAL(KIND=8),
DIMENSION(:,:,:,:),
INTENT(OUT) :: v_out
3048 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad
3049 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
3050 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(V1_in,2)*3/2, bloc_size) :: cu
3051 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)*3/2,bloc_size) :: ru
3052 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: visco_entro
3053 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru_1, prod_ru_2, prod_ru_3
3054 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu_1, prod_cu_2, prod_cu_3
3056 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size) :: intermediate_1, intermediate_2, intermediate_3
3057 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),3*SIZE(V1_in,2),bloc_size*nb_procs) :: dist_field, combined_field
3058 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_1
3059 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_2
3060 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu_3
3061 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_1
3062 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_2
3063 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu_3
3064 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
3065 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
3066 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code, rank, i_field
3069 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
3070 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
3073 #include "petsc/finclude/petsc.h"
3074 mpi_comm :: communicator
3075 CALL mpi_comm_rank(communicator, rank, code)
3077 IF (present(temps)) temps = 0.d0
3080 nb_field=
SIZE(v1_in,2)
3081 m_max_c =
SIZE(v1_in,3)
3082 m_max = m_max_c*nb_procs
3083 np_tot = nb_procs*bloc_size
3084 n_r_pad=2*m_max_pad-1
3086 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
3099 dist_field(i, 1:nb_field, 1:np) = transpose(v1_in(:,:,i))
3100 dist_field(i, nb_field+1:2*nb_field,1:np) = transpose(v2_in(:,:,i))
3101 dist_field(i,2*nb_field+1:3*nb_field,1:np) = transpose(v3_in(:,:,i))
3103 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3105 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
3107 longueur_tranche=bloc_size*m_max_c*nb_field*3
3110 mpid=mpi_double_precision
3111 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
3112 mpid, communicator, code)
3113 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3121 shiftc = (nb-1)*bloc_size
3122 shiftl = (nb-1)*m_max_c
3124 DO nf = 1, nb_field*3/2
3130 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
3131 -combined_field(:,2*nf,jindex),kind=8)
3135 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
3141 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3144 fft_dim=1; istride=1; ostride=1;
3148 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
3149 odist=m_max_pad; onembed(1)=m_max_pad
3152 howmany=bloc_size*nb_field*3/2
3155 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
3156 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
3158 CALL dfftw_execute(fftw_plan_multi_c2r)
3160 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
3168 visco_entro(:,n) = -inputs%LES_coeff1 + c_in_real(:,n)
3173 prod_ru_1(:,1,:) = visco_entro*ru(:,1,:)
3174 prod_ru_1(:,2,:) = visco_entro*ru(:,2,:)
3175 prod_ru_1(:,3,:) = visco_entro*ru(:,3,:)
3177 prod_ru_2(:,1,:) = visco_entro*ru(:,4,:)
3178 prod_ru_2(:,2,:) = visco_entro*ru(:,5,:)
3179 prod_ru_2(:,3,:) = visco_entro*ru(:,6,:)
3181 prod_ru_3(:,1,:) = visco_entro*ru(:,7,:)
3182 prod_ru_3(:,2,:) = visco_entro*ru(:,8,:)
3183 prod_ru_3(:,3,:) = visco_entro*ru(:,9,:)
3186 howmany = bloc_size*nb_field/2
3187 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_1, &
3188 inembed, istride, idist, prod_cu_1, onembed, ostride, odist, fftw_estimate)
3190 CALL dfftw_execute(fftw_plan_multi_r2c)
3192 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
3194 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_2, &
3195 inembed, istride, idist, prod_cu_2, onembed, ostride, odist, fftw_estimate)
3197 CALL dfftw_execute(fftw_plan_multi_r2c)
3199 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
3201 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_3, &
3202 inembed, istride, idist, prod_cu_3, onembed, ostride, odist, fftw_estimate)
3204 CALL dfftw_execute(fftw_plan_multi_r2c)
3206 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
3208 prod_cu_1 = prod_cu_1*(1.d0/n_r_pad)
3209 prod_cu_2 = prod_cu_2*(1.d0/n_r_pad)
3210 prod_cu_3 = prod_cu_3*(1.d0/n_r_pad)
3212 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
3216 combined_prod_cu_1(:,:,1)=prod_cu_1(1,:,:)
3217 combined_prod_cu_2(:,:,1)=prod_cu_2(1,:,:)
3218 combined_prod_cu_3(:,:,1)=prod_cu_3(1,:,:)
3221 combined_prod_cu_1(:,:,n)=2*conjg(prod_cu_1(n,:,:))
3222 combined_prod_cu_2(:,:,n)=2*conjg(prod_cu_2(n,:,:))
3223 combined_prod_cu_3(:,:,n)=2*conjg(prod_cu_3(n,:,:))
3226 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3229 longueur_tranche=bloc_size*m_max_c*nb_field
3230 mpid=mpi_double_precision
3231 CALL mpi_alltoall(combined_prod_cu_1,longueur_tranche,mpid, dist_prod_cu_1,longueur_tranche, &
3232 mpid,communicator,code)
3233 CALL mpi_alltoall(combined_prod_cu_2,longueur_tranche,mpid, dist_prod_cu_2,longueur_tranche, &
3234 mpid,communicator,code)
3235 CALL mpi_alltoall(combined_prod_cu_3,longueur_tranche,mpid, dist_prod_cu_3,longueur_tranche, &
3236 mpid,communicator,code)
3237 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3242 shiftc = (nb-1)*bloc_size
3243 shiftl = (nb-1)*m_max_c
3244 intermediate_1 = dist_prod_cu_1(:,:,shiftl+i)
3245 intermediate_2 = dist_prod_cu_2(:,:,shiftl+i)
3246 intermediate_3 = dist_prod_cu_3(:,:,shiftl+i)
3248 IF (n+shiftc > np ) cycle
3249 DO i_field = 1, nb_field/2
3250 v_out(1,n+shiftc, i_field*2-1, i) =
REAL (intermediate_1(i_field,n),kind=8)
3251 v_out(1,n+shiftc, i_field*2 , i) = aimag(intermediate_1(i_field,n))
3252 v_out(2,n+shiftc, i_field*2-1, i) =
REAL (intermediate_2(i_field,n),kind=8)
3253 v_out(2,n+shiftc, i_field*2 , i) = aimag(intermediate_2(i_field,n))
3254 v_out(3,n+shiftc, i_field*2-1, i) =
REAL (intermediate_3(i_field,n),kind=8)
3255 v_out(3,n+shiftc, i_field*2 , i) = aimag(intermediate_3(i_field,n))
3260 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3274 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(INOUT) :: c1_inout
3275 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad
3276 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
3277 REAL(KIND=8),
DIMENSION(SIZE(c1_inout,3),SIZE(c1_inout,2),bloc_size*nb_procs) :: dist_field
3278 REAL(KIND=8),
DIMENSION(SIZE(c1_inout,3),SIZE(c1_inout,2),bloc_size*nb_procs) :: combined_field
3279 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(c1_inout,2)/2, bloc_size) :: cu
3280 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(c1_inout,2)/2,bloc_size) :: ru
3281 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: prod_ru_1
3282 COMPLEX(KIND=8),
DIMENSION(m_max_pad,bloc_size) :: prod_cu_1
3283 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(c1_inout,3)*nb_procs) :: combined_prod_cu_1
3284 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(c1_inout,3)*nb_procs) :: dist_prod_cu_1
3285 COMPLEX(KIND=8),
DIMENSION(bloc_size) :: intermediate_1
3286 INTEGER :: np, np_tot, nb_field, m_max, m_max_c, mpid, n_r_pad
3287 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
3288 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code, rank
3291 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
3292 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
3295 #include "petsc/finclude/petsc.h"
3296 mpi_comm :: communicator
3298 CALL mpi_comm_rank(communicator, rank, code)
3300 IF (present(temps)) temps = 0.d0
3302 np =
SIZE(c1_inout,1)
3303 nb_field =
SIZE(c1_inout,2)
3304 m_max_c =
SIZE(c1_inout,3)
3305 m_max = m_max_c*nb_procs
3306 np_tot = nb_procs*bloc_size
3307 n_r_pad = 2*m_max_pad-1
3309 IF (mod(nb_field,2)/=0 .OR. m_max_c==0)
THEN
3322 dist_field(i, 1:nb_field, 1:np) = transpose(c1_inout(:,:,i))
3324 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3326 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 0.d0
3328 longueur_tranche=bloc_size*m_max_c*nb_field
3331 mpid=mpi_double_precision
3332 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
3333 mpid, communicator, code)
3334 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3342 shiftc = (nb-1)*bloc_size
3343 shiftl = (nb-1)*m_max_c
3345 DO nf = 1, nb_field/2
3351 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
3352 -combined_field(:,2*nf,jindex),kind=8)
3356 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
3362 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3365 fft_dim=1; istride=1; ostride=1;
3369 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
3370 odist=m_max_pad; onembed(1)=m_max_pad
3373 howmany=bloc_size*nb_field/2
3376 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
3377 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
3379 CALL dfftw_execute(fftw_plan_multi_c2r)
3382 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
3386 prod_ru_1(:,n) = max(0.d0, min(1.d0, ru(:,1,n)))
3390 howmany = bloc_size*1
3391 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru_1, &
3392 inembed, istride, idist, prod_cu_1, onembed, ostride, odist, fftw_estimate)
3394 CALL dfftw_execute(fftw_plan_multi_r2c)
3396 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
3398 prod_cu_1 = prod_cu_1*(1.d0/n_r_pad)
3400 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
3404 combined_prod_cu_1(:,1)=prod_cu_1(1,:)
3407 combined_prod_cu_1(:,n)=2*conjg(prod_cu_1(n,:))
3410 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3413 longueur_tranche=bloc_size*m_max_c*2
3414 mpid=mpi_double_precision
3415 CALL mpi_alltoall(combined_prod_cu_1,longueur_tranche,mpid, dist_prod_cu_1,longueur_tranche, &
3416 mpid,communicator,code)
3417 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3422 shiftc = (nb-1)*bloc_size
3423 shiftl = (nb-1)*m_max_c
3424 intermediate_1 = dist_prod_cu_1(:,shiftl+i)
3426 IF (n+shiftc > np ) cycle
3427 c1_inout(n+shiftc, 1, i) =
REAL (intermediate_1(n),kind=8)
3428 c1_inout(n+shiftc, 2, i) = aimag(intermediate_1(n))
3432 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3437 hloc_gauss, l_g, nb_procs, bloc_size, m_max_pad, temps)
3449 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in, v2_in
3450 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: c_in
3451 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: c_out
3452 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: hloc_gauss
3453 INTEGER,
INTENT(IN) :: l_g
3454 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
3455 INTEGER,
INTENT(IN) :: nb_procs, bloc_size, m_max_pad
3456 COMPLEX(KIND=8),
DIMENSION(m_max_pad, SIZE(V1_in,2)+SIZE(c_in,2)/2, bloc_size) :: cu
3457 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)+SIZE(c_in,2)/2,bloc_size) :: ru
3458 COMPLEX(KIND=8),
DIMENSION(m_max_pad,bloc_size) :: prod_cu
3459 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: prod_ru
3460 COMPLEX(KIND=8),
DIMENSION(bloc_size) :: intermediate
3461 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2)+SIZE(c_in,2),bloc_size*nb_procs) :: dist_field
3462 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),2*SIZE(V1_in,2)+SIZE(c_in,2),bloc_size*nb_procs) :: combined_field
3463 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu
3464 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu
3465 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: norm_vel
3466 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size/l_G) :: norm_vel_int
3467 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: norm_grad_phi
3468 REAL(KIND=8),
DIMENSION(bloc_size*nb_procs) :: hloc_gauss_tot
3469 REAL(KIND=8) :: hh, x, max_norm_vel_loc, max_norm_vel_loc_f, max_norm_vel_tot
3471 INTEGER :: np, np_tot, nb_field, nb_field2, m_max, m_max_c, mpid, n_r_pad
3472 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
3473 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
3476 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
3477 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
3480 #include "petsc/finclude/petsc.h"
3481 mpi_comm :: communicator_f
3482 mpi_comm :: communicator_s
3484 IF (present(temps)) temps = 0.d0
3486 CALL mpi_comm_rank(communicator_f, rank, code)
3489 nb_field =
SIZE(v1_in,2)
3490 nb_field2=
SIZE(c_in,2)
3491 m_max_c =
SIZE(v1_in,3)
3492 m_max = m_max_c*nb_procs
3493 np_tot = nb_procs*bloc_size
3494 n_r_pad = 2*m_max_pad-1
3496 IF (mod(nb_field,2)/=0 .OR. mod(nb_field2,2)/=0 .OR. m_max_c==0)
THEN
3509 dist_field(i,1:nb_field,1:np) = transpose(v1_in(:,:,i))
3510 dist_field(i,nb_field+1:2*nb_field,1:np) = transpose(v2_in(:,:,i))
3511 dist_field(i,2*nb_field+1:2*nb_field+nb_field2,1:np) = transpose(c_in(:,:,i))
3513 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3515 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 0.d0
3517 hloc_gauss_tot(1:np) = hloc_gauss
3518 IF (np/=np_tot) hloc_gauss_tot(np+1:np_tot) = 1.d100
3520 longueur_tranche=bloc_size*m_max_c*(nb_field*2+nb_field2)
3523 mpid=mpi_double_precision
3524 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
3525 mpid, communicator_f, code)
3526 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3534 shiftc = (nb-1)*bloc_size
3535 shiftl = (nb-1)*m_max_c
3537 DO nf = 1, (nb_field+nb_field2/2)
3543 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
3544 -combined_field(:,2*nf,jindex),kind=8)
3548 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
3554 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3557 fft_dim=1; istride=1; ostride=1;
3561 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
3562 odist=m_max_pad; onembed(1)=m_max_pad
3565 howmany=bloc_size*(nb_field+nb_field2/2)
3569 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
3570 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
3572 CALL dfftw_execute(fftw_plan_multi_c2r)
3574 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
3581 norm_vel(:,:) = sqrt(ru(:,4,:)**2 + ru(:,5,:)**2 + ru(:,6,:)**2)
3582 DO i = 1, 2*m_max_pad - 1
3583 DO l = 1, bloc_size/l_g
3584 x = maxval(norm_vel(i,(l-1)*l_g+1:l*l_g))
3585 norm_vel_int(i,l) = x
3588 IF (2*m_max_pad - 1 .GE. 3)
THEN
3589 DO l = 1, bloc_size/l_g
3590 DO i = 2, 2*m_max_pad - 2
3591 norm_vel(i,(l-1)*l_g+1:l*l_g) = maxval(norm_vel_int(i-1:i+1,l))
3593 norm_vel(1,(l-1)*l_g+1:l*l_g) = max(norm_vel_int(1,l),norm_vel_int(2,l),norm_vel_int(2*m_max_pad - 1,l))
3594 norm_vel(2*m_max_pad - 1,(l-1)*l_g+1:l*l_g) = &
3595 max(norm_vel_int(2*m_max_pad - 2,l),norm_vel_int(2*m_max_pad - 1,l),norm_vel_int(1,l))
3598 DO l = 1, bloc_size/l_g
3599 norm_vel(1,(l-1)*l_g+1:l*l_g) = norm_vel_int(1,l)
3605 max_norm_vel_loc=maxval(norm_vel)
3606 CALL mpi_allreduce(max_norm_vel_loc,max_norm_vel_loc_f,1,mpi_double_precision, mpi_max, communicator_f, code)
3607 CALL mpi_allreduce(max_norm_vel_loc_f,max_norm_vel_tot,1,mpi_double_precision, mpi_max, communicator_s, code)
3611 norm_grad_phi(:,:) = sqrt(ru(:,1,:)**2 + ru(:,2,:)**2 + ru(:,3,:)**2)
3615 hh = inputs%h_min_distance
3620 max_norm_vel_tot=min(1.d0,max_norm_vel_tot)
3623 prod_ru(:,n) = inputs%level_set_comp_factor*4*inputs%LES_coeff4* &
3624 max_norm_vel_tot*(2.d0*
regul_tab(ru(:,7,n),0.01d0)-1.d0)* &
3625 (max((1.d0 - (2*ru(:,7,n)-1.d0)**2),0.d0)/(2*hh)-norm_grad_phi(:,n))
3630 howmany = bloc_size*1
3631 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
3632 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
3634 CALL dfftw_execute(fftw_plan_multi_r2c)
3636 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
3640 prod_cu = prod_cu*(1.d0/n_r_pad)
3642 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
3646 combined_prod_cu(:,1)=prod_cu(1,:)
3648 combined_prod_cu(:,n)=2*conjg(prod_cu(n,:))
3651 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3654 longueur_tranche=bloc_size*m_max_c*2
3655 mpid=mpi_double_precision
3656 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
3657 mpid,communicator_f,code)
3658 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3663 shiftc = (nb-1)*bloc_size
3664 shiftl = (nb-1)*m_max_c
3665 intermediate = dist_prod_cu(:,shiftl+i)
3667 IF (n+shiftc > np ) cycle
3668 c_out(n+shiftc, 1, i) =
REAL (intermediate(n),kind=8)
3669 c_out(n+shiftc, 2 , i) = aimag(intermediate(n))
3673 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3678 coeff1_in_level, v_out, c_out, nb_procs, bloc_size, m_max_pad, temps)
3687 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in
3688 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: c1_in
3689 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: c_in_real
3690 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: hloc_gauss
3691 REAL(KIND=8),
INTENT(IN) :: coeff1_in_level
3692 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v_out
3693 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: c_out
3694 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
3695 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
3696 INTEGER :: np, np_tot, nb_field1, nb_field2
3697 INTEGER :: m_max, m_max_c, mpid, n_r_pad
3698 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
3700 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),SIZE(V1_in,2)+SIZE(c1_in,2),bloc_size*nb_procs) :: dist_field
3701 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),SIZE(V1_in,2)+SIZE(c1_in,2),bloc_size*nb_procs) :: combined_field
3702 COMPLEX(KIND=8),
DIMENSION(m_max_pad, (SIZE(V1_in,2)+SIZE(c1_in,2))/2, bloc_size) :: cu
3703 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,(SIZE(V1_in,2)+SIZE(c1_in,2))/2,bloc_size) :: ru
3704 REAL(KIND=8),
DIMENSION(bloc_size*nb_procs) :: hloc_gauss_tot
3705 REAL(KIND=8),
DIMENSION(2*m_max_pad-1, bloc_size) :: visc_entro
3706 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu
3707 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru
3708 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2, bloc_size) :: intermediate
3709 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu
3710 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu
3711 COMPLEX(KIND=8),
DIMENSION(m_max_pad,bloc_size) :: prod_cu2
3712 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,bloc_size) :: prod_ru2
3713 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu2
3714 COMPLEX(KIND=8),
DIMENSION(bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu2
3715 COMPLEX(KIND=8),
DIMENSION(bloc_size) :: intermediate2
3717 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
3722 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
3723 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
3726 #include "petsc/finclude/petsc.h"
3727 mpi_comm :: communicator
3729 CALL mpi_comm_rank(communicator, rank, code)
3731 IF (present(temps)) temps = 0.d0
3734 nb_field1=
SIZE(v1_in,2)
3735 nb_field2=
SIZE(c1_in,2)
3736 m_max_c =
SIZE(v1_in,3)
3737 m_max = m_max_c*nb_procs
3738 n_r_pad = 2*m_max_pad-1
3739 np_tot = nb_procs*bloc_size
3741 IF (mod(nb_field1,2)/=0 .OR. mod(nb_field2,2)/=0 .OR. m_max_c==0)
THEN
3759 dist_field(i,1:nb_field1,1:np) = transpose(v1_in(:,:,i))
3760 dist_field(i,nb_field1+1:nb_field1+nb_field2,1:np) = transpose(c1_in(:,:,i))
3762 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3764 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
3766 hloc_gauss_tot(1:np) = hloc_gauss
3767 IF (np/=np_tot) hloc_gauss_tot(np+1:np_tot) = 1.d100
3769 longueur_tranche=bloc_size*m_max_c*(nb_field1+nb_field2)
3772 mpid=mpi_double_precision
3773 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
3774 mpid, communicator, code)
3775 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3783 shiftc = (nb-1)*bloc_size
3784 shiftl = (nb-1)*m_max_c
3786 DO nf = 1, (nb_field1+nb_field2)/2
3792 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
3793 -combined_field(:,2*nf,jindex),kind=8)
3797 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
3803 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3806 fft_dim=1; istride=1; ostride=1;
3810 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
3811 odist=m_max_pad; onembed(1)=m_max_pad
3814 howmany=bloc_size*(nb_field1+nb_field2)/2
3817 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
3818 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
3820 CALL dfftw_execute(fftw_plan_multi_c2r)
3823 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
3825 IF (nb_field1 == 6 .AND. nb_field2 == 2)
THEN
3831 prod_ru2(:,:) = max(0.d0, ru(:,4,:)*(1.d0 - ru(:,4,:)))
3835 visc_entro(:,n) = -coeff1_in_level + c_in_real(:,n)
3839 prod_ru(:,1,:) = -visc_entro*ru(:,1,:)
3840 prod_ru(:,2,:) = -visc_entro*ru(:,2,:)
3841 prod_ru(:,3,:) = -visc_entro*ru(:,3,:)
3843 CALL
error_petsc(
'error in problem type while calling FFT_PAR_ENTRO_VISC_DCL')
3846 howmany = bloc_size*nb_field1/2
3847 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
3848 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
3849 CALL dfftw_execute(fftw_plan_multi_r2c)
3851 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
3853 howmany = bloc_size*1
3854 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru2, &
3855 inembed, istride, idist, prod_cu2, onembed, ostride, odist, fftw_estimate)
3856 CALL dfftw_execute(fftw_plan_multi_r2c)
3858 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
3862 prod_cu = prod_cu*(1.d0/n_r_pad)
3863 prod_cu2 = prod_cu2*(1.d0/n_r_pad)
3865 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
3870 combined_prod_cu(:,:,1)=prod_cu(1,:,:)
3871 combined_prod_cu2(:,1)=prod_cu2(1,:)
3873 combined_prod_cu(:,:,n)=2*conjg(prod_cu(n,:,:))
3874 combined_prod_cu2(:,n)=2*conjg(prod_cu2(n,:))
3877 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3880 longueur_tranche=bloc_size*m_max_c*nb_field1
3881 mpid=mpi_double_precision
3882 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
3883 mpid,communicator,code)
3885 longueur_tranche=bloc_size*m_max_c*2
3886 mpid=mpi_double_precision
3887 CALL mpi_alltoall(combined_prod_cu2,longueur_tranche,mpid, dist_prod_cu2,longueur_tranche, &
3888 mpid,communicator,code)
3890 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
3896 shiftc = (nb-1)*bloc_size
3897 shiftl = (nb-1)*m_max_c
3898 intermediate = dist_prod_cu(:,:,shiftl+i)
3899 intermediate2 = dist_prod_cu2(:,shiftl+i)
3901 IF (n+shiftc > np ) cycle
3902 DO i_field = 1, nb_field1/2
3903 v_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate(i_field,n),kind=8)
3904 v_out(n+shiftc, i_field*2 , i) = aimag(intermediate(i_field,n))
3906 c_out(n+shiftc, 1, i) =
REAL (intermediate2(n),kind=8)
3907 c_out(n+shiftc, 2, i) = aimag(intermediate2(n))
3912 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3917 bloc_size, m_max_pad, temps)
3925 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v1_in
3926 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v2_in
3927 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: v_out
3928 REAL(KIND=8),
DIMENSION(:),
OPTIONAL,
INTENT(INOUT) :: temps
3929 INTEGER,
INTENT(IN) :: bloc_size, m_max_pad, nb_procs
3930 INTEGER :: np, np_tot, nb_field1, nb_field2, m_max, m_max_c, mpid, n_r_pad
3931 INTEGER(KIND=8) :: fftw_plan_multi_c2r, fftw_plan_multi_r2c
3933 COMPLEX(KIND=8),
DIMENSION(m_max_pad, (SIZE(V1_in,2)+SIZE(V2_in,2))/2, bloc_size) :: cu
3934 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,(SIZE(V1_in,2)+SIZE(V2_in,2))/2,bloc_size) :: ru
3935 COMPLEX(KIND=8),
DIMENSION(m_max_pad,SIZE(V1_in,2)/2,bloc_size) :: prod_cu
3936 REAL(KIND=8),
DIMENSION(2*m_max_pad-1,SIZE(V1_in,2)/2,bloc_size) :: prod_ru
3937 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2, bloc_size) :: intermediate
3938 REAL(KIND=8),
DIMENSION(SIZE(V1_in,3),SIZE(V1_in,2)+SIZE(V2_in,2),bloc_size*nb_procs) :: dist_field, combined_field
3939 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: combined_prod_cu
3940 COMPLEX(KIND=8),
DIMENSION(SIZE(V1_in,2)/2,bloc_size,SIZE(V1_in,3)*nb_procs) :: dist_prod_cu
3943 INTEGER :: nb, nf, shiftc, shiftl, jindex, longueur_tranche, i, n, code
3947 INTEGER :: fft_dim, howmany, istride, ostride, idist, odist
3948 INTEGER,
DIMENSION(1) :: dim, inembed, onembed
3951 #include "petsc/finclude/petsc.h"
3952 mpi_comm :: communicator
3954 IF (present(temps)) temps = 0.d0
3957 nb_field1=
SIZE(v1_in,2)
3958 nb_field2=
SIZE(v2_in,2)
3959 m_max_c =
SIZE(v1_in,3)
3960 m_max = m_max_c*nb_procs
3961 n_r_pad=2*m_max_pad-1
3962 np_tot = nb_procs*bloc_size
3964 IF (mod(nb_field1,2)/=0 .OR. mod(nb_field2,2)/=0 .OR. m_max_c==0)
THEN
3982 dist_field(i,1:nb_field1,1:np) = transpose(v1_in(:,:,i))
3983 dist_field(i,nb_field1+1:nb_field1+nb_field2,1:np) = transpose(v2_in(:,:,i))
3985 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
3987 IF (np/=np_tot) dist_field(:,:,np+1:np_tot) = 1.d100
3989 longueur_tranche=bloc_size*m_max_c*(nb_field1+nb_field2)
3992 mpid=mpi_double_precision
3993 CALL mpi_alltoall(dist_field,longueur_tranche, mpid, combined_field, longueur_tranche, &
3994 mpid, communicator, code)
3995 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
4001 shiftc = (nb-1)*bloc_size
4002 shiftl = (nb-1)*m_max_c
4004 DO nf = 1, (nb_field1+nb_field2)/2
4010 cu(shiftl+1:shiftl+m_max_c,nf,n) = 0.5d0*cmplx(combined_field(:,2*nf-1,jindex),&
4011 -combined_field(:,2*nf,jindex),kind=8)
4015 cu(1,:,:) = 2*cmplx(
REAL(cu(1,:,:),KIND=8),0.d0,kind=8)
4019 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
4022 fft_dim=1; istride=1; ostride=1;
4023 idist=n_r_pad; inembed(1)=n_r_pad; dim(1)=n_r_pad
4024 odist=m_max_pad; onembed(1)=m_max_pad
4026 howmany=bloc_size*(nb_field1+nb_field2)/2
4029 CALL dfftw_plan_many_dft_c2r(fftw_plan_multi_c2r, fft_dim, dim, howmany, cu, &
4030 onembed, ostride, odist, ru, inembed, istride, idist, fftw_estimate)
4031 CALL dfftw_execute(fftw_plan_multi_c2r)
4034 CALL dfftw_destroy_plan(fftw_plan_multi_c2r)
4039 IF (nb_field1 == 6 .AND. nb_field2 == 2)
THEN
4040 DO i = 1, 2*m_max_pad-1
4048 CALL
error_petsc(
'error in dimension of INPUT variables while calling FFT_SCALAR_VECT_DCL ')
4051 howmany = bloc_size*nb_field1/2
4053 CALL dfftw_plan_many_dft_r2c(fftw_plan_multi_r2c, fft_dim, dim, howmany, prod_ru, &
4054 inembed, istride, idist, prod_cu, onembed, ostride, odist, fftw_estimate)
4055 CALL dfftw_execute(fftw_plan_multi_r2c)
4056 CALL dfftw_destroy_plan(fftw_plan_multi_r2c)
4060 prod_cu = prod_cu*(1.d0/n_r_pad)
4061 IF (present(temps)) temps(2) = temps(2) + mpi_wtime() -
t
4066 combined_prod_cu(:,:,1)=prod_cu(1,:,:)
4068 combined_prod_cu(:,:,n)=2*conjg(prod_cu(n,:,:))
4071 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
4073 longueur_tranche=bloc_size*m_max_c*nb_field1
4076 mpid=mpi_double_precision
4077 CALL mpi_alltoall(combined_prod_cu,longueur_tranche,mpid, dist_prod_cu,longueur_tranche, &
4078 mpid,communicator,code)
4080 IF (present(temps)) temps(1) = temps(1) + mpi_wtime() -
t
4086 shiftc = (nb-1)*bloc_size
4087 shiftl = (nb-1)*m_max_c
4088 intermediate = dist_prod_cu(:,:,shiftl+i)
4090 IF (n+shiftc > np ) cycle
4091 DO i_field = 1, nb_field1/2
4092 v_out(n+shiftc, i_field*2-1, i) =
REAL (intermediate(i_field,n),kind=8)
4093 v_out(n+shiftc, i_field*2 , i) = aimag(intermediate(i_field,n))
4098 IF (present(temps)) temps(3) = temps(3) + mpi_wtime() -
t
section doc_intro_frame_work_num_app Numerical approximation subsection doc_intro_fram_work_num_app_Fourier_FEM Fourier Finite element representation The SFEMaNS code uses a hybrid Fourier Finite element formulation The Fourier decomposition allows to approximate the problem’s solutions for each Fourier mode modulo nonlinear terms that are made explicit The variables are then approximated on a meridian section of the domain with a finite element method The numerical approximation of a function f $f f is written in the following generic t
subroutine, public fft_par_dot_prod_dcl(communicator, V1_in, V2_in, c_out, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_kelvin_force(communicator, V1_in, V2_in, V_out, nb_procs, bloc_size, m_max_pad, temps)
real(kind=8) function, dimension(size(phi)) regul_tab(phi, eps)
subroutine, public fft_par_real(communicator, V1_in, V_out, opt_nb_plane)
subroutine, public fft_par_prod_dcl(communicator, c1_in, c2_in, c_out, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_compute_entropy_visc_mom(communicator, communicator_S, V1_in, V2_in, V3_in, c1_in, hloc_gauss, c1_real_out, nb_procs, bloc_size, m_max_pad, l_G, opt_c2_real_out, temps)
real(kind=8) function, public kelvin_force_coeff(temp)
subroutine, public fft_par_entro_visc_dcl(communicator, V1_in, c1_in, c_in_real, hloc_gauss, coeff1_in_level, V_out, c_out, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_max_vel_dcl(communicator, V1_in, V_out, nb_procs, bloc_size, m_max_pad)
subroutine, public fft_compute_entropy_visc_grad_mom(communicator, V1_in, V2_in, V3_in, c_in_real, V_out, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_compute_entropy_visc(communicator, communicator_S, V1_in, V2_in, V3_in, V4_in, V5_in, hloc_gauss, V1_out, V2_out, V3_out, nb_procs, bloc_size, m_max_pad, residual_normalization, l_G, temps)
subroutine, public fft_no_overshoot_level_set(communicator, c1_inout, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_par_compr_entro_visc_dcl(communicator, V1_in, V2_in, c1_in, c_in_real, hloc_gauss, coeff1_in_level, V_out, c_out, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_par_var_eta_prod_t_dcl(communicator, eta, H_mesh, c_in, c_out, nb_procs, bloc_size, m_max_pad, time, temps)
subroutine, public fft_compression_level_set_dcl(communicator_F, communicator_S, V1_in, V2_in, c_in, c_out, hloc_gauss, l_G, nb_procs, bloc_size, m_max_pad, temps)
real(kind=8) function, public regul(phi, eps)
subroutine, public fft_scalar_vect_dcl(communicator, V1_in, V2_in, V_out, pb, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_heaviside_dcl(communicator, V1_in, values, V_out, nb_procs, bloc_size, m_max_pad, coeff_tanh, temps)
subroutine, public fft_par_var_eta_prod_gauss_dcl(communicator, eta, H_mesh, c_in, c_out, nb_procs, bloc_size, m_max_pad, rr_gauss, time, temps)
subroutine, public fft_compute_diffu_mom(communicator, V1_in, V2_in, V3_in, V1_out, V2_out, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public fft_tensor_dcl(communicator, V1_in, V2_in, V_out, nb_procs, bloc_size, m_max_pad, temps, opt_tension)
subroutine, public fft_check_interface(communicator, V1_in, nb_fluids, interface_ok, nb_procs, bloc_size, m_max_pad, temps)
subroutine error_petsc(string)
subroutine, public fft_par_cross_prod_dcl(communicator, V1_in, V2_in, V_out, nb_procs, bloc_size, m_max_pad, temps)