11 #include "petsc/finclude/petsc.h" 15 TYPE(
mesh_type),
POINTER :: pp_mesh, vv_mesh
16 REAL(KIND=8),
POINTER,
DIMENSION(:,:,:) :: un, pn
19 TYPE(
mesh_type),
POINTER :: H_mesh, phi_mesh
21 REAL(KIND=8),
POINTER,
DIMENSION(:,:,:) :: Hn, Bn, phin, vel
22 REAL(KIND=8),
POINTER,
DIMENSION(:) :: sigma_field, mu_H_field
25 REAL(KIND=8),
POINTER,
DIMENSION(:,:,:) :: temperature
26 REAL(KIND=8),
POINTER,
DIMENSION(:) :: vol_heat_capacity_field
27 REAL(KIND=8),
POINTER,
DIMENSION(:) :: temperature_diffusivity_field
29 REAL(KIND=8),
POINTER,
DIMENSION(:,:,:,:) :: level_set
31 REAL(KIND=8),
POINTER,
DIMENSION(:,:,:) :: density
34 INTEGER,
POINTER,
DIMENSION(:) :: list_mode
39 REAL(KIND=8) :: tps, tploc, tploc_max=0.d0
41 petscerrorcode :: ierr
43 mpi_comm,
DIMENSION(:),
POINTER :: comm_one_d, comm_one_d_ns, comm_one_d_temp
46 CALL petscinitialize(petsc_null_character,ierr)
47 CALL mpi_comm_rank(petsc_comm_world,rank,ierr)
53 CALL initial(vv_mesh, pp_mesh, h_mesh, phi_mesh, temp_mesh, &
54 interface_h_phi, interface_h_mu, list_mode, &
55 un, pn, hn, bn, phin, vel, &
56 vol_heat_capacity_field, temperature_diffusivity_field, mu_h_field, sigma_field, &
57 time, m_max_c, comm_one_d, comm_one_d_ns, comm_one_d_temp, temperature, &
58 level_set, density, der_un)
63 IF (
inputs%if_just_processing)
THEN 98 DO it = 1,
inputs%nb_iteration
105 IF (.NOT.
inputs%test_de_convergence)
THEN 110 IF (mod(it,
inputs%freq_restart) == 0)
THEN 116 IF (it>1) tploc_max = tploc_max + tploc
124 IF (
inputs%test_de_convergence)
THEN 125 CALL post_proc_test(vv_mesh, pp_mesh, temp_mesh, h_mesh, phi_mesh, list_mode, &
126 un, pn, hn, bn, phin, temperature, level_set, mu_h_field, &
127 time, m_max_c, comm_one_d, comm_one_d_ns, comm_one_d_temp)
144 INTEGER,
INTENT(IN) :: it
145 REAL(KIND=8) :: err, norm
146 INTEGER :: i, it_plot
147 CHARACTER(LEN=3) :: what
148 INTEGER :: rank_S, rank_F
149 INTEGER :: rank_ns_S, rank_ns_F
150 REAL(KIND=8),
DIMENSION(vv_mesh%np, 2, SIZE(list_mode)) :: level_1_P2
151 REAL(KIND=8),
DIMENSION(pp_mesh%np, 2, SIZE(list_mode)) :: level_1_P1
152 REAL(KIND=8),
DIMENSION(vv_mesh%np,2,SIZE(list_mode)) :: chi, one_chi
153 INTEGER :: nb_procs, m_max_pad, bloc_size
155 CHARACTER(LEN=3) :: st_mode
156 CHARACTER(LEN=200) :: header
157 CHARACTER(LEN=3) :: name_of_field
160 IF (vv_mesh%me /=0)
THEN 161 CALL mpi_comm_rank(comm_one_d_ns(1), rank_ns_s, ierr)
162 CALL mpi_comm_rank(comm_one_d_ns(2), rank_ns_f, ierr)
167 CALL mpi_comm_rank(comm_one_d(1), rank_s, ierr)
168 CALL mpi_comm_rank(comm_one_d(2), rank_f, ierr)
171 IF (
inputs%check_numerical_stability)
THEN 173 norm =
norm_sf(comm_one_d_ns,
'L2', vv_mesh, list_mode, un)
175 norm =
norm_sf(comm_one_d,
'L2', h_mesh, list_mode, hn)
178 CALL error_petsc(
'From my_post_processing: numerical unstability')
183 IF (mod(it,
inputs%freq_en) == 0)
THEN 189 IF (
inputs%if_compute_momentum_pseudo_force)
THEN 196 err =
norm_sf(comm_one_d,
'div', vv_mesh, list_mode, un)
197 norm =
norm_sf(comm_one_d,
'H1', vv_mesh, list_mode, un)
200 WRITE(31,*) time, err/norm
202 DO i=1,
SIZE(list_mode)
203 norm =
norm_s(comm_one_d,
'L2', vv_mesh, list_mode(i:i), un(:,:,i:i))
204 IF (rank_ns_s == 0)
THEN 206 WRITE(100+list_mode(i),*) time, norm
210 err =
norm_sf(comm_one_d,
'L2', vv_mesh, list_mode, un)
211 norm =
norm_sf(comm_one_d,
'sH1', vv_mesh, list_mode, un)
213 WRITE(98,*) time, err
214 WRITE(*,*)
'norm L2 of velocity', time, err
215 WRITE(*,*)
'semi norm H1 of velocity', time, norm
218 err =
norm_sf(comm_one_d,
'L2', pp_mesh, list_mode, pn)
220 WRITE(*,*)
'norm L2 of pressure', time, err
223 IF (
inputs%if_level_set)
THEN 226 IF (
inputs%if_level_set_P2)
THEN 233 IF (
inputs%if_temperature)
THEN 234 norm =
norm_sf(comm_one_d_temp,
'L2', temp_mesh, list_mode, temperature)
236 WRITE(99,*)
'norm L2 of temperature', time, norm
237 WRITE(*,*)
'norm L2 of temperature', time, norm
242 IF (
inputs%type_pb/=
'nst')
THEN 243 err =
norm_sf(comm_one_d,
'L2', h_mesh, list_mode, hn)
246 WRITE(41,*) time, err
248 err =
norm_sf(comm_one_d,
'div', h_mesh, list_mode, bn)
249 norm =
norm_sf(comm_one_d,
'L2', h_mesh, list_mode, bn)
252 WRITE(51,*) time, err, err/norm
253 WRITE(52,*) time, err, norm
254 WRITE(*,*)
'norm L2 of magnetic field', time, norm
256 DO i=1,
SIZE(list_mode)
257 norm =
norm_s(comm_one_d,
'L2', h_mesh, list_mode(i:i), hn(:,:,i:i))
258 IF (rank_s == 0)
THEN 260 WRITE(200+list_mode(i),*) time, norm
266 IF (mod(it,
inputs%freq_plot) == 0)
THEN 268 IF (it==
inputs%freq_plot)
THEN 273 it_plot = it/
inputs%freq_plot
275 IF (
inputs%if_level_set)
THEN 276 IF (
inputs%if_level_set_P2)
THEN 277 level_1_p2=level_set(1,:,:,:)
278 CALL vtu_3d(level_1_p2,
'vv_mesh',
'Level_1',
'level_1', what, opt_it=it_plot)
280 level_1_p1=level_set(1,:,:,:)
281 CALL vtu_3d(level_1_p1,
'pp_mesh',
'Level_1',
'level_1', what, opt_it=it_plot)
285 IF (
inputs%type_pb/=
'mxw' .AND.
inputs%type_pb/=
'mxx')
THEN 286 IF (
inputs%type_fe_velocity==3)
THEN 287 CALL vtu_3d(un,
'vv_mesh',
'Velocity',
'vel', what, opt_it=it_plot, opt_mesh_in=vv_mesh)
289 CALL vtu_3d(un,
'vv_mesh',
'Velocity',
'vel', what, opt_it=it_plot)
291 CALL vtu_3d(pn,
'pp_mesh',
'Pressure',
'pre', what, opt_it=it_plot)
292 CALL vtu_3d(un,
'vv_mesh',
'Vorticity',
'vor', what, opt_it=it_plot, &
293 opt_grad_curl=
'curl_u', opt_mesh_in=vv_mesh)
295 IF (
inputs%if_ns_penalty)
THEN 296 CALL mpi_comm_size(comm_one_d(2), nb_procs, ierr)
297 m_max_pad = 3*
SIZE(list_mode)*nb_procs/2
298 bloc_size =
SIZE(vv_mesh%rr,2)/nb_procs+1
299 DO i=1,
SIZE(list_mode)
300 IF (list_mode(i)==0)
THEN 308 one_chi, chi, nb_procs, bloc_size, m_max_pad, vv_mesh%rr, time)
309 CALL vtu_3d(chi,
'vv_mesh',
'Chi',
'chi', what, opt_it=it_plot)
314 WRITE(st_mode,
'(I3)') list_mode(i)
315 header =
'Vn_'//
'mode_'//trim(adjustl(st_mode))
317 CALL make_vtu_file_2d(comm_one_d_ns(1), vv_mesh, header, un(:,:,i), name_of_field, what, opt_it=it_plot)
318 WRITE(st_mode,
'(I3)') list_mode(i)
319 header =
'Pn_'//
'mode_'//trim(adjustl(st_mode))
321 CALL make_vtu_file_2d(comm_one_d_ns(1), pp_mesh, header, pn(:,:,i), name_of_field, what, opt_it=it_plot)
324 IF (
inputs%if_temperature)
THEN 327 IF (
inputs%type_pb/=
'nst')
THEN 410 #include "petsc/finclude/petsc.h" 414 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
415 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: un
416 REAL(KIND=8),
INTENT(IN) :: time
417 REAL(KIND=8),
DIMENSION(vv_mesh%gauss%l_G*vv_mesh%dom_me,6,SIZE(list_mode)) :: vel_gauss, vel_gauss_penal
418 REAL(KIND=8),
DIMENSION(2,vv_mesh%gauss%l_G*vv_mesh%dom_me) :: rr_gauss
419 INTEGER,
DIMENSION(vv_mesh%gauss%n_w) :: j_loc
420 REAL(KIND=8) :: vel_torque, vel_torque_tot
421 INTEGER :: m, l , i, mode, index,
type, nb_procs, m_max_pad, bloc_size
422 petscerrorcode :: ierr
423 mpi_comm,
DIMENSION(2) :: communicator
426 DO m = 1, vv_mesh%dom_me
427 j_loc = vv_mesh%jj(:,m)
428 DO l = 1, vv_mesh%gauss%l_G
430 rr_gauss(1,index) = sum(vv_mesh%rr(1,j_loc)*vv_mesh%gauss%ww(:,l))
431 rr_gauss(2,index) = sum(vv_mesh%rr(2,j_loc)*vv_mesh%gauss%ww(:,l))
435 DO i = 1,
SIZE(list_mode)
438 DO m = 1, vv_mesh%dom_me
439 j_loc = vv_mesh%jj(:,m)
440 DO l = 1, vv_mesh%gauss%l_G
443 vel_gauss(index,
type,i) = sum(un(j_loc,
type,i)*vv_mesh%
gauss%
ww(:,l))*(3/(2*
inputs%dt))
447 IF(
inputs%if_impose_vel_in_solids)
THEN 449 vel_gauss(:,:,i) = vel_gauss(:,:,i) - imposed_velocity_by_penalty(rr_gauss(:,:),time)
454 CALL mpi_comm_size(communicator(2), nb_procs, ierr)
455 m_max_pad = 3*
SIZE(list_mode)*nb_procs/2
456 bloc_size =
SIZE(vel_gauss,1)/nb_procs+1
458 vel_gauss, vel_gauss_penal, nb_procs, bloc_size, m_max_pad, rr_gauss, time)
461 DO i = 1,
SIZE(list_mode)
467 DO m = 1, vv_mesh%dom_me
468 j_loc = vv_mesh%jj(:,m)
469 DO l = 1, vv_mesh%gauss%l_G
472 vel_torque = vel_torque + (vel_gauss_penal(index,5,i) - vel_gauss(index,5,i)) &
473 *rr_gauss(1,index)*vv_mesh%gauss%rj(l,m)
476 CALL mpi_allreduce(vel_torque, vel_torque_tot,1,mpi_double_precision, mpi_sum, communicator(1), ierr)
477 WRITE(*,*)
' FORCES_AND_MOMENTS ', time, 2*acos(-1.d0)*vel_torque_tot/(0.5d0*acos(-1.d0))
478 WRITE(12,*) time, 2*acos(-1.d0)*vel_torque_tot/(0.5d0*acos(-1.d0))
488 #include "petsc/finclude/petsc.h" 492 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
493 REAL(KIND=8),
DIMENSION(:,:,:,:),
INTENT(IN) :: level_set
494 REAL(KIND=8),
INTENT(IN) :: time
495 LOGICAL,
SAVE :: once_compute=.true.
496 REAL(KIND=8),
ALLOCATABLE,
DIMENSION(:),
SAVE :: volum_init
497 REAL(KIND=8) :: volum_init_loc, volum_init_F
498 REAL(KIND=8) :: inte_fft_loc, inte_fft_tot_F
499 REAL(KIND=8),
DIMENSION(inputs%nb_fluid-1) :: inte_fft_tot
500 REAL(KIND=8),
DIMENSION(mesh%np, 2, SIZE(list_mode)) :: level_posi_fft
502 INTEGER,
DIMENSION(mesh%gauss%n_w) :: j_loc
503 INTEGER :: m, l , i, nb_inter
504 INTEGER :: my_petscworld_rank, code
505 mpi_comm,
DIMENSION(2) :: communicator
507 CALL mpi_comm_rank(petsc_comm_world,my_petscworld_rank,code)
509 103
FORMAT(1500(e22.9,2x))
512 IF (once_compute)
THEN 513 once_compute = .false.
515 ALLOCATE(volum_init(
SIZE(level_set,1)))
517 DO nb_inter=1,
SIZE(level_set,1)
518 volum_init_loc = 0.d0
519 DO i = 1,
SIZE(list_mode)
520 IF (list_mode(i)==0)
THEN 523 DO l = 1, mesh%gauss%l_G
525 ray = sum(mesh%rr(1,j_loc)*mesh%gauss%ww(:,l))
526 volum_init_loc = volum_init_loc + sum(level_set_exact(nb_inter,1,mesh%rr(:,j_loc),list_mode(i),0.d0)* &
527 mesh%gauss%ww(:,l))*ray*mesh%gauss%rj(l,m)
532 volum_init_loc = volum_init_loc*2*acos(-1.d0)
533 CALL mpi_allreduce(volum_init_loc, volum_init_f, 1, mpi_double_precision, mpi_sum, &
534 communicator(2), code)
535 CALL mpi_allreduce(volum_init_f, volum_init(nb_inter), 1, mpi_double_precision, mpi_sum, &
536 communicator(1), code)
538 IF (my_petscworld_rank==0)
THEN 539 WRITE(*,*)
'mass initial = ', time, volum_init
544 DO nb_inter=1,
SIZE(level_set,1)
545 level_posi_fft = level_set(nb_inter,:,:,:)
547 DO i = 1,
SIZE(list_mode)
548 IF (list_mode(i)==0)
THEN 551 DO l = 1, mesh%gauss%l_G
553 ray = sum(mesh%rr(1,j_loc)*mesh%gauss%ww(:,l))
554 inte_fft_loc = inte_fft_loc + sum(level_posi_fft(j_loc,1,i)*mesh%gauss%ww(:,l))* &
555 ray*mesh%gauss%rj(l,m)
560 inte_fft_loc = inte_fft_loc*2*acos(-1.d0)
561 CALL mpi_allreduce(inte_fft_loc, inte_fft_tot_f, 1, mpi_double_precision, mpi_sum, &
562 communicator(2), code)
563 CALL mpi_allreduce(inte_fft_tot_f, inte_fft_tot(nb_inter), 1, mpi_double_precision, mpi_sum, &
564 communicator(1), code)
566 IF (my_petscworld_rank==0)
THEN 567 WRITE(*,*)
'relative mass error of level set at t = ', &
568 time, abs(1-inte_fft_tot/(volum_init+1.d-14))
569 WRITE(97,103) time, abs(1-inte_fft_tot/(volum_init+1.d-14))
subroutine, public make_vtu_file_2d(communicator, mesh_in, header, field_in, field_name, what, opt_it)
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 error_petsc(string)
real(kind=8) function user_time()
subroutine, public vtu_3d(field, name_of_mesh, header, name_of_field, what, opt_it, opt_grad_curl, opt_2D, opt_mesh_in)
subroutine, public save_run(it, freq_restart)
subroutine compute_level_set_conservation(time, mesh, communicator, list_mode, level_set)
subroutine, public post_proc_test(vv_mesh, pp_mesh, temp_mesh, H_mesh, phi_mesh, list_mode, un, pn, Hn, Bn, phin, tempn, level_setn, mu_H_field, time, m_max_c, comm_one_d, comm_one_d_ns, comm_one_d_temp)
real(kind=8) function norm_s(communicator, norm_type, mesh, list_mode, v)
subroutine, public write_verbose(rank, opt_tps, opt_tploc_max)
subroutine, public initial(vv_mesh_out, pp_mesh_out, H_mesh_out, phi_mesh_out, temp_mesh_out, interface_H_phi_out, interface_H_mu_out, list_mode_out, un_out, pn_out, Hn_out, Bn_out, phin_out, v_to_Max_out, vol_heat_capacity_field_out, temperature_diffusivity_field_out, mu_H_field_out, sigma_field_out, time_out, m_max_c_out, comm_one_d_out, comm_one_d_ns_out, comm_one_d_temp_out, tempn_out, level_set_out, density_out, der_un_out)
real(kind=8) function norm_sf(communicator, norm_type, mesh, list_mode, v)
subroutine my_post_processing(it)
subroutine, public run_sfemans(time_in, it)
real(kind=8), dimension(:,:), pointer ww
subroutine forces_and_moments(time, vv_mesh, communicator, list_mode, un)
subroutine, public read_user_data(data_file)