SFEMaNS  version 4.1 (work in progress)
Reference documentation for SFEMaNS
 All Classes Files Functions Variables Groups Pages
mesh_interpolation.f90
Go to the documentation of this file.
2 
3  PUBLIC :: mesh_interpol
4  PRIVATE
5 CONTAINS
6  SUBROUTINE mesh_interpol
7 
9  USE def_type_mesh
10  USE my_util
11  USE create_comm
13  USE metis_sfemans
14  USE prep_maill
15  USE sub_plot
16  USE restart
17 
18  IMPLICIT NONE
19 
20  TYPE(mesh_type) :: p1_mesh_glob, p2_mesh_glob, p2_c0_mesh_glob_temp
21 
22  TYPE(mesh_type), TARGET :: h_mesh, phi_mesh
23  TYPE(mesh_type), TARGET :: h_mesh_glob, phi_mesh_glob
24  TYPE(mesh_type), POINTER :: h_mesh_in, h_mesh_out, phi_mesh_in, phi_mesh_out
25 
26  TYPE(mesh_type), TARGET :: vv_mesh, pp_mesh
27  TYPE(mesh_type), TARGET :: vv_mesh_glob, pp_mesh_glob
28  TYPE(mesh_type), POINTER :: vv_mesh_in, vv_mesh_out, pp_mesh_in, pp_mesh_out
29 
30  TYPE(mesh_type), TARGET :: temp_mesh
31  TYPE(mesh_type), TARGET :: temp_mesh_glob
32  TYPE(mesh_type), POINTER :: temp_mesh_in, temp_mesh_out
33 
34  CHARACTER(len=200) :: old_filename, old_directory
35  CHARACTER(len=200) :: new_filename, new_directory
36  CHARACTER(len=200) :: file_name, directory
37  CHARACTER(len=200) :: file_name_m, directory_m
38  LOGICAL :: if_momentum, if_mass, if_induction, if_energy, &
39  old_is_form, new_is_form, iformatted, is_form_m, mono_in, mono_out, is_in, &
40  dom_h_larger_dom_ns, dom_temp_larger_dom_ns, &
41  if_temperature_in, if_temperature_out, if_temperature, if_level_set, inter_mesh, &
42  rw_ns, rw_temp, rw_mxw, check_plt, test, if_select
43 
44  INTEGER :: nb_s, nb_f, nb_procs, rank, type_fe_h, type_fe_phi, &
45  nb_dom_ns, nb_dom_temp, nb_dom_h, nb_dom_phi, nsize, code, m, &
46  m_max_c, rank_s, nb_inter, nb_inter_mu, nb_inter_v_t, &
47  k, kp, i, nb_mode, rang_ns_s, rang_temp_s, rang_s, l, lblank, nb_fluid
48  INTEGER :: nb_fic, index_start
49  REAL(KIND=8) :: time_h, time_u, time_t, max_vel
50  TYPE(periodic_data) :: my_periodic
51 
52  INTEGER, DIMENSION(:), ALLOCATABLE :: list_inter, list_inter_temp, list_inter_v_t, &
53  list_inter_mu, list_inter_h_phi, list_dom_h, &
54  list_dom_ns, list_dom_temp, list_dom_temp_in, list_dom_phi, list_dom_h_in, list_dom, part, &
55  list_mode, controle_h, controle_phi, &
56  controle_vv, controle_pp, controle_temp, temp_in_to_new, h_in_to_new, &
57  l_t_g_vv, l_t_g_pp, l_t_g_h, l_t_g_phi, l_t_g_temp
58 
59  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: hn, hn1, bn, bn1, phin, phin1
60  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: hn_glob, hn1_glob, bn_glob, bn1_glob, phin_glob, phin1_glob
61  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: un, un_m1, pn, pn_m1
62  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: incpn, incpn_m1, tempn, tempn_m1
63  REAL(KIND=8), DIMENSION(:,:,:,:), POINTER :: level_setn, level_setn_m1
64  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: un_glob, un_m1_glob, pn_glob, pn_m1_glob
65  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: incpn_glob, incpn_m1_glob, tempn_glob, tempn_m1_glob
66  REAL(KIND=8), DIMENSION(:,:,:,:), POINTER :: level_setn_glob, level_setn_m1_glob
67 
68  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: hn_in, hn1_in, bn_in, bn1_in, phin_in, phin1_in
69  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: hn_out, hn1_out, bn_out, bn1_out, phin_out, phin1_out
70  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: un_in, un_m1_in, pn_in, pn_m1_in
71  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: incpn_in, incpn_m1_in, tempn_in, tempn_m1_in
72  REAL(KIND=8), DIMENSION(:,:,:,:), POINTER :: level_setn_in, level_setn_m1_in
73  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: un_out, un_m1_out, pn_out, pn_m1_out
74  REAL(KIND=8), DIMENSION(:,:,:), POINTER :: incpn_out, incpn_m1_out, tempn_out, tempn_m1_out
75  REAL(KIND=8), DIMENSION(:,:,:,:), POINTER :: level_setn_out, level_setn_m1_out
76 
77  CHARACTER(len=3) :: type_pb, tit_m, tit_s, tit
78  CHARACTER(len=4) :: tit_part
79  CHARACTER(len=200) :: mesh_part_name
80  INTEGER :: petsc_rank
81  LOGICAL :: if_read_partition
82 
83 #include "petsc/finclude/petsc.h"
84  mpi_comm :: comm_cart
85  mpi_comm, DIMENSION(:), POINTER :: comm_one_d, comm_one_d_ns, comm_one_d_temp, coord_cart
86  petscerrorcode :: ierr
87 
88  CALL petscinitialize(petsc_null_character,ierr)
89  CALL mpi_comm_rank(petsc_comm_world, petsc_rank, code)
90 
91  OPEN(unit=22, file='data_interpol', status='unknown', access='sequential')
92 
93  !===Compute is_in (is_in=.TRUE. if Petsc -> NonPetsc; is_in=.FALSE. if NonPetsc -> Petsc)
94  CALL which_pb(is_in)
95 
96  IF (is_in) THEN
97  CALL read_until(22, '===Number of processors in meridian section (Input)')
98  READ(22,*) nb_s
99  CALL read_until(22, '===Problem type (Input): (nst, mxw, mhd, fhd)')
100  READ(22,*) type_pb
101  CALL find_string(22, '===Is there an input temperature field?', test)
102  IF (test) THEN
103  READ (22, *) if_temperature_in
104  ELSE
105  if_temperature_in = .false.
106  END IF
107  if_temperature = if_temperature_in
108  inter_mesh = .false.
109  if_read_partition = .true.
110  ELSE
111  CALL read_until(22, '===Number of processors in meridian section (Output)')
112  READ(22,*) nb_s
113  CALL read_until(22, '===Problem type (Output): (nst, mxw, mhd, fhd)')
114  READ(22,*) type_pb
115  CALL find_string(22, '===Is there an output temperature field?', test)
116  IF (test) THEN
117  READ (22, *) if_temperature_out
118  ELSE
119  if_temperature_out = .false.
120  END IF
121  if_temperature = if_temperature_out
122  CALL read_until(22, '===Should data be interpolated on new mesh? (True/False)')
123  READ(22,*) inter_mesh
124  if_read_partition = .false.
125  END IF
126 
127  !===Set rw_ns, rw_mxw and rw_temp (function of Problem type (Input))
128  CALL read_until(22, '===Problem type (Input): (nst, mxw, mhd, fhd)')
129  READ(22,*) tit
130  IF (tit=='nst') THEN
131  rw_ns = .true.
132  rw_mxw = .false.
133  ELSE IF ((tit=='mhd').OR.(tit=='fhd')) THEN
134  rw_ns = .true.
135  rw_mxw = .true.
136  ELSE IF (tit=='mxw') THEN
137  rw_ns = .false.
138  rw_mxw = .true.
139  ELSE
140  CALL error_petsc('BUG in interpol, type_pb (Input) not correct')
141  END IF
142  CALL find_string(22, '===Is there an input temperature field?', test)
143  IF (test) THEN
144  READ (22, *) rw_temp
145  ELSE
146  rw_temp = .false.
147  END IF
148 
149  !===Default parameters
150  nb_f = 1
151 
152  !===Check construction with plotmtv
153  CALL find_string(22, '===Check construction with plotmtv? (True/False)', test)
154  IF (test) THEN
155  READ (22, *) check_plt
156  ELSE
157  check_plt = .false.
158  END IF
159 
160  !===Number of time steps to process
161  CALL read_until(22, '===How many files (times steps) should be converted?')
162  READ(22, *) nb_fic
163 
164  !===Starting index
165  CALL find_string(22, '===What is the starting index? (suite*_I*index.mesh*), index is an integer in [1,999]', test)
166  IF (test) THEN
167  READ (22, *) index_start
168  ELSE
169  index_start = 1
170  END IF
171 
172  !===Number of Fourier modes
173  CALL read_until(22, '===Number of Fourier modes')
174  READ(22, *) nb_mode
175  ALLOCATE(list_mode(nb_mode))
176  CALL find_string(22, '===Select Fourier modes? (true/false)',test)
177  IF (test) THEN
178  READ(22,*) if_select
179  IF (if_select) THEN
180  CALL read_until(22, '===List of Fourier modes (if select_mode=.TRUE.)')
181  READ(22,*) list_mode
182  ELSE
183  list_mode = (/ (m, m=0, nb_mode-1) /)
184  END IF
185  ELSE
186  list_mode = (/ (m, m=0, nb_mode-1) /)
187  END IF
188 
189  !===Input and Output mesh files
190  CALL read_until(22, '===Directory and name of input mesh file')
191  READ(22,*) old_directory, old_filename
192  CALL read_until(22, '===Is input mesh file formatted (true/false)?')
193  READ(22,*) old_is_form
194  IF (is_in) THEN !Interpolation is done at second step only
195  new_directory = old_directory
196  new_filename = old_filename
197  new_is_form = old_is_form
198  ELSE
199  CALL read_until(22, '===Directory and name of output mesh file')
200  READ(22,*) new_directory, new_filename
201  CALL read_until(22, '===Is output mesh file formatted (true/false)?')
202  READ(22,*) new_is_form
203  END IF
204 
205  !===Data for NS
206  IF ( (type_pb == 'nst') .OR. (type_pb == 'mhd') .OR. (type_pb == 'fhd')) THEN
207  CALL read_until(22, '===Number of subdomains in Navier-Stokes mesh')
208  READ(22,*) nb_dom_ns
209  ALLOCATE(list_dom_ns(nb_dom_ns))
210  CALL read_until(22, '===List of subdomains for Navier-Stokes mesh')
211  READ (22, *) list_dom_ns
212  CALL find_string(22, '===Is there a level set?', test)
213  IF (test) THEN
214  READ (22, *) if_level_set
215  IF (if_level_set) THEN
216  CALL read_until(22, '===How many fluids?')
217  READ(22,*) nb_fluid
218  END IF
219  ELSE
220  if_level_set = .false.
221  END IF
222  IF (type_pb == 'nst') ALLOCATE(list_dom_h(0), list_dom_phi(0))
223  END IF
224 
225  !===Data for temperature
226  IF (if_temperature) THEN
227  CALL read_until(22, '===Number of subdomains in temperature mesh')
228  READ(22,*) nb_dom_temp
229  ALLOCATE(list_dom_temp_in(nb_dom_temp), list_dom_temp(nb_dom_temp), temp_in_to_new(nb_dom_temp))
230  CALL read_until(22, '===List of subdomains for temperature mesh')
231  READ (22, *) list_dom_temp_in
232  CALL find_string(21, '===Number of interfaces between velocity and temperature only domains (for nst applications)', test)
233  IF (test) THEN
234  READ(21,*) nb_inter_v_t
235  ALLOCATE(list_inter_v_t(nb_inter_v_t))
236  CALL read_until(21, '===List of interfaces between velocity and temperature only domains (for nst applications)')
237  READ(21,*) list_inter_v_t
238  ELSE
239  ALLOCATE(list_inter_v_t(0))
240  END IF
241  ELSE
242  ALLOCATE(list_dom_temp(0))
243  END IF
244 
245  !===Data for Maxwell
246  IF ( (type_pb == 'mhd') .OR. (type_pb == 'mxw') .OR. (type_pb == 'fhd')) THEN
247  CALL read_until(22, '===Type of finite element for magnetic field')
248  READ (22, *) type_fe_h
249  CALL read_until(22, '===Number of subdomains in magnetic field (H) mesh')
250  READ(22,*) nb_dom_h ! number of sub_domains for H
251  ALLOCATE(list_dom_h_in(nb_dom_h), list_dom_h(nb_dom_h), h_in_to_new(nb_dom_h)) ! JLG/AR Nov 17 2008
252  CALL read_until(22, '===List of subdomains for magnetic field (H) mesh')
253  READ(22,*) list_dom_h_in
254 
255  !==========Interfaces H/H==========================!
256  CALL read_until(22, '===Number of interfaces in H mesh')
257  READ(22,*) nb_inter_mu
258  ALLOCATE(list_inter_mu(nb_inter_mu))
259  IF (nb_inter_mu>0) THEN
260  CALL read_until(22, '===List of interfaces in H mesh')
261  READ(22,*) list_inter_mu
262  END IF
263 
264  !==========Subdomains for phi======================!
265  CALL find_string(22, '===Number of subdomains in magnetic potential (phi) mesh', test)
266  IF (test) THEN
267  READ (22, *) nb_dom_phi
268  ELSE
269  nb_dom_phi = 0
270  END IF
271  ALLOCATE(list_dom_phi(nb_dom_phi))
272  IF (nb_dom_phi>0) THEN
273  !==========List of subdomains for phi======================!
274  CALL read_until(22, '===List of subdomains for magnetic potential (phi) mesh')
275  READ(22,*) list_dom_phi
276 
277  !==========H/phi interface=========================!
278  CALL read_until(22, '===Number of interfaces between H and phi')
279  READ(22,*) nb_inter ! number of interfaces between H and phi
280  ALLOCATE(list_inter_h_phi(nb_inter))
281  IF (nb_inter>0) THEN
282  CALL read_until(22, '===List of interfaces between H and phi')
283  READ(22,*) list_inter_h_phi
284  END IF
285 
286  !==========Finite element type=====================!
287  CALL read_until(22, '===Type of finite element for scalar potential')
288  READ(22,*) type_fe_phi
289  ELSE
290  ALLOCATE(list_inter_h_phi(0))
291  type_fe_phi = -1
292  END IF
293  IF (type_pb == 'mxw') THEN
294  ALLOCATE(list_dom_ns(0))
295  END IF
296  END IF
297 
298  CALL find_string(22, '===How many pieces of periodic boundary?', test)
299  IF (test) THEN
300  READ (22, *) my_periodic%nb_periodic_pairs
301  ELSE
302  my_periodic%nb_periodic_pairs = 0
303  END IF
304 
305  IF (my_periodic%nb_periodic_pairs.GE.1) THEN
306  ALLOCATE(my_periodic%list_periodic(2,my_periodic%nb_periodic_pairs))
307  ALLOCATE(my_periodic%vect_e(2,my_periodic%nb_periodic_pairs))
308  CALL read_until(22, '===Indices of periodic boundaries and corresponding vectors')
309  DO k = 1, my_periodic%nb_periodic_pairs
310  READ(22,*) my_periodic%list_periodic(:,k), my_periodic%vect_e(:,k)
311  END DO
312  END IF
313  CLOSE(22)
314 
315  !===Creation of logicals for equations
316  if_mass = if_level_set
317  if_momentum = type_pb=='nst' .OR. type_pb=='mhd' .OR. type_pb=='fhd'
318  if_induction = type_pb=='mxw' .OR. type_pb=='mhd' .OR. type_pb=='fhd' ! No mxx: for mxx, put mhd
319  if_energy = if_temperature
320 
321  !===Check that vv_mesh is a subset of H_mesh
322  IF (if_induction) THEN
323  IF (if_momentum) THEN
324  IF (SIZE(list_dom_h) < SIZE(list_dom_ns)) THEN
325  WRITE(*,*) ' BUG: NS must be a subset of Maxwell '
326  stop
327  END IF
328  DO k = 1, nb_dom_ns
329  ! JLG/AR Nov 17 2008
330  IF (minval(abs(list_dom_h_in - list_dom_ns(k))) /= 0) THEN
331  WRITE(*,*) ' BUG : NS must be a subset of Maxwell '
332  stop
333  END IF
334  DO kp = 1, nb_dom_h
335  IF (list_dom_h_in(kp) == list_dom_ns(k)) EXIT
336  END DO
337  h_in_to_new(k) = kp
338  ! JLG/AR Nov 17 2008
339  list_dom_h(k) = list_dom_ns(k)
340  END DO
341  m = nb_dom_ns
342  DO k = 1, nb_dom_h
343  IF (minval(abs(list_dom_h_in(k) - list_dom_ns)) == 0) cycle
344  m = m + 1
345  ! JLG/AR Nov 17 2008
346  h_in_to_new(m) = k
347  ! JLG/AR Nov 17 2008
348  list_dom_h(m) = list_dom_h_in(k)
349  END DO
350  IF (m/=nb_dom_h) THEN
351  WRITE(*,*) ' BUG : m/=nb_dom_H '
352  stop
353  END IF
354  IF (nb_dom_h > nb_dom_ns) THEN
355  dom_h_larger_dom_ns = .true.
356  ELSE
357  dom_h_larger_dom_ns = .false.
358  END IF
359  ELSE
360  ! JLG/AR Nov 17 2008
361  DO k = 1, nb_dom_h
362  h_in_to_new(k) = k
363  END DO
364  ! JLG/AR Nov 17 2008
365  list_dom_h = list_dom_h_in
366  END IF
367  END IF
368 
369  !===Check that vv_mesh is a subset of temp_mesh
370  IF (if_energy) THEN
371  IF (SIZE(list_dom_temp) < SIZE(list_dom_ns)) THEN
372  WRITE(*,*) ' BUG: NS must be a subset of temp '
373  stop
374  END IF
375  DO k = 1, nb_dom_ns
376  IF (minval(abs(list_dom_temp_in - list_dom_ns(k))) /= 0) THEN
377  WRITE(*,*) ' BUG : NS must be a subset of temp '
378  stop
379  END IF
380  DO kp = 1, nb_dom_temp
381  IF (list_dom_temp_in(kp) == list_dom_ns(k)) EXIT
382  END DO
383  temp_in_to_new(k) = kp
384  list_dom_temp(k) = list_dom_ns(k)
385  END DO
386  m = nb_dom_ns
387  DO k = 1, nb_dom_temp
388  IF (minval(abs(list_dom_temp_in(k) - list_dom_ns)) == 0) cycle
389  m = m + 1
390  temp_in_to_new(m) = k
391  list_dom_temp(m) = list_dom_temp_in(k)
392  END DO
393  IF (m/=nb_dom_temp) THEN
394  WRITE(*,*) ' BUG : m/=nb_dom_temp '
395  stop
396  END IF
397  IF (nb_dom_temp > nb_dom_ns) THEN
398  dom_temp_larger_dom_ns = .true.
399  ELSE
400  dom_temp_larger_dom_ns = .false.
401  END IF
402  END IF
403 
404  !===Check that temp_mesh is a subset of H_mesh
405  IF (if_induction .AND. if_energy) THEN
406  IF (SIZE(list_dom_h) < SIZE(list_dom_temp)) THEN
407  WRITE(*,*) ' BUG: temp must be a subset of Maxwell '
408  stop
409  END IF
410  DO k = 1, nb_dom_temp
411  IF (minval(abs(list_dom_h - list_dom_temp(k))) /= 0) THEN
412  WRITE(*,*) ' BUG: temp must be a subset of Maxwell '
413  stop
414  END IF
415  END DO
416  END IF
417 
418  !===Create interfaces in meshes
419  IF (if_momentum .AND. (.NOT. if_induction)) THEN
420  IF (if_energy) THEN
421  nsize = SIZE(list_dom_temp)
422  ALLOCATE(list_dom(nsize))
423  list_dom = list_dom_temp
424  ALLOCATE(list_inter(SIZE(list_inter_v_t)))
425  list_inter = list_inter_v_t
426  ELSE
427  nsize = SIZE(list_dom_ns)
428  ALLOCATE(list_dom(nsize))
429  list_dom = list_dom_ns
430  ALLOCATE(list_inter(0))
431  END IF
432  ELSE
433  nsize = SIZE(list_dom_h)+SIZE(list_dom_phi)
434  ALLOCATE(list_dom(nsize))
435  list_dom(1:SIZE(list_dom_h)) = list_dom_h
436  IF (SIZE(list_dom_phi)>0) THEN
437  list_dom(SIZE(list_dom_h)+1:) = list_dom_phi
438  END IF
439  nsize = SIZE(list_inter_mu)+SIZE(list_inter_h_phi)
440  ALLOCATE(list_inter(nsize))
441  IF (SIZE(list_inter_mu)>0) THEN
442  list_inter(1:SIZE(list_inter_mu)) = list_inter_mu
443  END IF
444  IF (SIZE(list_inter_h_phi)>0) THEN
445  list_inter(SIZE(list_inter_mu)+1:) = list_inter_h_phi
446  END IF
447  END IF
448  IF (if_energy) THEN
449  ALLOCATE(list_inter_temp(0))
450  END IF
451 
452  !===Directory, file name and format
453  IF (is_in) THEN
454  directory = old_directory
455  file_name = old_filename
456  iformatted = old_is_form
457  ELSE
458  directory = new_directory
459  file_name = new_filename
460  iformatted = new_is_form
461  END IF
462 
463  IF (is_in) THEN
464  directory_m = new_directory
465  file_name_m = new_filename
466  is_form_m = new_is_form
467  ELSE
468  directory_m = old_directory
469  file_name_m = old_filename
470  is_form_m = old_is_form
471  END IF
472 
473  !===Check coherence
474  CALL mpi_comm_size(petsc_comm_world, nb_procs, ierr)
475  IF ( nb_s*nb_f /= nb_procs ) THEN
476  CALL error_petsc('BUG: nb_S * nb_F /= nb_procs')
477  END IF
478 
479  CALL create_cart_comm((/nb_s, nb_f/),comm_cart,comm_one_d,coord_cart)
480  CALL mpi_comm_size(comm_one_d(2),nb_procs,code)
481  CALL mpi_comm_rank(comm_one_d(2),rank,code)
482  IF (nb_f/=nb_procs) THEN
483  CALL error_petsc('BUG in INIT, nb_procs_F/=nb_procs')
484  END IF
485 
486  IF ( (rw_ns) .AND. (type_pb=='mxw')) THEN
487  CALL error_petsc('WARNING: type_pb and/or rw_ns might be wrong')
488  END IF
489  IF ( (rw_mxw) .AND. ((type_pb=='nst')) ) THEN
490  CALL error_petsc('WARNING: type_pb and/or rw_mxw might be wrong')
491  END IF
492 
493  !===Prepare meshes and pointers
494  CALL load_dg_mesh_free_format(directory, file_name, list_dom, list_inter, 1, p1_mesh_glob, iformatted)
495  CALL load_dg_mesh_free_format(directory, file_name, list_dom, list_inter, 2, p2_mesh_glob, iformatted)
496  IF (if_energy) THEN
497  CALL load_dg_mesh_free_format(directory, file_name, list_dom, &
498  list_inter_temp, 2, p2_c0_mesh_glob_temp, iformatted)
499  END IF
500 
501  !===Start Metis mesh generation=================================================
502  ALLOCATE(part(p1_mesh_glob%me))
503  WRITE(tit_part,'(i4)') nb_s
504  mesh_part_name='mesh_part_S'//trim(adjustl(tit_part))//'.'//trim(adjustl(file_name))
505  IF (if_read_partition) THEN
506  OPEN(unit=51, file=mesh_part_name, status='unknown', form='formatted')
507  READ(51,*) part
508  CLOSE(51)
509  WRITE(*,*) 'read partition'
510  ELSE
511  WRITE(*,*) 'create partition'
512  CALL part_mesh_m_t_h_phi(nb_s, list_dom_ns, list_dom_temp, list_dom_h, &
513  list_dom_phi, p1_mesh_glob, list_inter, part, my_periodic)
514  IF (petsc_rank==0) THEN
515  OPEN(unit=51, file=mesh_part_name, status='replace', form='formatted')
516  WRITE(51,*) part
517  CLOSE(51)
518  END IF
519  END IF
520 
521  !===Extract local meshes from global meshes
522  IF (if_momentum) THEN
523  CALL extract_mesh(comm_one_d(1),nb_s,p1_mesh_glob,part,list_dom_ns,pp_mesh_glob,pp_mesh)
524  CALL extract_mesh(comm_one_d(1),nb_s,p2_mesh_glob,part,list_dom_ns,vv_mesh_glob,vv_mesh)
525 
526  ALLOCATE(comm_one_d_ns(2))
527  comm_one_d_ns(2) = comm_one_d(2)
528  CALL mpi_comm_rank(comm_one_d(1),rank_s,code)
529  IF (pp_mesh%me/=0) THEN
530  CALL mpi_comm_split(comm_one_d(1),1,rank_s,comm_one_d_ns(1),code)
531  ELSE
532  CALL mpi_comm_split(comm_one_d(1),mpi_undefined,rank_s,comm_one_d_ns(1),code)
533  END IF
534  END IF
535 
536  IF (if_energy) THEN
537  CALL extract_mesh(comm_one_d(1),nb_s,p2_c0_mesh_glob_temp,part,list_dom_temp,temp_mesh_glob,temp_mesh)
538  ALLOCATE(comm_one_d_temp(2))
539  CALL mpi_comm_dup(comm_one_d(2), comm_one_d_temp(2), code)
540  CALL mpi_comm_rank(comm_one_d(1),rank_s,code)
541  IF (temp_mesh%me/=0) THEN
542  CALL mpi_comm_split(comm_one_d(1),1,rank_s,comm_one_d_temp(1),code)
543  ELSE
544  CALL mpi_comm_split(comm_one_d(1),mpi_undefined,rank_s,comm_one_d_temp(1),code)
545  END IF
546  END IF
547 
548  IF (if_induction) THEN
549  IF (type_fe_h==1) THEN
550  CALL extract_mesh(comm_one_d(1),nb_s,p1_mesh_glob,part,list_dom_h,h_mesh_glob,h_mesh)
551  ELSE
552  CALL extract_mesh(comm_one_d(1),nb_s,p2_mesh_glob,part,list_dom_h,h_mesh_glob,h_mesh)
553  END IF
554  IF (type_fe_phi==1) THEN
555  CALL extract_mesh(comm_one_d(1),nb_s,p1_mesh_glob,part,list_dom_phi,phi_mesh_glob,phi_mesh)
556  ELSE
557  CALL extract_mesh(comm_one_d(1),nb_s,p2_mesh_glob,part,list_dom_phi,phi_mesh_glob,phi_mesh)
558  END IF
559  END IF
560 
561  !===Cleanup
562  CALL free_mesh(p1_mesh_glob)
563  CALL free_mesh(p2_mesh_glob)
564  IF (if_energy) THEN
565  DEALLOCATE(list_inter_temp)
566  CALL free_mesh(p2_c0_mesh_glob_temp)
567  END IF
568 
569  m_max_c = nb_mode/nb_f
570 
571  !===Load meshes for monoproc
572  IF (if_momentum) THEN
573  CALL free_mesh(vv_mesh_glob)
574  CALL free_mesh(pp_mesh_glob)
575  CALL load_mesh_free_format(directory_m, file_name_m, list_dom_ns, 2, vv_mesh_glob, is_form_m)
576  CALL load_mesh_free_format(directory_m, file_name_m, list_dom_ns, 1, pp_mesh_glob, is_form_m)
577  IF (check_plt) THEN
578  CALL plot_const_p1_label(vv_mesh_glob%jj, vv_mesh_glob%rr, 1.d0*vv_mesh_glob%i_d, 'vv.plt')
579  END IF
580  END IF
581  IF (if_energy) THEN
582  CALL free_mesh(temp_mesh_glob)
583  CALL load_mesh_free_format(directory_m, file_name_m, list_dom_temp, 2, temp_mesh_glob, is_form_m)
584  IF (check_plt) THEN
585  CALL plot_const_p1_label(temp_mesh_glob%jj, temp_mesh_glob%rr, 1.d0*temp_mesh_glob%i_d, 'temp.plt')
586  END IF
587  END IF
588  IF (if_induction) THEN
589  CALL free_mesh(h_mesh_glob)
590  CALL free_mesh(phi_mesh_glob)
591  CALL load_dg_mesh_free_format(directory_m, file_name_m, list_dom_h, list_inter_mu, type_fe_h, h_mesh_glob, is_form_m)
592  CALL load_mesh_free_format(directory_m, file_name_m, list_dom_phi, type_fe_phi, phi_mesh_glob, is_form_m)
593  IF (check_plt) THEN
594  CALL plot_const_p1_label(h_mesh_glob%jj, h_mesh_glob%rr, 1.d0*h_mesh_glob%i_d, 'HH.plt')
595  CALL plot_const_p1_label(phi_mesh_glob%jj, phi_mesh_glob%rr, 1.d0*phi_mesh_glob%i_d, 'phi.plt')
596  END IF
597  END IF
598 
599  !===Array allocation
600  IF (if_momentum) THEN
601  ALLOCATE(un_glob(vv_mesh_glob%np, 6, m_max_c))
602  ALLOCATE(un_m1_glob(vv_mesh_glob%np, 6, m_max_c))
603  ALLOCATE(pn_glob(pp_mesh_glob%np, 2, m_max_c))
604  ALLOCATE(pn_m1_glob(pp_mesh_glob%np, 2, m_max_c))
605  ALLOCATE(incpn_m1_glob(pp_mesh_glob%np, 2, m_max_c))
606  ALLOCATE(incpn_glob(pp_mesh_glob%np, 2, m_max_c))
607  ALLOCATE(un(vv_mesh%np, 6, m_max_c))
608  ALLOCATE(un_m1(vv_mesh%np, 6, m_max_c))
609  ALLOCATE(pn(pp_mesh%np, 2, m_max_c))
610  ALLOCATE(pn_m1(pp_mesh%np, 2, m_max_c))
611  ALLOCATE(incpn_m1(pp_mesh%np, 2, m_max_c))
612  ALLOCATE(incpn(pp_mesh%np, 2, m_max_c))
613  un_glob = 0.d0
614  un_m1_glob = 0.d0
615  pn_glob = 0.d0
616  pn_m1_glob = 0.d0
617  incpn_m1_glob = 0.d0
618  incpn_glob = 0.d0
619  un = 0.d0
620  un_m1 = 0.d0
621  pn = 0.d0
622  pn_m1 = 0.d0
623  incpn_m1= 0.d0
624  incpn = 0.d0
625  IF (if_mass) THEN
626  ALLOCATE(level_setn_m1_glob(nb_fluid-1,pp_mesh_glob%np, 2, m_max_c))
627  ALLOCATE(level_setn_glob(nb_fluid-1,pp_mesh_glob%np, 2, m_max_c))
628  ALLOCATE(level_setn_m1(nb_fluid-1,pp_mesh%np, 2, m_max_c))
629  ALLOCATE(level_setn(nb_fluid-1,pp_mesh%np, 2, m_max_c))
630  level_setn_m1_glob = 0.d0
631  level_setn_glob = 0.d0
632  level_setn_m1 = 0.d0
633  level_setn = 0.d0
634  END IF
635  END IF
636 
637  IF (if_energy) THEN
638  ALLOCATE(tempn_m1_glob(temp_mesh_glob%np, 2, m_max_c))
639  ALLOCATE(tempn_glob(temp_mesh_glob%np, 2, m_max_c))
640  ALLOCATE(tempn_m1(temp_mesh%np, 2, m_max_c))
641  ALLOCATE(tempn(temp_mesh%np, 2, m_max_c))
642  tempn_m1_glob = 0.d0
643  tempn_glob = 0.d0
644  tempn_m1 = 0.d0
645  tempn = 0.d0
646  END IF
647 
648  IF (if_induction) THEN
649  ALLOCATE(hn1(h_mesh%np, 6, m_max_c))
650  ALLOCATE(hn(h_mesh%np, 6, m_max_c))
651  ALLOCATE(bn1(h_mesh%np, 6, m_max_c))
652  ALLOCATE(bn(h_mesh%np, 6, m_max_c))
653  ALLOCATE(phin1(phi_mesh%np,2, m_max_c))
654  ALLOCATE(phin(phi_mesh%np,2, m_max_c))
655  ALLOCATE(hn1_glob(h_mesh_glob%np, 6, m_max_c))
656  ALLOCATE(hn_glob(h_mesh_glob%np, 6, m_max_c))
657  ALLOCATE(bn1_glob(h_mesh_glob%np, 6, m_max_c))
658  ALLOCATE(bn_glob(h_mesh_glob%np, 6, m_max_c))
659  ALLOCATE(phin1_glob(phi_mesh_glob%np,2, m_max_c))
660  ALLOCATE(phin_glob(phi_mesh_glob%np,2, m_max_c))
661  hn1 = 0.d0
662  hn = 0.d0
663  bn1 = 0.d0
664  bn = 0.d0
665  phin1 = 0.d0
666  phin = 0.d0
667  hn1_glob = 0.d0
668  hn_glob = 0.d0
669  bn1_glob = 0.d0
670  bn_glob = 0.d0
671  phin1_glob = 0.d0
672  phin_glob = 0.d0
673  END IF
674 
675  !===Pointers
676  IF (is_in) THEN
677  mono_in = .false.
678  mono_out = .true.
679  IF (if_induction) THEN
680  hn_in => hn
681  hn1_in => hn1
682  bn_in => bn
683  bn1_in => bn1
684  phin_in => phin
685  phin1_in => phin1
686  h_mesh_in => h_mesh
687  phi_mesh_in => phi_mesh
688  hn_out => hn_glob
689  hn1_out => hn1_glob
690  bn_out => bn_glob
691  bn1_out => bn1_glob
692  phin_out => phin_glob
693  phin1_out => phin1_glob
694  h_mesh_out => h_mesh_glob
695  phi_mesh_out => phi_mesh_glob
696  END IF
697  IF (if_momentum) THEN
698  un_in => un
699  un_m1_in => un_m1
700  pn_in => pn
701  pn_m1_in => pn_m1
702  incpn_in => incpn
703  incpn_m1_in=> incpn_m1
704  vv_mesh_in => vv_mesh
705  pp_mesh_in => pp_mesh
706  un_out => un_glob
707  un_m1_out => un_m1_glob
708  pn_out => pn_glob
709  pn_m1_out => pn_m1_glob
710  incpn_out => incpn_glob
711  incpn_m1_out=> incpn_m1_glob
712  vv_mesh_out => vv_mesh_glob
713  pp_mesh_out => pp_mesh_glob
714  IF (if_mass) THEN
715  level_setn_in => level_setn
716  level_setn_m1_in => level_setn_m1
717  level_setn_out => level_setn_glob
718  level_setn_m1_out=> level_setn_m1_glob
719  END IF
720  END IF
721  IF (if_energy) THEN
722  tempn_in => tempn
723  tempn_m1_in => tempn_m1
724  tempn_out => tempn_glob
725  tempn_m1_out => tempn_m1_glob
726  temp_mesh_in => temp_mesh
727  temp_mesh_out => temp_mesh_glob
728  END IF
729 
730  ELSE
731  mono_in = .true.
732  mono_out = .false.
733  IF (if_induction) THEN
734  hn_in => hn_glob
735  hn1_in => hn1_glob
736  bn_in => bn_glob
737  bn1_in => bn1_glob
738  phin_in => phin_glob
739  phin1_in => phin1_glob
740  h_mesh_in => h_mesh_glob
741  phi_mesh_in => phi_mesh_glob
742  hn_out => hn
743  hn1_out => hn1
744  bn_out => bn
745  bn1_out => bn1
746  phin_out => phin
747  phin1_out => phin1
748  h_mesh_out => h_mesh
749  phi_mesh_out => phi_mesh
750  END IF
751  IF (if_momentum) THEN
752  un_in => un_glob
753  un_m1_in => un_m1_glob
754  pn_in => pn_glob
755  pn_m1_in => pn_m1_glob
756  incpn_in => incpn_glob
757  incpn_m1_in=> incpn_m1_glob
758  vv_mesh_in => vv_mesh_glob
759  pp_mesh_in => pp_mesh_glob
760  un_out => un
761  un_m1_out => un_m1
762  pn_out => pn
763  pn_m1_out => pn_m1
764  incpn_out => incpn
765  incpn_m1_out=> incpn_m1
766  vv_mesh_out => vv_mesh
767  pp_mesh_out => pp_mesh
768  IF (if_mass) THEN
769  level_setn_in => level_setn_glob
770  level_setn_m1_in => level_setn_m1_glob
771  level_setn_out => level_setn
772  level_setn_m1_out=> level_setn_m1
773  END IF
774  END IF
775  IF (if_energy) THEN
776  tempn_in => tempn_glob
777  tempn_m1_in => tempn_m1_glob
778  tempn_out => tempn
779  tempn_m1_out=> tempn_m1
780  temp_mesh_in => temp_mesh_glob
781  temp_mesh_out => temp_mesh
782  END IF
783  END IF
784 
785  !===Interpolation for Maxwell
786  IF (rw_mxw) THEN
787  IF (rank==0) WRITE(*,*) 'Start interpolation Maxwell'
788  IF (inter_mesh) THEN
789  ALLOCATE(controle_h(h_mesh_out%np), controle_phi(phi_mesh_out%np))
790  DO m = index_start, index_start+nb_fic-1
791  hn1 = 0.d0
792  hn = 0.d0
793  bn1 = 0.d0
794  bn = 0.d0
795  phin1 = 0.d0
796  phin = 0.d0
797  hn1_glob = 0.d0
798  hn_glob = 0.d0
799  bn1_glob = 0.d0
800  bn_glob = 0.d0
801  phin1_glob = 0.d0
802  phin_glob = 0.d0
803  WRITE(tit, '(i3)') m
804  lblank = eval_blank(3,tit)
805  DO l = 1, lblank - 1
806  tit(l:l) = '0'
807  END DO
808 
809  IF (petsc_rank==0) CALL system('mv suite_maxwell_I'//tit//'.'//old_filename//'suite_maxwell.'//old_filename)
810  CALL mpi_barrier( mpi_comm_world, code)
811  CALL read_restart_maxwell(comm_one_d, h_mesh_in, phi_mesh_in, time_h, list_mode, hn_in, hn1_in, &
812  bn_in, bn1_in, phin_in, phin1_in, old_filename, interpol=.false., opt_mono=mono_in)
813 
814  !===Controle_H and controle_phi are initialized to zero in interp_mesh
815  CALL interp_mesh(h_mesh_in, h_mesh_out, hn_in, hn_out, controle_h, type_fe_h)
816  CALL interp_mesh(h_mesh_in, h_mesh_out, hn1_in, hn1_out, controle_h, type_fe_h)
817  CALL interp_mesh(h_mesh_in, h_mesh_out, bn_in, bn_out, controle_h, type_fe_h)
818  CALL interp_mesh(h_mesh_in, h_mesh_out, bn1_in, bn1_out, controle_h, type_fe_h)
819  CALL interp_mesh(phi_mesh_in, phi_mesh_out, phin_in, phin_out, controle_phi, type_fe_phi)
820  CALL interp_mesh(phi_mesh_in, phi_mesh_out, phin1_in, phin1_out, controle_phi, type_fe_phi)
821 
822  IF ( min(minval(controle_h),minval(controle_phi)) == 0) THEN
823  CALL error_petsc('certains points non trouve H/phi 2')
824  END IF
825 
826  CALL write_restart_maxwell(comm_one_d, h_mesh_out, phi_mesh_out, time_h, list_mode, hn_out, hn1_out, &
827  bn_out, bn1_out, phin_out, phin1_out, new_filename, m, 1, opt_mono=mono_out)
828  CALL mpi_comm_rank(comm_one_d(1), rank_s, ierr)
829  END DO
830  DEALLOCATE(controle_h, controle_phi)
831  ELSE
832  ALLOCATE(l_t_g_h(h_mesh%np), l_t_g_phi(phi_mesh%np))
833  l_t_g_h = 0
834  l_t_g_phi = 0
835  CALL loc_to_glob(h_mesh, h_mesh_glob, l_t_g_h)
836  CALL loc_to_glob(phi_mesh, phi_mesh_glob, l_t_g_phi)
837  DO m = index_start, index_start+nb_fic-1
838  hn1 = 0.d0
839  hn = 0.d0
840  bn1 = 0.d0
841  bn = 0.d0
842  phin1 = 0.d0
843  phin = 0.d0
844  hn1_glob = 0.d0
845  hn_glob = 0.d0
846  bn1_glob = 0.d0
847  bn_glob = 0.d0
848  phin1_glob = 0.d0
849  phin_glob = 0.d0
850  WRITE(tit, '(i3)') m
851  lblank = eval_blank(3,tit)
852  DO l = 1, lblank - 1
853  tit(l:l) = '0'
854  END DO
855 
856  IF (is_in) THEN
857  CALL mpi_comm_rank(comm_one_d(1), rank_s, ierr)
858  WRITE(tit_s,'(i3)') rank_s
859  lblank = eval_blank(3,tit_s)
860  DO l = 1, lblank - 1
861  tit_s(l:l) = '0'
862  END DO
863  CALL system('mv suite_maxwell_S'//tit_s//'_I'//tit//'.'//old_filename//'suite_maxwell_S'//tit_s//'.'//old_filename)
864  ELSE
865  IF (petsc_rank==0) CALL system('mv suite_maxwell_I'//tit//'.'//old_filename//'suite_maxwell.'//old_filename)
866  CALL mpi_barrier( mpi_comm_world, code)
867  END IF
868  CALL read_restart_maxwell(comm_one_d, h_mesh_in, phi_mesh_in, time_h, list_mode, hn_in, hn1_in, &
869  bn_in, bn1_in, phin_in, phin1_in, old_filename, interpol=.false., opt_mono=mono_in)
870 
871  CALL inter_mesh_loc_to_glob(h_mesh_in, h_mesh_out, hn_in, hn_out, l_t_g_h, is_in, comm_one_d(1))
872  CALL inter_mesh_loc_to_glob(h_mesh_in, h_mesh_out, hn1_in, hn1_out, l_t_g_h, is_in, comm_one_d(1))
873  CALL inter_mesh_loc_to_glob(h_mesh_in, h_mesh_out, bn_in, bn_out, l_t_g_h, is_in, comm_one_d(1))
874  CALL inter_mesh_loc_to_glob(h_mesh_in, h_mesh_out, bn1_in, bn1_out, l_t_g_h, is_in, comm_one_d(1))
875  CALL inter_mesh_loc_to_glob(phi_mesh_in, phi_mesh_out, phin_in, phin_out, l_t_g_phi, is_in, comm_one_d(1))
876  CALL inter_mesh_loc_to_glob(phi_mesh_in, phi_mesh_out, phin1_in, phin1_out, l_t_g_phi, is_in, comm_one_d(1))
877 
878  CALL write_restart_maxwell(comm_one_d, h_mesh_out, phi_mesh_out, time_h, list_mode, hn_out, hn1_out, &
879  bn_out, bn1_out, phin_out, phin1_out, new_filename, m, 1, opt_mono=mono_out)
880  CALL mpi_comm_rank(comm_one_d(1), rank_s, ierr)
881  END DO
882 
883  END IF
884 
885  IF (check_plt) THEN
886  IF (h_mesh%me /= 0) THEN
887  CALL mpi_comm_rank(comm_one_d(1), rang_s, ierr)
888  WRITE(tit_s,'(i3)') rang_s
889  lblank = eval_blank(3,tit_s)
890  DO l = 1, lblank - 1
891  tit_s(l:l) = '0'
892  END DO
893  DO i = 1, SIZE(list_mode)
894  WRITE(tit_m,'(i3)') list_mode(i)
895  lblank = eval_blank(3,tit_m)
896  DO l = 1, lblank - 1
897  tit_m(l:l) = '0'
898  END DO
899  CALL plot_scalar_field(h_mesh%jj, h_mesh%rr, hn(:,1,i), 'H_r_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
900  CALL plot_scalar_field(h_mesh%jj, h_mesh%rr, hn(:,2,i), 'H_r_sin_m='//tit_m//'_'//tit_s//'_999.plt' )
901  CALL plot_scalar_field(h_mesh%jj, h_mesh%rr, hn(:,3,i), 'H_t_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
902  CALL plot_scalar_field(h_mesh%jj, h_mesh%rr, hn(:,4,i), 'H_t_sin_m='//tit_m//'_'//tit_s//'_999.plt' )
903  CALL plot_scalar_field(h_mesh%jj, h_mesh%rr, hn(:,5,i), 'H_z_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
904  CALL plot_scalar_field(h_mesh%jj, h_mesh%rr, hn(:,6,i), 'H_z_sin_m='//tit_m//'_'//tit_s//'_999.plt' )
905 
906  END DO
907 
908  IF (rang_s == 0) THEN
909  DO i = 1, SIZE(list_mode)
910  WRITE(tit_m,'(i3)') list_mode(i)
911  lblank = eval_blank(3,tit_m)
912  DO l = 1, lblank - 1
913  tit_m(l:l) = '0'
914  END DO
915  CALL plot_scalar_field(h_mesh_glob%jj, h_mesh_glob%rr, hn_glob(:,1,i), 'gH_r_cos_m='//tit_m//'_999.plt' )
916  CALL plot_scalar_field(h_mesh_glob%jj, h_mesh_glob%rr, hn_glob(:,2,i), 'gH_r_sin_m='//tit_m//'_999.plt' )
917  CALL plot_scalar_field(h_mesh_glob%jj, h_mesh_glob%rr, hn_glob(:,3,i), 'gH_t_cos_m='//tit_m//'_999.plt' )
918  CALL plot_scalar_field(h_mesh_glob%jj, h_mesh_glob%rr, hn_glob(:,4,i), 'gH_t_sin_m='//tit_m//'_999.plt' )
919  CALL plot_scalar_field(h_mesh_glob%jj, h_mesh_glob%rr, hn_glob(:,5,i), 'gH_z_cos_m='//tit_m//'_999.plt' )
920  CALL plot_scalar_field(h_mesh_glob%jj, h_mesh_glob%rr, hn_glob(:,6,i), 'gH_z_sin_m='//tit_m//'_999.plt' )
921  END DO
922  END IF
923  END IF
924  END IF
925  IF (rank==0) WRITE(*,*) 'End interpolation Maxwell'
926 
927  END IF
928 
929  !===Interpolation for NS
930  IF (rw_ns) THEN
931  IF (rank==0) WRITE(*,*) 'Start interpolation NS'
932 
933  IF (inter_mesh) THEN
934 
935  ALLOCATE(controle_vv(vv_mesh_out%np), controle_pp(pp_mesh_out%np))
936  DO m = index_start, index_start+nb_fic-1
937  un_glob = 0.d0
938  un_m1_glob = 0.d0
939  pn_glob = 0.d0
940  pn_m1_glob = 0.d0
941  incpn_m1_glob = 0.d0
942  incpn_glob = 0.d0
943  un = 0.d0
944  un_m1 = 0.d0
945  pn = 0.d0
946  pn_m1 = 0.d0
947  incpn_m1= 0.d0
948  incpn = 0.d0
949  IF (if_level_set) THEN
950  level_setn_m1_glob = 0.d0
951  level_setn_glob = 0.d0
952  level_setn_m1 = 0.d0
953  level_setn = 0.d0
954  END IF
955 
956  WRITE(tit, '(i3)') m
957  lblank = eval_blank(3,tit)
958  DO l = 1, lblank - 1
959  tit(l:l) = '0'
960  END DO
961 
962  IF (petsc_rank==0) THEN
963  CALL system('mv suite_ns_I'//tit//'.'//old_filename//'suite_ns.'//old_filename)
964  END IF
965  CALL mpi_barrier( mpi_comm_world, code)
966 
967  IF (vv_mesh%me/=0) THEN
968  IF (if_level_set)THEN
969  CALL read_restart_ns(comm_one_d_ns, time_u, list_mode, un_in, un_m1_in, &
970  pn_in, pn_m1_in, incpn_in, incpn_m1_in, old_filename,opt_level_set=level_setn_in, &
971  opt_level_set_m1=level_setn_m1_in, opt_max_vel=max_vel, opt_mono = mono_in)
972 
973  ELSE
974  CALL read_restart_ns(comm_one_d_ns, time_u, list_mode, un_in, un_m1_in, &
975  pn_in, pn_m1_in, incpn_in, incpn_m1_in, old_filename, opt_mono = mono_in)
976  END IF
977  END IF
978  controle_vv = 0
979  controle_pp = 0
980  CALL interp_mesh(vv_mesh_in, vv_mesh_out, un_in, un_out, controle_vv, 2)
981  CALL interp_mesh(vv_mesh_in, vv_mesh_out, un_m1_in, un_m1_out, controle_vv, 2)
982  CALL interp_mesh(pp_mesh_in, pp_mesh_out, pn_in, pn_out, controle_pp, 1)
983  CALL interp_mesh(pp_mesh_in, pp_mesh_out, pn_m1_in, pn_m1_out, controle_pp, 1)
984  CALL interp_mesh(pp_mesh_in, pp_mesh_out, incpn_in, incpn_out, controle_pp, 1)
985  CALL interp_mesh(pp_mesh_in, pp_mesh_out, incpn_m1_in, incpn_m1_out, controle_pp, 1)
986  IF (if_level_set) THEN
987  DO k = 1, nb_fluid-1
988  CALL interp_mesh(pp_mesh_in, pp_mesh_out, level_setn_in(k,:,:,:), level_setn_out(k,:,:,:), controle_pp, 1)
989  CALL interp_mesh(pp_mesh_in, pp_mesh_out, level_setn_m1_in(k,:,:,:), level_setn_m1_out(k,:,:,:), controle_pp, 1)
990  END DO
991  END IF
992 
993  IF ( min(minval(controle_vv),minval(controle_pp)) == 0) THEN
994  CALL error_petsc('certains points non trouve')
995  END IF
996 
997  IF (pp_mesh%me /=0) THEN
998  IF (if_level_set) THEN
999  CALL write_restart_ns(comm_one_d_ns, vv_mesh_out, pp_mesh_out, time_u, list_mode, un_out, un_m1_out, &
1000  pn_out, pn_m1_out, incpn_out, incpn_m1_out, new_filename, m, 1, opt_level_set=level_setn_out, &
1001  opt_level_set_m1=level_setn_m1_out, opt_max_vel=max_vel, opt_mono=mono_out)
1002  ELSE
1003  CALL write_restart_ns(comm_one_d_ns, vv_mesh_out, pp_mesh_out, time_u, list_mode, un_out, un_m1_out, &
1004  pn_out, pn_m1_out, incpn_out, incpn_m1_out, new_filename, m, 1, opt_mono=mono_out)
1005  END IF
1006  CALL mpi_comm_rank(comm_one_d_ns(1), rang_ns_s, ierr)
1007  END IF
1008  END DO
1009  DEALLOCATE(controle_vv, controle_pp)
1010 
1011  ELSE
1012 
1013  ALLOCATE(l_t_g_vv(vv_mesh%np), l_t_g_pp(pp_mesh%np))
1014  l_t_g_vv = 0
1015  l_t_g_pp = 0
1016  CALL loc_to_glob(vv_mesh, vv_mesh_glob, l_t_g_vv)
1017  CALL loc_to_glob(pp_mesh, pp_mesh_glob, l_t_g_pp)
1018  IF (pp_mesh%me /=0) THEN
1019  DO m = index_start, index_start+nb_fic-1
1020  un_glob = 0.d0
1021  un_m1_glob = 0.d0
1022  pn_glob = 0.d0
1023  pn_m1_glob = 0.d0
1024  incpn_m1_glob = 0.d0
1025  incpn_glob = 0.d0
1026  un = 0.d0
1027  un_m1 = 0.d0
1028  pn = 0.d0
1029  pn_m1 = 0.d0
1030  incpn_m1= 0.d0
1031  incpn = 0.d0
1032  IF (if_level_set) THEN
1033  level_setn_m1_glob = 0.d0
1034  level_setn_glob = 0.d0
1035  level_setn_m1 = 0.d0
1036  level_setn = 0.d0
1037  END IF
1038 
1039  WRITE(tit, '(i3)') m
1040  lblank = eval_blank(3,tit)
1041  DO l = 1, lblank - 1
1042  tit(l:l) = '0'
1043  END DO
1044  IF (is_in) THEN
1045  CALL mpi_comm_rank(comm_one_d_ns(1), rang_ns_s, ierr)
1046  WRITE(tit_s,'(i3)') rang_ns_s
1047  lblank = eval_blank(3,tit_s)
1048  DO l = 1, lblank - 1
1049  tit_s(l:l) = '0'
1050  END DO
1051 
1052  CALL system('mv suite_ns_S'//tit_s//'_I'//tit//'.'//old_filename//'suite_ns_S'//tit_s//'.'//old_filename)
1053 
1054  ELSE
1055  IF (petsc_rank==0) CALL system('mv suite_ns_I'//tit//'.'//old_filename//'suite_ns.'//old_filename)
1056  CALL mpi_barrier( mpi_comm_world, code)
1057  END IF
1058 
1059  IF (if_level_set) THEN
1060  CALL read_restart_ns(comm_one_d_ns, time_u, list_mode, un_in, un_m1_in, &
1061  pn_in, pn_m1_in, incpn_in, incpn_m1_in, old_filename, opt_level_set=level_setn_in, &
1062  opt_level_set_m1=level_setn_m1_in, opt_max_vel=max_vel, opt_mono = mono_in)
1063  ELSE
1064  CALL read_restart_ns(comm_one_d_ns, time_u, list_mode, un_in, un_m1_in, &
1065  pn_in, pn_m1_in, incpn_in, incpn_m1_in, old_filename, opt_mono = mono_in)
1066  END IF
1067 
1068  CALL inter_mesh_loc_to_glob(vv_mesh_in, vv_mesh_out, un_in, un_out, l_t_g_vv, is_in, &
1069  comm_one_d_ns(1))
1070  CALL inter_mesh_loc_to_glob(vv_mesh_in, vv_mesh_out, un_m1_in, un_m1_out, l_t_g_vv, is_in, &
1071  comm_one_d_ns(1))
1072  CALL inter_mesh_loc_to_glob(pp_mesh_in, pp_mesh_out, pn_in, pn_out, l_t_g_pp, is_in, &
1073  comm_one_d_ns(1))
1074  CALL inter_mesh_loc_to_glob(pp_mesh_in, pp_mesh_out, pn_m1_in, pn_m1_out, l_t_g_pp, is_in, &
1075  comm_one_d_ns(1))
1076  CALL inter_mesh_loc_to_glob(pp_mesh_in, pp_mesh_out, incpn_in, incpn_out, l_t_g_pp, is_in, &
1077  comm_one_d_ns(1))
1078  CALL inter_mesh_loc_to_glob(pp_mesh_in, pp_mesh_out, incpn_m1_in, incpn_m1_out, l_t_g_pp, is_in, &
1079  comm_one_d_ns(1))
1080  IF (if_level_set) THEN
1081  DO k = 1, nb_fluid-1
1082  CALL inter_mesh_loc_to_glob(pp_mesh_in, pp_mesh_out, level_setn_in(k,:,:,:), level_setn_out(k,:,:,:), &
1083  l_t_g_pp, is_in, comm_one_d_ns(1))
1084  CALL inter_mesh_loc_to_glob(pp_mesh_in, pp_mesh_out, level_setn_m1_in(k,:,:,:), &
1085  level_setn_m1_out(k,:,:,:), l_t_g_pp, is_in, comm_one_d_ns(1))
1086  END DO
1087  END IF
1088 
1089  IF (if_level_set) THEN
1090  CALL write_restart_ns(comm_one_d_ns, vv_mesh_out, pp_mesh_out, time_u, list_mode, un_out, un_m1_out, &
1091  pn_out, pn_m1_out, incpn_out, incpn_m1_out, new_filename, m, 1, opt_level_set=level_setn_out, &
1092  opt_level_set_m1=level_setn_m1_out, opt_max_vel=max_vel, opt_mono=mono_out)
1093  ELSE
1094  CALL write_restart_ns(comm_one_d_ns, vv_mesh_out, pp_mesh_out, time_u, list_mode, un_out, un_m1_out, &
1095  pn_out, pn_m1_out, incpn_out, incpn_m1_out, new_filename, m, 1, opt_mono=mono_out)
1096  END IF
1097  CALL mpi_comm_rank(comm_one_d_ns(1), rang_ns_s, ierr)
1098  END DO
1099  END IF
1100  END IF
1101 
1102  IF (check_plt) THEN
1103  IF (pp_mesh%me /= 0) THEN
1104  CALL mpi_comm_rank(comm_one_d_ns(1), rang_ns_s, ierr)
1105  WRITE(tit_s,'(i3)') rang_ns_s
1106  lblank = eval_blank(3,tit_s)
1107  DO l = 1, lblank - 1
1108  tit_s(l:l) = '0'
1109  END DO
1110  DO i = 1, SIZE(list_mode)
1111  WRITE(tit_m,'(i3)') list_mode(i)
1112  lblank = eval_blank(3,tit_m)
1113  DO l = 1, lblank - 1
1114  tit_m(l:l) = '0'
1115  END DO
1116  CALL plot_scalar_field(vv_mesh%jj, vv_mesh%rr, un(:,1,i), 'u_r_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
1117  CALL plot_scalar_field(vv_mesh%jj, vv_mesh%rr, un(:,3,i), 'u_t_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
1118  CALL plot_scalar_field(vv_mesh%jj, vv_mesh%rr, un(:,4,i), 'u_t_sin_m='//tit_m//'_'//tit_s//'_999.plt' )
1119  CALL plot_scalar_field(vv_mesh%jj, vv_mesh%rr, un(:,5,i), 'u_z_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
1120 
1121  END DO
1122 
1123  IF (rang_ns_s == 0) THEN
1124  DO i = 1, SIZE(list_mode)
1125  WRITE(tit_m,'(i3)') list_mode(i)
1126  lblank = eval_blank(3,tit_m)
1127  DO l = 1, lblank - 1
1128  tit_m(l:l) = '0'
1129  END DO
1130  CALL plot_scalar_field(vv_mesh_glob%jj, vv_mesh_glob%rr, un_glob(:,1,i), 'gu_r_cos_m='//tit_m//'_999.plt' )
1131  CALL plot_scalar_field(vv_mesh_glob%jj, vv_mesh_glob%rr, un_glob(:,3,i), 'gu_t_cos_m='//tit_m//'_999.plt' )
1132  CALL plot_scalar_field(vv_mesh_glob%jj, vv_mesh_glob%rr, un_glob(:,4,i), 'gu_t_sin_m='//tit_m//'_999.plt' )
1133  CALL plot_scalar_field(vv_mesh_glob%jj, vv_mesh_glob%rr, un_glob(:,5,i), 'gu_z_cos_m='//tit_m//'_999.plt' )
1134  END DO
1135  END IF
1136  END IF
1137  END IF
1138  IF (rank==0) WRITE(*,*) 'End interpolation NS'
1139  END IF
1140 
1141  !===Interpolation for temperature
1142  IF (rw_temp) THEN
1143  IF (rank==0) WRITE(*,*) 'Start interpolation temperature'
1144 
1145  IF (inter_mesh) THEN
1146  ALLOCATE(controle_temp(temp_mesh_out%np))
1147  DO m = index_start, index_start+nb_fic-1
1148  tempn_m1_glob = 0.d0
1149  tempn_glob = 0.d0
1150  tempn_m1 = 0.d0
1151  tempn = 0.d0
1152  WRITE(tit, '(i3)') m
1153  lblank = eval_blank(3,tit)
1154  DO l = 1, lblank - 1
1155  tit(l:l) = '0'
1156  END DO
1157 
1158  IF (petsc_rank==0) THEN
1159  CALL system('mv suite_temp_I'//tit//'.'//old_filename//'suite_temp.'//old_filename)
1160  END IF
1161  CALL mpi_barrier( mpi_comm_world, code)
1162 
1163  IF (temp_mesh%me/=0) THEN
1164  CALL read_restart_temp(comm_one_d_temp, time_t, list_mode, tempn_in, tempn_m1_in, old_filename, &
1165  opt_mono = mono_in)
1166  END IF
1167  controle_temp = 0
1168  CALL interp_mesh(temp_mesh_in, temp_mesh_out, tempn_in, tempn_out, controle_temp, 2)
1169  CALL interp_mesh(temp_mesh_in, temp_mesh_out, tempn_m1_in, tempn_m1_out, controle_temp, 2)
1170 
1171  IF (temp_mesh%me /= 0) THEN
1172  CALL write_restart_temp(comm_one_d_temp, temp_mesh_out, time_t, &
1173  list_mode, tempn_out, tempn_m1_out, new_filename, m, 1, opt_mono = mono_out)
1174  CALL mpi_comm_rank(comm_one_d_temp(1), rang_temp_s, ierr)
1175  END IF
1176  END DO
1177  DEALLOCATE(controle_temp)
1178 
1179  ELSE
1180 
1181  ALLOCATE(l_t_g_temp(temp_mesh%np))
1182  l_t_g_temp = 0
1183  CALL loc_to_glob(temp_mesh, temp_mesh_glob, l_t_g_temp)
1184  IF (temp_mesh%me /=0) THEN
1185  DO m = index_start, index_start+nb_fic-1
1186  tempn_m1_glob = 0.d0
1187  tempn_glob = 0.d0
1188  tempn_m1 = 0.d0
1189  tempn = 0.d0
1190 
1191  WRITE(tit, '(i3)') m
1192  lblank = eval_blank(3,tit)
1193  DO l = 1, lblank - 1
1194  tit(l:l) = '0'
1195  END DO
1196  IF (is_in) THEN
1197  CALL mpi_comm_rank(comm_one_d_temp(1), rang_temp_s, ierr)
1198  WRITE(tit_s,'(i3)') rang_temp_s
1199  lblank = eval_blank(3,tit_s)
1200  DO l = 1, lblank - 1
1201  tit_s(l:l) = '0'
1202  END DO
1203 
1204  CALL system('mv suite_temp_S'//tit_s//'_I'//tit//'.'//old_filename//'suite_temp_S'//tit_s//'.'//old_filename)
1205  ELSE
1206  IF (petsc_rank==0) CALL system('mv suite_temp_I'//tit//'.'//old_filename//'suite_temp.'//old_filename)
1207  CALL mpi_barrier( mpi_comm_world, code)
1208  END IF
1209 
1210  CALL read_restart_temp(comm_one_d_temp, time_t, list_mode, tempn_in, tempn_m1_in, old_filename, &
1211  opt_mono = mono_in)
1212 
1213  CALL inter_mesh_loc_to_glob(temp_mesh_in, temp_mesh_out, tempn_in, tempn_out, l_t_g_temp, is_in, &
1214  comm_one_d_temp(1))
1215  CALL inter_mesh_loc_to_glob(temp_mesh_in, temp_mesh_out, tempn_m1_in, tempn_m1_out, l_t_g_temp, is_in, &
1216  comm_one_d_temp(1))
1217 
1218  CALL write_restart_temp(comm_one_d_temp, temp_mesh_out, time_t, list_mode, tempn_out, tempn_m1_out, &
1219  new_filename, m, 1, opt_mono = mono_out)
1220  CALL mpi_comm_rank(comm_one_d_temp(1), rang_temp_s, ierr)
1221  END DO
1222  END IF
1223  END IF
1224 
1225  IF (check_plt) THEN
1226  IF (temp_mesh%me /= 0) THEN
1227  CALL mpi_comm_rank(comm_one_d_temp(1), rang_temp_s, ierr)
1228  WRITE(tit_s,'(i3)') rang_temp_s
1229  lblank = eval_blank(3,tit_s)
1230  DO l = 1, lblank - 1
1231  tit_s(l:l) = '0'
1232  END DO
1233  DO i = 1, SIZE(list_mode)
1234  WRITE(tit_m,'(i3)') list_mode(i)
1235  lblank = eval_blank(3,tit_m)
1236  DO l = 1, lblank - 1
1237  tit_m(l:l) = '0'
1238  END DO
1239  CALL plot_scalar_field(temp_mesh%jj, temp_mesh%rr, tempn(:,1,i), 'temp_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
1240  CALL plot_scalar_field(temp_mesh%jj, temp_mesh%rr, tempn(:,2,i), 'temp_sin_m='//tit_m//'_'//tit_s//'_999.plt' )
1241  END DO
1242  IF (rang_temp_s == 0) THEN
1243  DO i = 1, SIZE(list_mode)
1244  WRITE(tit_m,'(i3)') list_mode(i)
1245  lblank = eval_blank(3,tit_m)
1246  DO l = 1, lblank - 1
1247  tit_m(l:l) = '0'
1248  END DO
1249  CALL plot_scalar_field(temp_mesh_glob%jj, temp_mesh_glob%rr, tempn(:,1,i), &
1250  'gtemp_cos_m='//tit_m//'_'//tit_s//'_999.plt' )
1251  CALL plot_scalar_field(temp_mesh_glob%jj, temp_mesh_glob%rr, tempn(:,2,i), &
1252  'gtemp_sin_m='//tit_m//'_'//tit_s//'_999.plt' )
1253  END DO
1254  END IF
1255  END IF
1256  END IF
1257  IF (rank==0) WRITE(*,*) 'End interpolation temperature'
1258  END IF
1259 
1260  IF (is_in) THEN
1261  IF (petsc_rank==0 .AND. rw_mxw) CALL system('rm -rf suite_maxwell_S*')
1262  IF (petsc_rank==0 .AND. rw_ns) CALL system('rm -rf suite_ns_S*')
1263  IF (petsc_rank==0 .AND. rw_temp) CALL system('rm -rf suite_temp_S*')
1264  ELSE
1265  IF (petsc_rank==0 .AND. rw_mxw) CALL system('rm -rf suite_maxwell.*')
1266  IF (petsc_rank==0 .AND. rw_ns) CALL system('rm -rf suite_ns.*')
1267  IF (petsc_rank==0 .AND. rw_temp) CALL system('rm -rf suite_temp.*')
1268  END IF
1269 
1270  IF (check_plt .AND. petsc_rank==0) THEN
1271  CALL system('mkdir -p PLT')
1272  CALL system('mv *.plt PLT/')
1273  END IF
1274  CALL mpi_barrier( mpi_comm_world, code)
1275 
1276  CALL petscfinalize(ierr)
1277 
1278  END SUBROUTINE mesh_interpol
1279 
1280  SUBROUTINE which_pb(is_in)
1281  USE my_util
1282  IMPLICIT NONE
1283  LOGICAL, INTENT(OUT) :: is_in
1284  CHARACTER(len=200) :: inline
1285  CALL getarg(1,inline)
1286  IF (trim(adjustl(inline)) == 'petsc_nonpetsc') THEN
1287  is_in = .true.
1288  ELSE IF (trim(adjustl(inline)) == 'nonpetsc_petsc') THEN
1289  is_in = .false.
1290  ELSE
1291  CALL error_petsc('BUG in which_pb')
1292  END IF
1293  END SUBROUTINE which_pb
1294 
1295 END MODULE mesh_interpolation
integer function eval_blank(len_str, string)
subroutine write_restart_maxwell(communicator, H_mesh, phi_mesh, time, list_mode, Hn, Hn1, Bn, Bn1, phin, phin1, filename, it, freq_restart, opt_mono)
Definition: restart.f90:280
subroutine write_restart_ns(communicator, vv_mesh, pp_mesh, time, list_mode, un, un_m1, pn, pn_m1, incpn, incpn_m1, filename, it, freq_restart, opt_level_set, opt_level_set_m1, opt_max_vel, opt_mono)
Definition: restart.f90:8
subroutine, public free_mesh(mesh)
subroutine loc_to_glob(mesh_loc, mesh_glob, l_t_g)
subroutine, public part_mesh_m_t_h_phi(nb_proc, list_u, list_T_in, list_h_in, list_phi, mesh, list_of_interfaces, part, my_periodic)
subroutine write_restart_temp(communicator, temp_mesh, time, list_mode, tempn, tempn_m1, filename, it, freq_restart, opt_mono)
Definition: restart.f90:534
subroutine, public load_dg_mesh_free_format(dir, fil, list_dom, list_inter, type_fe, mesh, mesh_formatted)
Definition: prep_mesh.f90:16
subroutine, public extract_mesh(communicator, nb_proc, mesh_glob, part, list_dom, mesh, mesh_loc)
subroutine read_restart_temp(communicator, time, list_mode, tempn, tempn_m1, filename, val_init, interpol, opt_mono)
Definition: restart.f90:611
subroutine, public load_mesh_free_format(dir, fil, list_dom, type_fe, mesh, mesh_formatted, edge_stab)
Definition: prep_mesh.f90:710
subroutine read_restart_ns(communicator, time, list_mode, un, un_m1, pn, pn_m1, incpn, incpn_m1, filename, val_init, interpol, opt_level_set, opt_level_set_m1, opt_max_vel, opt_mono)
Definition: restart.f90:99
subroutine which_pb(is_in)
subroutine plot_scalar_field(jj, rr, uu, file_name)
Definition: sub_plot.f90:703
subroutine interp_mesh(mesh_in, mesh_out, in_field, out_field, controle, type_fe)
subroutine inter_mesh_loc_to_glob(mesh_in, mesh_out, in_field, out_field, l_t_g, is_in, comm)
subroutine, public mesh_interpol
subroutine, public create_cart_comm(ndim, comm_cart, comm_one_d, coord_cart)
subroutine read_until(unit, string)
subroutine plot_const_p1_label(jj, rr, uu, file_name)
Definition: sub_plot.f90:264
subroutine find_string(unit, string, okay)
subroutine error_petsc(string)
Definition: my_util.f90:15
subroutine read_restart_maxwell(communicator, H_mesh, phi_mesh, time, list_mode, Hn, Hn1, Bn, Bn1, phin, phin1, filename, val_init, interpol, opt_mono)
Definition: restart.f90:374
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 form
Definition: doc_intro.h:193