SFEMaNS  version 5.3
Reference documentation for SFEMaNS
initialization.f90
Go to the documentation of this file.
1 !
2 !Authors Jean-Luc Guermond, Caroline Nore, Copyrights 2005
3 !Revised June 2008, Jean-Luc Guermond
4 !Revised for PETSC, Jean-Luc Guermond, Francky Luddens, January 2011
5 !Revised July 9th 2013, JLG, Loic Cappanera, Remi Menard, Daniel Castanon
6 !Revised July 25th 2016, JLG, Loic Cappanera, Raphael Zanella
7 !Revised July 20th 2019, JLG, Hughes Faller (p3/p2 FE + Taylor algorithm for NS)
8 
10  USE def_type_mesh
11  USE symmetric_field
12  USE input_data
13  USE my_util
14 #include "petsc/finclude/petsc.h"
15  USE petsc
16  IMPLICIT NONE
17  PUBLIC:: initial, save_run, run_sfemans
19  PRIVATE
20 
21  !Logicals for equations-----------------------------------------------------
23 
24  !Fields for Navier-Stokes---------------------------------------------------
25  TYPE(mesh_type), TARGET :: pp_mesh, vv_mesh
26  TYPE(petsc_csr_la) :: vv_1_la, pp_1_la
27  TYPE(petsc_csr_la) :: vv_3_la ! for stress bc
28  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: un, un_m1
29 ! CN-HF 16/01/2020
30  TYPE(dyn_real_array_three), TARGET, ALLOCATABLE, DIMENSION(:) :: der_un
31  ! (noeuds,type,mode) composante du champ de vitesse a deux instants sur vv_mesh
32  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: pn, pn_m1
33  TYPE(dyn_real_array_three), ALLOCATABLE, DIMENSION(:) :: der_pn
34  ! (noeuds,type,mode) composante du champ de pression a deux instants sur pp_mesh
35  REAL(KIND=8), ALLOCATABLE, DIMENSION(:,:,:) :: incpn, incpn_m1
36  !---------------------------------------------------------------------------
37 
38  !Fields for level sets in Navier-Stokes-------------------------------------
39  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:,:):: level_set, level_set_m1
40  !Fields for density---------------------------------------------------------
41  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: density, density_m1, density_m2
42  !Entropy viscosity for level-set--------------------------------------------
43  REAL(KIND=8), ALLOCATABLE, DIMENSION(:,:) :: visc_entro_level
44  !Maximum of velocity--------------------------------------------------------
45  REAL(KIND=8) :: max_vel
46 
47  !Fields for temperature-----------------------------------------------------
48  ! (noeuds,type,mode) composante du champ de phase a deux instants sur vv_mesh
49  TYPE(mesh_type), TARGET :: temp_mesh
51  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: tempn, tempn_m1
52  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:) :: vol_heat_capacity_field
53  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:) :: temperature_diffusivity_field
54  !---------------------------------------------------------------------------
55 
56  !Fields for Maxwell---------------------------------------------------------
57  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: hn, hn1, hext, phin, phin1
58  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: bn, bn1, bext
59  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:) :: sigma_field, mu_h_field
60  TYPE(mesh_type), TARGET :: h_mesh, phi_mesh, pmag_mesh
63  !---------------------------------------------------------------------------
64 
65  !Periodic structures--------------------------------------------------------
69  TYPE(periodic_type) :: vvz_per
73  !---------------------------------------------------------------------------
74 
75  !Coupling variables---------------------------------------------------------
76  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: v_to_max
77  REAL(KIND=8), ALLOCATABLE, DIMENSION(:,:,:) :: h_to_ns
78  REAL(KIND=8), ALLOCATABLE, DIMENSION(:,:,:) :: b_to_ns
79  !October 7, 2008, JLG
80  REAL(KIND=8), ALLOCATABLE, DIMENSION(:,:,:) :: t_to_ns
81  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: v_to_energy
82  REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: h_to_energy, pdt_h_to_energy
83  !---------------------------------------------------------------------------
84 
85  !Connectivity structures----------------------------------------------------
86  !October 7, 2008, JLG
87  INTEGER, ALLOCATABLE, DIMENSION(:) :: jj_v_to_h
88  INTEGER, ALLOCATABLE, DIMENSION(:) :: jj_v_to_temp
89  !---------------------------------------------------------------------------
90 
91  !Modes list-----------------------------------------------------------------
92  INTEGER, TARGET, ALLOCATABLE, DIMENSION(:) :: list_mode
93  INTEGER :: m_max_c
94  !---------------------------------------------------------------------------
95 
96  !Names already used---------------------------------------------------------
97  REAL(KIND=8) :: time
98  REAL(KIND=8) :: r_fourier
99  INTEGER :: index_fourier
100  !---------------------------------------------------------------------------
101 
102  !Communicators for Petsc, in space and Fourier------------------------------
103  mpi_comm :: comm_cart
104  mpi_comm, DIMENSION(:), POINTER :: comm_one_d, comm_one_d_ns, &
105  comm_one_d_temp, coord_cart
106  !---------------------------------------------------------------------------
107 
108  !-------------END OF DECLARATIONS------------------------------------------
109 CONTAINS
110  !---------------------------------------------------------------------------
111 
112  !---------------------------------------------------------------------------
113  SUBROUTINE initial(vv_mesh_out, pp_mesh_out, H_mesh_out, phi_mesh_out, temp_mesh_out, &
114  interface_h_phi_out, interface_h_mu_out, list_mode_out, &
115  un_out, pn_out, hn_out, bn_out, phin_out, v_to_max_out, &
116  vol_heat_capacity_field_out, temperature_diffusivity_field_out, &
117  mu_h_field_out, sigma_field_out, &
118  time_out, m_max_c_out, comm_one_d_out, comm_one_d_ns_out, comm_one_d_temp_out, &
119  tempn_out, level_set_out, density_out, der_un_out)
121 #include "petsc/finclude/petsc.h"
122  USE petsc
123  IMPLICIT NONE
124  TYPE(mesh_type), POINTER :: pp_mesh_out, vv_mesh_out
125  TYPE(mesh_type), POINTER :: H_mesh_out, phi_mesh_out
126  TYPE(mesh_type), POINTER :: temp_mesh_out
127  TYPE(dyn_real_array_three), POINTER, DIMENSION(:):: der_un_out
128  TYPE(interface_type), POINTER :: interface_H_mu_out, interface_H_phi_out
129  INTEGER, POINTER, DIMENSION(:) :: list_mode_out
130  REAL(KIND=8), POINTER, DIMENSION(:,:,:) :: un_out, pn_out, Hn_out, Bn_out, phin_out, v_to_Max_out, tempn_out, density_out
131  REAL(KIND=8), POINTER, DIMENSION(:,:,:,:):: level_set_out
132  REAL(KIND=8), POINTER, DIMENSION(:) :: sigma_field_out, mu_H_field_out
133  REAL(KIND=8), POINTER, DIMENSION(:) :: vol_heat_capacity_field_out, temperature_diffusivity_field_out
134  REAL(KIND=8) :: time_out
135  INTEGER :: m_max_c_out
136  mpi_comm, DIMENSION(:), POINTER :: comm_one_d_out, comm_one_d_ns_out, comm_one_d_temp_out
137 
138  CALL init
139 
140  !===Initialize meshes for vtu post processing
141  CALL sfemans_initialize_postprocessing(comm_one_d, vv_mesh, pp_mesh, h_mesh, phi_mesh, temp_mesh, &
142  list_mode, inputs%number_of_planes_in_real_space)
143 
144  vv_mesh_out => vv_mesh
145  pp_mesh_out => pp_mesh
146  h_mesh_out => h_mesh
147  phi_mesh_out => phi_mesh
148  temp_mesh_out => temp_mesh
149  interface_h_mu_out => interface_h_mu
150  interface_h_phi_out => interface_h_phi
151  list_mode_out => list_mode
152  un_out => un
153  der_un_out => der_un
154  pn_out => pn
155  tempn_out => tempn
156  level_set_out => level_set
157  density_out => density
158  hn_out => hn
159  bn_out => bn
160  phin_out => phin
161  v_to_max_out => v_to_max
162  vol_heat_capacity_field_out => vol_heat_capacity_field
163  temperature_diffusivity_field_out => temperature_diffusivity_field
164  mu_h_field_out => mu_h_field
165  sigma_field_out => sigma_field
166  time_out = time
167  m_max_c_out = m_max_c
168  comm_one_d_out => comm_one_d
169  comm_one_d_ns_out => comm_one_d_ns
170  comm_one_d_temp_out => comm_one_d_temp
171  END SUBROUTINE initial
172  !---------------------------------------------------------------------------
173 
174  !---------------------------------------------------------------------------
175  SUBROUTINE run_sfemans(time_in, it)
179  USE update_maxwell
181  USE input_data
182  IMPLICIT NONE
183  REAL(KIND=8), INTENT(in) :: time_in
184  REAL(KIND=8), DIMENSION(vv_mesh%np,2,SIZE(list_mode)) :: visco_dyn_m1
185  REAL(KIND=8), DIMENSION(vv_mesh%np,2,SIZE(list_mode)) :: one_over_sigma_ns
186  INTEGER :: it
187 
188  CALL zero_out_modes
189 
190  time = time_in
191 
192  IF (if_mass) THEN
193  CALL three_level_mass(comm_one_d_ns, time, pp_1_la, vv_1_la, list_mode, pp_mesh, vv_mesh, &
194  2*un-un_m1, max_vel, level_set_per, density_m2, density_m1, density, level_set_m1, level_set,&
196  CALL reconstruct_variable(comm_one_d_ns, list_mode, pp_mesh, vv_mesh, level_set_m1, &
197  inputs%dyna_visc_fluid, visco_dyn_m1)
198  IF (inputs%variation_sigma_fluid) THEN
199  CALL reconstruct_variable(comm_one_d_ns, list_mode, pp_mesh, vv_mesh, level_set, &
200  1.d0/inputs%sigma_fluid, one_over_sigma_ns)
201  ELSE
202  one_over_sigma_ns = 0.d0
203  END IF
204  END IF
205 
206  IF (if_energy) THEN
207  IF (if_momentum) THEN
209  END IF
210  IF (inputs%type_pb=='fhd') THEN
211  CALL projection_mag_field(vv_mesh, 2*hn-hn1, jj_v_to_h, .true., h_to_ns)
213  IF (.NOT. inputs%if_steady_current_fhd) THEN
214  CALL projection_mag_field(vv_mesh, (hn-hn1)/inputs%dt, jj_v_to_h, .true., h_to_ns)
216  END IF
217  END IF
218  CALL three_level_temperature(comm_one_d_temp, time, temp_1_la, inputs%dt, list_mode, &
221  inputs%my_par_temperature, inputs%temperature_list_dirichlet_sides, &
222  inputs%temperature_list_robin_sides, inputs%convection_coeff, &
223  inputs%exterior_temperature, temp_per) !===MODIFICATION: robin
224  END IF
225 
226  IF (if_momentum) THEN
227  IF (if_energy) THEN
228  CALL projection_temperature(vv_mesh, tempn, jj_v_to_temp, t_to_ns)
229  END IF
230  IF (if_induction) THEN
231  CALL projection_mag_field(vv_mesh, 2*hn-hn1, jj_v_to_h, .true., h_to_ns)
232  CALL projection_mag_field(vv_mesh, 2*bn-bn1, jj_v_to_h, .true., b_to_ns)
233  END IF
234  !===JLG July 20, 2019, p3 mesh
235  !===HF April 2019
236  IF (inputs%if_navier_stokes_with_taylor) THEN
237  CALL navier_stokes_taylor(comm_one_d_ns, time, vv_3_la, pp_1_la, &
238  list_mode, pp_mesh, vv_mesh, pn, der_pn, un, der_un, vvz_per, pp_per)
239 
240  ELSE
241  CALL navier_stokes_decouple(comm_one_d_ns,time, vv_3_la, pp_1_la, &
242  list_mode, pp_mesh, vv_mesh, incpn_m1, incpn, &
243  pn_m1, pn, un_m1, un, vvz_per, pp_per, h_to_ns, b_to_ns, &
244  density_m2, density_m1, density, visco_dyn_m1, t_to_ns, level_set_m1, level_set, &
246  END IF
247  !===HF April 2019
248  !===JLG July 20, 2019, p3 mesh
249  END IF
250 
251  IF (if_induction) THEN
252  IF (inputs%type_pb == 'fhd' .AND. inputs%if_steady_current_fhd) THEN !===If steady current, computation of H only once
253  IF (it == 1) THEN
254  IF (if_momentum) THEN
256  END IF
257  CALL maxwell_decouple(comm_one_d, h_mesh, pmag_mesh, phi_mesh, &
260  time, inputs%dt, inputs%Rem, list_mode, h_phi_per, la_h, la_pmag, la_phi, la_mhd, one_over_sigma_ns, jj_v_to_h)
261  hn1 = hn
262  bn1 = bn
263  phin1 = phin
264  END IF
265  ELSE
266  IF (if_momentum) THEN
268  END IF
269  CALL maxwell_decouple(comm_one_d, h_mesh, pmag_mesh, phi_mesh, &
272  time, inputs%dt, inputs%Rem, list_mode, h_phi_per, la_h, la_pmag, la_phi, la_mhd, one_over_sigma_ns, jj_v_to_h)
273  END IF
274  END IF
275 
276  END SUBROUTINE run_sfemans
277  !---------------------------------------------------------------------------
278 
279  !---------------------------------------------------------------------------
280  SUBROUTINE zero_out_modes
282  IMPLICIT NONE
283  LOGICAL, SAVE :: once_zero_out_mode=.true.
284  INTEGER, POINTER, DIMENSION(:), SAVE :: select_mode_ns, select_mode_mxw
285  INTEGER :: kp
286  IF (once_zero_out_mode) THEN
287  once_zero_out_mode=.false.
288  IF (inputs%if_zero_out_modes) THEN
289  CALL prepare_zero_out_modes(list_mode, inputs%list_select_mode_ns, select_mode_ns)
290  CALL prepare_zero_out_modes(list_mode, inputs%list_select_mode_mxw, select_mode_mxw)
291  END IF
292  END IF
293  IF (inputs%if_zero_out_modes) THEN
294  IF (h_mesh%me /=0 .AND. SIZE(select_mode_mxw)>0) THEN
295  hn(:,:,select_mode_mxw) = 0.d0
296  hn1(:,:,select_mode_mxw) = 0.d0
297  END IF
298  IF (phi_mesh%me /= 0 .AND. SIZE(select_mode_mxw)>0) THEN
299  phin(:,:,select_mode_mxw) = 0.d0
300  phin1(:,:,select_mode_mxw) = 0.d0
301  END IF
302  IF (vv_mesh%me /=0 .AND. SIZE(select_mode_ns)>0) THEN
303  un(:,:,select_mode_ns) = 0.d0
304  pn(:,:,select_mode_ns) = 0.d0
305  IF(inputs%if_navier_stokes_with_taylor) THEN
306  DO kp = 1, inputs%taylor_order-1
307  der_un(kp)%DRT( :,:,select_mode_ns) = 0.d0
308  der_pn(kp)%DRT( :,:,select_mode_ns) = 0.d0
309  END DO
310  ELSE
311  incpn(:,:,select_mode_ns) = 0.d0
312  un_m1(:,:,select_mode_ns) = 0.d0
313  pn_m1(:,:,select_mode_ns) = 0.d0
314  incpn_m1(:,:,select_mode_ns) = 0.d0
315  END IF
316  END IF
317  END IF
318  END SUBROUTINE zero_out_modes
319  !---------------------------------------------------------------------------
320 
321  !---------------------------------------------------------------------------
322  SUBROUTINE prepare_zero_out_modes(list_mode, list_mode_to_zero_out, select_mode)
324  IMPLICIT NONE
325  INTEGER, DIMENSION(:), INTENT(IN) :: list_mode_to_zero_out
326  INTEGER, DIMENSION(:) :: list_mode
327  INTEGER, POINTER, DIMENSION(:) :: select_mode
328  INTEGER :: i, inc
329  INTEGER, DIMENSION(1) :: kloc
330  inc = 0
331  DO i = 1, SIZE(list_mode_to_zero_out)
332  IF (minval(abs(list_mode-list_mode_to_zero_out(i)))==0) THEN
333  inc = inc + 1
334  END IF
335  END DO
336  ALLOCATE(select_mode(inc))
337  inc = 0
338  DO i = 1, SIZE(list_mode_to_zero_out)
339  IF (minval(abs(list_mode-list_mode_to_zero_out(i)))==0) THEN
340  inc = inc + 1
341  kloc = minloc(abs(list_mode-list_mode_to_zero_out(i)))
342  select_mode(inc) = kloc(1)
343  END IF
344  END DO
345  END SUBROUTINE prepare_zero_out_modes
346  !---------------------------------------------------------------------------
347 
348  !---------------------------------------------------------------------------
349  SUBROUTINE projection_velocity(mesh, vn, connectivity_structure, coupling_variable)
351  IMPLICIT NONE
352  TYPE(mesh_type), INTENT(IN) :: mesh
353  REAL(KIND=8), DIMENSION(:,:,:), INTENT(IN) :: vn
354  INTEGER, DIMENSION(:), INTENT(IN) :: connectivity_structure
355  REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT) :: coupling_variable
356  INTEGER :: i, j, k
357 
358  IF (mesh%np>0) THEN !===Check that ns is a subset of temp before constructing the extended vv field
359  DO i = 1, m_max_c
360  DO k= 1, 6 !===The user has to code extension_vel
361  coupling_variable(:,k,i) = extension_velocity(k, mesh, list_mode(i), time, 1)
362  END DO
363  END DO
364  END IF
365  IF (mesh%me /=0) THEN !===construction of the extended field
366  DO j = 1, SIZE(connectivity_structure)
367  IF (connectivity_structure(j) == -1) cycle
368  coupling_variable(j,:,:) = vn(connectivity_structure(j),:,:)
369  END DO
370  END IF
371  END SUBROUTINE projection_velocity
372  !---------------------------------------------------------------------------
373 
374  !---------------------------------------------------------------------------
375  SUBROUTINE projection_temperature(mesh, vn, connectivity_structure, coupling_variable) !===projection of temp on another mesh subroutine added
376  IMPLICIT NONE
377  TYPE(mesh_type), INTENT(IN) :: mesh
378  REAL(KIND=8), DIMENSION(:,:,:), INTENT(IN) :: vn
379  INTEGER, DIMENSION(:), INTENT(IN) :: connectivity_structure
380  REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT) :: coupling_variable
381  INTEGER :: j
382 
383  IF (mesh%me /=0 ) THEN !===construction of the restricted temperature field
384  DO j = 1, SIZE(connectivity_structure)
385  IF (connectivity_structure(j) == -1) cycle
386  coupling_variable(connectivity_structure(j),:,:) = vn(j,:,:)
387  END DO
388  END IF
389  END SUBROUTINE projection_temperature
390  !---------------------------------------------------------------------------
391 
392  !---------------------------------------------------------------------------
393  SUBROUTINE projection_mag_field(mesh, vn, connectivity_structure, if_restriction, coupling_variable) !===projection of mag field on another mesh subroutine added
395  IMPLICIT NONE
396  TYPE(mesh_type), INTENT(IN) :: mesh
397  REAL(KIND=8), DIMENSION(:,:,:), INTENT(IN) :: vn
398  INTEGER, DIMENSION(:), INTENT(IN) :: connectivity_structure
399  LOGICAL, INTENT(IN) :: if_restriction
400  REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT) :: coupling_variable
401  INTEGER :: j, m
402 
403  DO j = 1, SIZE(connectivity_structure)
404  IF (connectivity_structure(j) == -1) cycle
405  IF (if_restriction) THEN
406  coupling_variable(connectivity_structure(j),:,:) = vn(j,:,:)
407  ELSE
408  coupling_variable(j,:,:) = vn(connectivity_structure(j),:,:)
409  END IF
410  END DO
411  IF (if_restriction) THEN
412  IF (h_mesh%gauss%n_w/=mesh%gauss%n_w) THEN
413  DO m = 1, mesh%me
414  coupling_variable(mesh%jj(4,m),:,:) = (coupling_variable(mesh%jj(2,m),:,:) &
415  + coupling_variable(mesh%jj(3,m),:,:))/2
416  coupling_variable(mesh%jj(5,m),:,:) = (coupling_variable(mesh%jj(3,m),:,:) &
417  + coupling_variable(mesh%jj(1,m),:,:))/2
418  coupling_variable(mesh%jj(6,m),:,:) = (coupling_variable(mesh%jj(1,m),:,:) &
419  + coupling_variable(mesh%jj(2,m),:,:))/2
420  END DO
421  END IF
422  END IF
423 
424  END SUBROUTINE projection_mag_field
425  !---------------------------------------------------------------------------
426 
427  !----------------SAVE RUN---------------------------------------------------
428  SUBROUTINE save_run(it, freq_restart)
430  IMPLICIT NONE
431  INTEGER, INTENT(IN) :: it, freq_restart
432 
433  IF (if_momentum) THEN
434  IF (pp_mesh%me /= 0) THEN
435  IF(inputs%if_navier_stokes_with_taylor) THEN
436  CALL write_restart_ns_taylor(comm_one_d_ns, vv_mesh, pp_mesh, time, &
437  list_mode, un, der_un, pn, der_pn, inputs%file_name, it, freq_restart)
438  ELSE
439  IF (.NOT. if_mass) THEN
440  CALL write_restart_ns(comm_one_d_ns, vv_mesh, pp_mesh, time, &
441  list_mode, un, un_m1, pn, pn_m1, &
442  incpn, incpn_m1, inputs%file_name, it, freq_restart)
443  ELSE
444  CALL write_restart_ns(comm_one_d_ns, vv_mesh, pp_mesh, time, &
445  list_mode, un, un_m1, pn, pn_m1, &
446  incpn, incpn_m1, inputs%file_name, it, freq_restart, &
447  opt_level_set=level_set, opt_level_set_m1=level_set_m1,opt_max_vel=max_vel)
448  END IF
449  END IF
450  END IF
451  END IF
452 
453  IF (if_induction) THEN
454  CALL write_restart_maxwell(comm_one_d, h_mesh, phi_mesh, &
455  time, list_mode, hn, hn1, bn, bn1, &
456  phin, phin1, inputs%file_name, it, freq_restart)
457  END IF
458 
459  IF (if_energy) THEN
460  CALL write_restart_temp(comm_one_d_temp, temp_mesh, time, &
461  list_mode, tempn, tempn_m1, inputs%file_name, it, freq_restart)
462  END IF
463 
464  END SUBROUTINE save_run
465  !---------------------------------------------------------------------------
466 
467  SUBROUTINE init
468  !==================
469  USE my_util
470  USE chaine_caractere
471  USE periodic
472  USE prep_maill
474  USE restart
475  USE boundary
476  USE sub_plot
477  USE def_type_mesh
478  USE create_comm
479  USE metis_sfemans
480  !===JLG July 20, 2019, p3 mesh
482  !===JLG July 20, 2019, p3 mesh
483  USE st_matrix
484  USE st_csr_mhd
485  USE matrix_type
486  USE symmetric_field
487  USE tn_axi
489  USE subroutine_mass
490  USE sft_parallele
492 #include "petsc/finclude/petsc.h"
493  USE petsc
494  IMPLICIT NONE
495  TYPE(mesh_type) :: vv_mesh_glob, pp_mesh_glob
496  TYPE(mesh_type) :: H_mesh_glob, phi_mesh_glob, pmag_mesh_glob, temp_mesh_glob
497  TYPE(mesh_type) :: p1_mesh_glob, p2_mesh_glob, p1_c0_mesh_glob, p2_c0_mesh_glob_temp
498  TYPE(mesh_type) :: p3_mesh_glob !===JLG july 20, 2019, p3 mesh
499  TYPE(interface_type) :: interface_H_phi_glob, interface_H_mu_glob
500  INTEGER, DIMENSION(:), ALLOCATABLE :: list_dom_H, list_dom_temp
501  INTEGER, DIMENSION(:), ALLOCATABLE :: list_dom, list_inter, part, list_dummy, list_inter_temp
502  INTEGER, DIMENSION(:), ALLOCATABLE :: H_in_to_new, temp_in_to_new
503  CHARACTER(len=200) :: data_file
504  CHARACTER(len=200) :: data_directory
505  CHARACTER(len=200) :: tit_part, mesh_part_name
506  CHARACTER(len=200) :: data_fichier
507  INTEGER :: nsize
508  INTEGER :: k, kp, m, n, i, j
509  INTEGER :: code, rank, rank_S, nb_procs, petsc_rank, bloc_size, m_max_pad
510  REAL(KIND=8) :: time_u, time_h, time_T, error, max_vel_S
511  LOGICAL :: ns_periodic, mxw_periodic, temp_periodic
512  CHARACTER(len=2) :: tit
513  petscmpiint :: nb_procs_f, nb_procs_s
514 
515  !===Get numbers of processors===================================================
516  CALL mpi_comm_size(petsc_comm_world,nb_procs,code)
517  CALL mpi_comm_rank(petsc_comm_world,petsc_rank,code)
518 
519  !===Decide whether debugging or not=============================================
520  CALL sfemansinitialize
521  IF (inputs%test_de_convergence) THEN
522  IF (inputs%numero_du_test_debug<1 .OR. inputs%numero_du_test_debug>40) THEN
523  CALL error_petsc('BUG in INIT: debug_test_number is not in the correct range')
524  END IF
525  WRITE(tit,'(i2)') inputs%numero_du_test_debug
526  data_file = 'data_'//trim(adjustl(tit))
527  data_directory = inputs%data_directory_debug
528  data_fichier = trim(adjustl(data_directory))//'/debug_'//trim(adjustl(data_file))
529  ELSE
530  data_directory = '.'
531  data_file='data'
532  data_fichier = trim(adjustl(data_directory))//'/'//trim(adjustl(data_file))
533  END IF
534 
535  !===Assign correct user functions in boundary module
536  call assign_boundary
537 
538  !===Read data file==============================================================
539  CALL read_my_data(data_fichier)
540 
541  !===Debugging===================================================================
542  IF (inputs%test_de_convergence) THEN
543  inputs%directory = data_directory
544  END IF
545 
546  !===Initialization for empty vacuum=============================================
547  IF (inputs%nb_dom_phi==0) THEN
548  inputs%phi_nb_dirichlet_sides = 0
549  inputs%nb_inter = 0
550  inputs%mu_phi = 1.d0
551  inputs%type_fe_phi = -1
552  inputs%stab(2) = 0.d0
553  IF (ASSOCIATED(inputs%phi_list_dirichlet_sides)) DEALLOCATE(inputs%phi_list_dirichlet_sides)
554  ALLOCATE(inputs%phi_list_dirichlet_sides(0))
555  IF (ASSOCIATED(inputs%list_inter_H_phi)) DEALLOCATE(inputs%list_inter_H_phi)
556  ALLOCATE(inputs%list_inter_H_phi(0))
557  END IF
558 
559  !===Control inputs==============================================================
560  nb_procs_s = inputs%ndim(1)
561  nb_procs_f = inputs%ndim(2)
562  IF (inputs%ndim(1)*inputs%ndim(2)/=nb_procs) THEN
563  CALL error_petsc('BUG in INIT, nb_proc_space*nb_proc_fourier/=nb_procs')
564  END IF
565 
566  !===Create communicators========================================================
567  CALL create_cart_comm(inputs%ndim,comm_cart,comm_one_d,coord_cart)
568  CALL mpi_comm_size(comm_one_d(2),nb_procs,code)
569  CALL mpi_comm_rank(comm_one_d(2),rank,code)
570  IF (nb_procs_f/=nb_procs) THEN
571  CALL error_petsc('BUG in INIT, nb_procs_F/=nb_procs')
572  END IF
573 
574  !===Sort out fourier modes======================================================
575  m_max_c = inputs%m_max/nb_procs_f
576  ALLOCATE(list_mode(m_max_c))
577  IF (m_max_c==0) THEN
578  CALL error_petsc('BUG in INIT, m_max_c==0')
579  END IF
580  IF (inputs%select_mode) THEN
581  DO i = 1, m_max_c
582  list_mode(i) = inputs%list_mode_lect(i + rank*m_max_c)
583  END DO
584  ELSE
585  DO i = 1, m_max_c
586  list_mode(i) = i + rank*m_max_c - 1
587  END DO
588  END IF
589 
590  !===Check periodicity===========================================================
591  IF (inputs%my_periodic%nb_periodic_pairs< 1) THEN
592  ns_periodic=.false.; mxw_periodic=.false.; temp_periodic = .false.
593  vvrtz_per%n_bord = 0; vvrt_per%n_bord = 0; vvz_per%n_bord = 0; pp_per%n_bord = 0
594  h_phi_per%n_bord = 0 ; temp_per%n_bord = 0
595  level_set_per%n_bord = 0
596  ELSE
597  ns_periodic=.true.; mxw_periodic=.true.; temp_periodic=.true.
598  END IF
599 
600  !===Creation of logicals for equations==========================================
601  if_mass = inputs%if_level_set
602  if_momentum = inputs%type_pb=='nst' .OR. inputs%type_pb=='mhd' .OR. inputs%type_pb=='fhd'
603  if_induction = inputs%type_pb=='mxw' .OR. inputs%type_pb=='mhd' .OR. inputs%type_pb=='mxx' .OR. inputs%type_pb=='fhd'
604  if_energy = inputs%if_temperature
605  !===JLG july 20, 2019, p3 mesh
606  IF (inputs%if_navier_stokes_with_taylor) THEN
607  IF (petsc_rank==0) WRITE(*,*) 'INIT: Everything that is not Navier-Stokes is disabled, for Taylor Method'
608  if_mass = .false. !===Disable everything that is not NS, for the time being
609  if_momentum = inputs%type_pb=='nst'
610  if_induction = .false.
611  if_energy = .false.
612  END IF
613 
614  !===Check mesh that vv_mesh is a subset of H_mesh===============================
615  IF (if_induction) THEN
616  ALLOCATE(list_dom_h(inputs%nb_dom_H), h_in_to_new(inputs%nb_dom_H)) ! JLG/AR Nov 17 2008
617  IF (if_momentum .OR. inputs%type_pb=='mxx') THEN
618  IF (SIZE(list_dom_h) < SIZE(inputs%list_dom_ns)) THEN
619  CALL error_petsc(' BUG: NS must be a subset of Maxwell ')
620  END IF
621  DO k = 1, inputs%nb_dom_ns
622  IF (minval(abs(inputs%list_dom_H - inputs%list_dom_ns(k))) /= 0) THEN
623  CALL error_petsc(' BUG: NS must be a subset of Maxwell ')
624  END IF
625  DO kp = 1, inputs%nb_dom_H
626  IF (inputs%list_dom_H(kp) == inputs%list_dom_ns(k)) EXIT
627  END DO
628  h_in_to_new(k) = kp
629  list_dom_h(k) = inputs%list_dom_ns(k)
630  END DO
631  m = inputs%nb_dom_ns
632  DO k = 1, inputs%nb_dom_H
633  IF (minval(abs(inputs%list_dom_H(k) - inputs%list_dom_ns)) == 0) cycle
634  m = m + 1
635  h_in_to_new(m) = k
636  list_dom_h(m) = inputs%list_dom_H(k)
637  END DO
638  IF (m/=inputs%nb_dom_H) THEN
639  CALL error_petsc(' BUG: m/=inputs%nb_dom_H ')
640  END IF
641  ELSE
642  DO k = 1, inputs%nb_dom_H
643  h_in_to_new(k) = k
644  END DO
645  list_dom_h = inputs%list_dom_H
646  END IF
647  ELSE
648  ALLOCATE(h_in_to_new(0))
649  END IF
650 
651  !===Check mesh that vv_mesh is a subset of temp_mesh============================
652  IF (if_energy) THEN
653  ALLOCATE(list_dom_temp(inputs%nb_dom_temp), temp_in_to_new(inputs%nb_dom_temp))
654  IF (SIZE(list_dom_temp) < SIZE(inputs%list_dom_ns)) THEN
655  CALL error_petsc(' BUG: NS must be a subset of temp ')
656  END IF
657  DO k = 1, inputs%nb_dom_ns
658  IF (minval(abs(inputs%list_dom_temp - inputs%list_dom_ns(k))) /= 0) THEN
659  CALL error_petsc(' BUG: NS must be a subset of temp ')
660  END IF
661  DO kp = 1, inputs%nb_dom_temp
662  IF (inputs%list_dom_temp(kp) == inputs%list_dom_ns(k)) EXIT
663  END DO
664  temp_in_to_new(k) = kp
665  list_dom_temp(k) = inputs%list_dom_ns(k)
666  END DO
667  m = inputs%nb_dom_ns
668  DO k = 1, inputs%nb_dom_temp
669  IF (minval(abs(inputs%list_dom_temp(k) - inputs%list_dom_ns)) == 0) cycle
670  m = m + 1
671  temp_in_to_new(m) = k
672  list_dom_temp(m) = inputs%list_dom_temp(k)
673  END DO
674  IF (m/=inputs%nb_dom_temp) THEN
675  CALL error_petsc(' BUG: m/=inputs%nb_dom_temp ')
676  END IF
677  ELSE
678  ALLOCATE(temp_in_to_new(0))
679  END IF
680 
681  !===Check mesh that temp_mesh is a subset of H_mesh=============================
682  IF ((if_energy).AND.(if_induction)) THEN
683  IF (SIZE(list_dom_h) < SIZE(list_dom_temp)) THEN
684  CALL error_petsc(' BUG: temp must be a subset of H ')
685  END IF
686  DO k = 1, inputs%nb_dom_temp
687  IF (minval(abs(list_dom_h - list_dom_temp(k))) /= 0) THEN
688  CALL error_petsc(' BUG: temp must be a subset of H ')
689  END IF
690  END DO
691  END IF
692 
693  !===Create interfaces in meshes=================================================
694  IF (if_momentum .AND. (.NOT. if_induction)) THEN
695  IF (if_energy) THEN
696  nsize = SIZE(list_dom_temp)
697  ALLOCATE(list_dom(nsize))
698  list_dom = list_dom_temp
699  ALLOCATE(list_inter(SIZE(inputs%list_inter_v_T)))
700  list_inter = inputs%list_inter_v_T
701  ELSE
702  nsize = SIZE(inputs%list_dom_ns)
703  ALLOCATE(list_dom(nsize))
704  list_dom = inputs%list_dom_ns
705  ALLOCATE(list_inter(0))
706  END IF
707  ELSE
708  nsize = SIZE(list_dom_h)+SIZE(inputs%list_dom_phi)
709  ALLOCATE(list_dom(nsize))
710  list_dom(1:SIZE(list_dom_h)) = list_dom_h
711  IF (SIZE(inputs%list_dom_phi)>0) THEN
712  list_dom(SIZE(list_dom_h)+1:) = inputs%list_dom_phi
713  END IF
714  nsize = SIZE(inputs%list_inter_mu)+SIZE(inputs%list_inter_H_phi)
715  ALLOCATE(list_inter(nsize))
716  IF (SIZE(inputs%list_inter_mu)>0) THEN
717  list_inter(1:SIZE(inputs%list_inter_mu)) = inputs%list_inter_mu
718  END IF
719  IF (SIZE(inputs%list_inter_H_phi)>0) THEN
720  list_inter(SIZE(inputs%list_inter_mu)+1:) = inputs%list_inter_H_phi
721  END IF
722  END IF
723  IF (if_energy) THEN
724  ALLOCATE(list_inter_temp(0))
725  END IF
726 
727  !===Create meshes===============================================================
728  CALL load_dg_mesh_free_format(inputs%directory, inputs%file_name, list_dom, &
729  list_inter, 1, p1_mesh_glob, inputs%iformatted)
730  CALL load_dg_mesh_free_format(inputs%directory, inputs%file_name, list_dom, &
731  list_inter, 2, p2_mesh_glob, inputs%iformatted)
732  !===JLG july 20, 2019, p3 mesh
733  IF (inputs%type_fe_velocity==3) THEN
734  CALL create_p3_mesh(p1_mesh_glob, p2_mesh_glob, p3_mesh_glob, 3)
735  END IF
736  !===JLG july 20, 2019, p3 mesh
737  IF (if_energy) THEN
738  !===MODIFICATION: Dirichlet nodes in temp_mesh not created if list_dom > list_dom_temp
739  CALL load_dg_mesh_free_format(inputs%directory, inputs%file_name, list_dom_temp, &
740  list_inter_temp, 2, p2_c0_mesh_glob_temp, inputs%iformatted)
741  END IF
742  IF (if_induction) THEN
743  ALLOCATE(list_dummy(0))
744  CALL load_dg_mesh_free_format(inputs%directory, inputs%file_name, list_dom, &
745  inputs%list_inter_H_phi, 1, p1_c0_mesh_glob, inputs%iformatted)
746  END IF
747 
748  !===Start Metis mesh generation=================================================
749  ALLOCATE(part(p1_mesh_glob%me))
750  WRITE(tit_part,'(i4)') inputs%ndim(1)
751  mesh_part_name='mesh_part_S'//trim(adjustl(tit_part))//'.'//trim(adjustl(inputs%file_name))
752  IF (inputs%if_read_partition) THEN
753  OPEN(unit=51, file=mesh_part_name, status='unknown', form='formatted')
754  READ(51,*) part
755  CLOSE(51)
756  WRITE(*,*) 'read partition'
757  ELSE
758  WRITE(*,*) 'create partition'
759  CALL part_mesh_m_t_h_phi(nb_procs_s, inputs%list_dom_ns, inputs%list_dom_temp, inputs%list_dom_H, &
760  inputs%list_dom_phi, p1_mesh_glob,list_inter,part, inputs%my_periodic)
761  IF (petsc_rank==0) THEN
762  OPEN(unit=51, file=mesh_part_name, status='replace', form='formatted')
763  WRITE(51,*) part
764  CLOSE(51)
765  END IF
766  END IF
767 
768  !===Extract local meshes from global meshes=====================================
769  !===Specific to momentum (velocity)
770  IF (if_momentum .OR. inputs%type_pb=='mxx') THEN
771  IF (inputs%type_fe_velocity==2) THEN !===JLG july 20, 2019, p3 mesh
772  CALL extract_mesh(comm_one_d(1),nb_procs_s,p1_mesh_glob,part,inputs%list_dom_ns,pp_mesh_glob,pp_mesh)
773  CALL extract_mesh(comm_one_d(1),nb_procs_s,p2_mesh_glob,part,inputs%list_dom_ns,vv_mesh_glob,vv_mesh)
774  ELSE IF (inputs%type_fe_velocity==3) THEN
775  CALL extract_mesh(comm_one_d(1),nb_procs_s,p2_mesh_glob,part,inputs%list_dom_ns,pp_mesh_glob,pp_mesh)
776  CALL extract_mesh(comm_one_d(1),nb_procs_s,p3_mesh_glob,part,inputs%list_dom_ns,vv_mesh_glob,vv_mesh)
777  ELSE
778  CALL error_petsc('Bug in INIT, inputs%type_fe_velocity not correct')
779  END IF
780  !===JLG july 20, 2019, p3 mesh
781  !===Use increasing vertex index enumeration
782  !CALL incr_vrtx_indx_enumeration(vv_mesh,inputs%type_fe_velocity)
783  !CALL incr_vrtx_indx_enumeration(pp_mesh,inputs%type_fe_velocity-1)
784  !===JLG july 20, 2019, p3 mesh
785  ALLOCATE(comm_one_d_ns(2))
786  CALL mpi_comm_dup(comm_one_d(2), comm_one_d_ns(2), code)
787  !Correction FL-ID, 4/4/13
788  CALL mpi_comm_rank(comm_one_d(1),rank_s,code)
789  IF (pp_mesh%me/=0) THEN
790  CALL mpi_comm_split (comm_one_d(1),1,rank_s,comm_one_d_ns(1),code)
791  ELSE
792  CALL mpi_comm_split (comm_one_d(1),mpi_undefined,rank_s,comm_one_d_ns(1),code)
793  END IF
794 
795  !===Test whether pp_mesh and vv_mesh meshes coincide=========================
796  DO m = 1, vv_mesh%me
797  DO n = 1, 3
798  IF (minval(abs(vv_mesh%rr(1,vv_mesh%jj(n,m)) &
799  -pp_mesh%rr(1,pp_mesh%jj(:,m))))>1.d-16 &
800  .OR. minval(abs(vv_mesh%rr(2,vv_mesh%jj(n,m))&
801  -pp_mesh%rr(2,pp_mesh%jj(:,m))))>1.d-16) THEN
802  CALL error_petsc('BUG in INIT, vv and pp global meshes are different')
803  END IF
804  END DO
805  END DO
806 
807  !===Create periodic structures===============================================
808  IF (ns_periodic) THEN
809  CALL prep_periodic(inputs%my_periodic, pp_mesh, pp_per)
810  CALL prep_periodic(inputs%my_periodic, vv_mesh, vvz_per)
811  CALL prep_periodic_bloc(inputs%my_periodic, vv_mesh, vvrt_per, 2)
812  CALL prep_periodic_bloc(inputs%my_periodic, vv_mesh, vvrtz_per, 3)
813  IF (inputs%if_level_set_P2) THEN
814  CALL prep_periodic(inputs%my_periodic, vv_mesh, level_set_per)
815  ELSE
816  CALL prep_periodic(inputs%my_periodic, pp_mesh, level_set_per)
817  END IF
818  END IF
819 
820  !===Create global csr structure==============================================
821  IF (pp_mesh%me/=0) THEN
822  CALL st_aij_csr_glob_block(comm_one_d_ns(1),1,vv_mesh_glob,vv_mesh,vv_1_la, opt_per=vvz_per)
823  CALL st_aij_csr_glob_block(comm_one_d_ns(1),3,vv_mesh_glob,vv_mesh,vv_3_la, opt_per=vvrtz_per)
824  CALL st_aij_csr_glob_block(comm_one_d_ns(1),1,pp_mesh_glob,pp_mesh,pp_1_la, opt_per=pp_per)
825  !===Prepare csr structure for post processing curl_u==========================
826  CALL st_aij_csr_glob_block(comm_one_d_ns(1),1,vv_mesh_glob,vv_mesh,vizu_rot_u_la)
827  END IF
828 
829  !===Create symmetric points==================================================
830  IF (inputs%is_mesh_symmetric) THEN
831  ALLOCATE(vv_mz_la(vv_mesh%np))
832  CALL symmetric_points(vv_mesh, vv_mesh_glob, vv_mz_la)
833  END IF
834 
835  !===Deallocate global meshes=================================================
836  CALL free_mesh(vv_mesh_glob)
837  CALL free_mesh(pp_mesh_glob)
838 
839  !===Start Gauss points generation============================================
840  !===JLG july 20, 2019, p3 mesh
841  vv_mesh%edge_stab=.false.
842  pp_mesh%edge_stab=.false.
843  CALL gauss_points_2d(vv_mesh,inputs%type_fe_velocity)
844  CALL gauss_points_2d(pp_mesh,inputs%type_fe_velocity-1)
845  !===JLG july 20, 2019, p3 mesh
846  END IF !=== (if_momentum .OR. inputs%type_pb=='mxx')
847 
848  !===Extract local meshes from global meshes for Maxwell=========================
849  IF (if_induction) THEN
850  CALL extract_mesh(comm_one_d(1),nb_procs_s,p1_c0_mesh_glob,part,list_dom_h,pmag_mesh_glob,pmag_mesh)
851  IF (inputs%type_fe_H==1) THEN
852  CALL extract_mesh(comm_one_d(1),nb_procs_s,p1_mesh_glob,part,list_dom_h,h_mesh_glob,h_mesh)
853  ELSE
854  CALL extract_mesh(comm_one_d(1),nb_procs_s,p2_mesh_glob,part,list_dom_h,h_mesh_glob,h_mesh)
855  END IF
856  IF (inputs%type_fe_phi==1) THEN
857  CALL extract_mesh(comm_one_d(1),nb_procs_s,p1_mesh_glob,part,inputs%list_dom_phi,phi_mesh_glob,phi_mesh)
858  ELSE
859  CALL extract_mesh(comm_one_d(1),nb_procs_s,p2_mesh_glob,part,inputs%list_dom_phi,phi_mesh_glob,phi_mesh)
860  END IF
861  !===JLG july 20, 2019, p3 mesh
862  !===Use increasing vertex index enumeration
863  !CALL incr_vrtx_indx_enumeration(pmag_mesh,1)
864  !CALL incr_vrtx_indx_enumeration(H_mesh,inputs%type_fe_H)
865  !CALL incr_vrtx_indx_enumeration(phi_mesh,inputs%type_fe_phi)
866  !===JLG july 20, 2019, p3 mesh
867  END IF
868 
869  !===Extract local meshes from global meshes for temperature=====================
870  IF (if_energy) THEN
871  CALL extract_mesh(comm_one_d(1),nb_procs_s,p2_c0_mesh_glob_temp,part,list_dom_temp,temp_mesh_glob,temp_mesh)
872  ALLOCATE(comm_one_d_temp(2))
873  CALL mpi_comm_dup(comm_one_d(2), comm_one_d_temp(2), code)
874  CALL mpi_comm_rank(comm_one_d(1),rank_s,code)
875  IF (temp_mesh%me/=0) THEN
876  CALL mpi_comm_split (comm_one_d(1),1,rank_s,comm_one_d_temp(1),code)
877  ELSE
878  CALL mpi_comm_split (comm_one_d(1),mpi_undefined,rank_s,comm_one_d_temp(1),code)
879  END IF
880  END IF
881 
882  !===Deallocate global meshes====================================================
883  CALL free_mesh(p1_mesh_glob)
884  CALL free_mesh(p2_mesh_glob)
885  !===JLG July 20, 2019, p3 mesh
886  IF (inputs%type_fe_velocity==3) THEN
887  CALL free_mesh(p3_mesh_glob)
888  END IF
889  !===JLG July 20, 2019, p3 mesh
890  IF (if_induction) THEN
891  DEALLOCATE(list_dummy)
892  CALL free_mesh(p1_c0_mesh_glob)
893  END IF
894  IF (if_energy) THEN
895  DEALLOCATE(list_inter_temp)
896  CALL free_mesh(p2_c0_mesh_glob_temp)
897  END IF
898 
899  !===Specific to induction equation==============================================
900  IF (if_induction) THEN
901 
902  !===Verify that pmag_mesh and H_mesh coincide================================
903  IF (pmag_mesh%me/=0) THEN
904  error = 0.d0
905  DO k = 1, 2
906  DO n = 1, SIZE(pmag_mesh%jj,1)
907  error = error + maxval(abs(pmag_mesh%rr(k,pmag_mesh%jj(n,:))-h_mesh%rr(k,h_mesh%jj(n,1:pmag_mesh%me))))
908  END DO
909  END DO
910  IF (error/maxval(abs(h_mesh%rr(1,1) -h_mesh%rr(1,:))) .GE. 5.d-14) THEN
911  CALL error_petsc(.GE.'BUG in INIT, (error/MAXVAL(ABS(H_mesh%rr(1,1) -H_mesh%rr(1,:))) 5.d-14')
912  END IF
913  END IF
914 
915  !===Verify if the two meshes coincide on the NS domain=======================
916  IF (if_momentum .OR. inputs%type_pb=='mxx') THEN
917  IF (vv_mesh%me/=0) THEN
918  error = 0.d0
919  DO k = 1, 2
920  DO n = 1, SIZE(h_mesh%jj,1)
921  error = error + maxval(abs(vv_mesh%rr(k,vv_mesh%jj(n,:))-h_mesh%rr(k,h_mesh%jj(n,1:vv_mesh%me))))
922  END DO
923  END DO
924  IF (error/maxval(abs(h_mesh%rr(1,1) -h_mesh%rr(1,:))) .GE. 5.d-14) THEN
925  CALL error_petsc(.GE.'BUG in INIT, (error/MAXVAL(ABS(H_mesh%rr(1,1) -H_mesh%rr(1,:))) 5.d-14')
926  END IF
927 
928  error = error + maxval(abs(vv_mesh%rr(1,vv_mesh%jj(4,1:vv_mesh%me)) &
929  -(h_mesh%rr(1,h_mesh%jj(2,1:vv_mesh%me))+h_mesh%rr(1,h_mesh%jj(3,1:vv_mesh%me)))/2))&
930  + maxval(abs(vv_mesh%rr(1,vv_mesh%jj(5,:)) &
931  -(h_mesh%rr(1,h_mesh%jj(3,1:vv_mesh%me))+h_mesh%rr(1,h_mesh%jj(1,1:vv_mesh%me)))/2))&
932  + maxval(abs(vv_mesh%rr(1,vv_mesh%jj(6,:)) &
933  -(h_mesh%rr(1,h_mesh%jj(1,1:vv_mesh%me))+h_mesh%rr(1,h_mesh%jj(2,1:vv_mesh%me)))/2))&
934  + maxval(abs(vv_mesh%rr(2,vv_mesh%jj(4,:)) &
935  -(h_mesh%rr(2,h_mesh%jj(2,1:vv_mesh%me))+h_mesh%rr(2,h_mesh%jj(3,1:vv_mesh%me)))/2))&
936  + maxval(abs(vv_mesh%rr(2,vv_mesh%jj(5,:)) &
937  -(h_mesh%rr(2,h_mesh%jj(3,1:vv_mesh%me))+h_mesh%rr(2,h_mesh%jj(1,1:vv_mesh%me)))/2))&
938  + maxval(abs(vv_mesh%rr(2,vv_mesh%jj(6,:)) &
939  -(h_mesh%rr(2,h_mesh%jj(1,1:vv_mesh%me))+h_mesh%rr(2,h_mesh%jj(2,1:vv_mesh%me)))/2))
940  IF (error/maxval(abs(h_mesh%rr(1,1) -h_mesh%rr(1,:))) .GE. 5.d-14) THEN
941  WRITE(*,*) ' WARNING: vv_mesh and H_mesh do not coincide on the NS domain.'
942  WRITE(*,*) ' WARNING: Either you use curved elements P2 elements or BUG, ', &
943  error/maxval(abs(h_mesh%rr(1,1) -h_mesh%rr(1,:)))
944  END IF
945 
946  error=0.d0
947  DO k = 1, vv_mesh%me
948  DO n = 1, 2
949  error = error+ maxval(abs(vv_mesh%rr(n,vv_mesh%jj(1:3,k))-h_mesh%rr(n,h_mesh%jj(1:3,k))))
950  END DO
951  END DO
952  IF (error/maxval(abs(h_mesh%rr(1,1) -h_mesh%rr(1,:))) .GE. 5.d-14) THEN
953  CALL error_petsc('vv_mesh and H_mesh do NOT have the same P1 nodes')
954  END IF
955 
956  END IF
957  END IF
958 
959  !===Create interface structures==============================================
960  CALL load_interface(h_mesh_glob, h_mesh_glob, inputs%list_inter_mu, interface_h_mu_glob, .false.)
961  CALL load_interface(h_mesh_glob, phi_mesh_glob, inputs%list_inter_H_phi, interface_h_phi_glob, .true.)
962 
963  IF (h_mesh%me /=0) THEN
964  CALL load_interface(h_mesh, h_mesh, inputs%list_inter_mu, interface_h_mu, .false.)
965  ELSE
966  interface_h_mu%mes = 0
967  END IF
968 
969  IF (h_mesh%me * phi_mesh%me /=0) THEN
970  CALL load_interface(h_mesh, phi_mesh, inputs%list_inter_H_phi, interface_h_phi, .true.)
971  ELSE
972  interface_h_phi%mes = 0
973  END IF
974  !===JLG july 20, 2019, p3 mesh
975  !===Use increasing vertex index enumeration
976  !CALL incr_vrtx_indx_enumeration_for_interfaces(interface_H_phi,inputs%type_fe_H+1,inputs%type_fe_phi+1)
977  !===JLG july 20, 2019, p3 mesh
978 
979  !===Create periodic structures for Maxwell===================================
980  IF (mxw_periodic) THEN
982  WRITE(*,*) 'periodic MHD done'
983  END IF
984 
985  !===Create global csr structure==============================================
986  CALL st_scr_maxwell_mu_h_p_phi(comm_one_d(1), h_mesh_glob, h_mesh, pmag_mesh_glob, pmag_mesh, &
987  phi_mesh_glob, phi_mesh, interface_h_phi_glob, interface_h_mu_glob, &
988  la_h, la_pmag, la_phi, la_mhd, opt_per=h_phi_per)
989 
990  !===Prepare csr structure for post processing grad phi=======================+++
991  CALL st_aij_csr_glob_block(comm_one_d(1),1,phi_mesh_glob,phi_mesh, vizu_grad_phi_la)
992 
993  !===Prepare csr structure for post processing rot !h==========================+++
994  CALL st_aij_csr_glob_block(comm_one_d(1),1,h_mesh_glob,h_mesh, vizu_rot_h_la)
995 
996  IF (inputs%is_mesh_symmetric) THEN
997  ALLOCATE(h_mz_la(h_mesh%np))
998  CALL symmetric_points(h_mesh, h_mesh_glob, h_mz_la)
999  END IF
1000 
1001  !===Deallocate global meshes=================================================
1002  CALL free_mesh(h_mesh_glob)
1003  CALL free_mesh(pmag_mesh_glob)
1004  CALL free_mesh(phi_mesh_glob)
1005  CALL free_interface(interface_h_mu_glob)
1006  CALL free_interface(interface_h_phi_glob)
1007 
1008  !===Start Gauss points generation============================================
1009  !===JLG july 20, 2019, p3 mesh
1010  h_mesh%edge_stab = .false.
1011  pmag_mesh%edge_stab = .false.
1012  phi_mesh%edge_stab = .false.
1013  IF (1.LE.inputs%type_fe_H .AND. inputs%type_fe_H.LE.2) THEN
1014  CALL gauss_points_2d(h_mesh,inputs%type_fe_H)
1015  END IF
1016  CALL gauss_points_2d(pmag_mesh,1)
1017  IF (1.LE.inputs%type_fe_phi .AND. inputs%type_fe_phi.LE.2) THEN
1018  CALL gauss_points_2d(phi_mesh,inputs%type_fe_phi)
1019  END IF
1020  !===JLG july 20, 2019, p3 mesh
1021 
1022  !===Create sigma_field=======================================================
1023  ALLOCATE(sigma_field(h_mesh%me)) !===sigma field is P0 and defined on H_mesh
1024  DO m = 1, h_mesh%me
1025  DO k=1, inputs%nb_dom_H
1026  IF (h_mesh%i_d(m) == list_dom_h(k)) THEN
1027  sigma_field(m) = inputs%sigma(h_in_to_new(k))
1028  ENDIF
1029  ENDDO
1030  END DO
1031 
1032  !===Create mu_H_field========================================================
1033  ALLOCATE(mu_h_field(h_mesh%np)) !===mu_H_field is defined at nodes of H_mesh
1034  IF (inputs%analytical_permeability) THEN !===JLG + DCQ, June 26 2013
1035  mu_h_field = mu_bar_in_fourier_space(h_mesh,1,h_mesh%np)
1036  ELSE
1037  DO m = 1, h_mesh%me
1038  DO k=1, inputs%nb_dom_H
1039  IF (h_mesh%i_d(m) == list_dom_h(k)) THEN
1040  mu_h_field(h_mesh%jj(:,m)) = inputs%mu_H(h_in_to_new(k))
1041  ENDIF
1042  ENDDO
1043  END DO
1044  END IF
1045  !===Create mu_H_field========================================================
1046  !===Artificial boundary condition on phi on sphere of radius R
1047  !===d(phi)/dR + (1/R)*phi = 0. Assumes that phi=C/r at infinity
1048  !===Feature is currently disabled.
1049  r_fourier=-1.d0 !Negative radius disables the boundary condition
1050  index_fourier=0 !Index of spherical boundary where Fourier BC enforced
1051 
1052  END IF
1053 
1054  !===Specific to temperature=====================================================
1055  IF (if_energy) THEN
1056  !===Verify if the two meshes coincide on the NS domain=======================
1057  IF (vv_mesh%me/=0) THEN
1058  error = 0.d0
1059  DO k = 1, 2
1060  DO n = 1, SIZE(temp_mesh%jj,1)
1061  error = error + maxval(abs(vv_mesh%rr(k,vv_mesh%jj(n,:))-temp_mesh%rr(k,temp_mesh%jj(n,1:vv_mesh%me))))
1062  END DO
1063  END DO
1064  IF (error/maxval(abs(temp_mesh%rr(1,1) -temp_mesh%rr(1,:))) .GE. 5.d-14) THEN
1065  CALL error_petsc(.GE.'BUG in INIT, (error/MAXVAL(ABS(temp_mesh%rr(1,1) -temp_mesh%rr(1,:))) 5.d-14')
1066  END IF
1067 
1068  error = error + maxval(abs(vv_mesh%rr(1,vv_mesh%jj(4,1:vv_mesh%me)) &
1069  -(temp_mesh%rr(1,temp_mesh%jj(2,1:vv_mesh%me))+temp_mesh%rr(1,temp_mesh%jj(3,1:vv_mesh%me)))/2))&
1070  + maxval(abs(vv_mesh%rr(1,vv_mesh%jj(5,:)) &
1071  -(temp_mesh%rr(1,temp_mesh%jj(3,1:vv_mesh%me))+temp_mesh%rr(1,temp_mesh%jj(1,1:vv_mesh%me)))/2))&
1072  + maxval(abs(vv_mesh%rr(1,vv_mesh%jj(6,:)) &
1073  -(temp_mesh%rr(1,temp_mesh%jj(1,1:vv_mesh%me))+temp_mesh%rr(1,temp_mesh%jj(2,1:vv_mesh%me)))/2))&
1074  + maxval(abs(vv_mesh%rr(2,vv_mesh%jj(4,:)) &
1075  -(temp_mesh%rr(2,temp_mesh%jj(2,1:vv_mesh%me))+temp_mesh%rr(2,temp_mesh%jj(3,1:vv_mesh%me)))/2))&
1076  + maxval(abs(vv_mesh%rr(2,vv_mesh%jj(5,:)) &
1077  -(temp_mesh%rr(2,temp_mesh%jj(3,1:vv_mesh%me))+temp_mesh%rr(2,temp_mesh%jj(1,1:vv_mesh%me)))/2))&
1078  + maxval(abs(vv_mesh%rr(2,vv_mesh%jj(6,:)) &
1079  -(temp_mesh%rr(2,temp_mesh%jj(1,1:vv_mesh%me))+temp_mesh%rr(2,temp_mesh%jj(2,1:vv_mesh%me)))/2))
1080  IF (error/maxval(abs(temp_mesh%rr(1,1) -temp_mesh%rr(1,:))) .GE. 5.d-14) THEN
1081  WRITE(*,*) ' WARNING: vv_mesh and temp_mesh do not coincide on the NS domain.'
1082  WRITE(*,*) ' WARNING: Either you use curved elements P2 elements or BUG, ', &
1083  error/maxval(abs(temp_mesh%rr(1,1) -temp_mesh%rr(1,:)))
1084  END IF
1085 
1086  error=0.d0
1087  DO k = 1, vv_mesh%me
1088  DO n = 1, 2
1089  error = error+ maxval(abs(vv_mesh%rr(n,vv_mesh%jj(1:3,k))-temp_mesh%rr(n,temp_mesh%jj(1:3,k))))
1090  END DO
1091  END DO
1092  IF (error/maxval(abs(temp_mesh%rr(1,1) -temp_mesh%rr(1,:))) .GE. 5.d-14) THEN
1093  CALL error_petsc('vv_mesh and temp_mesh do NOT have the same P1 nodes')
1094  END IF
1095 
1096  END IF
1097 
1098  !===Create periodic structures for temperature===============================
1099  IF (temp_periodic) THEN
1100  CALL prep_periodic(inputs%my_periodic, temp_mesh, temp_per)
1101  END IF
1102 
1103  !===Create csr structure for temperature=====================================
1104  CALL st_aij_csr_glob_block(comm_one_d_temp(1),1,temp_mesh_glob,temp_mesh,temp_1_la, opt_per=temp_per)
1105 
1106  !===Deallocate global meshes=================================================
1107  CALL free_mesh(temp_mesh_glob)
1108 
1109  !===Start Gauss points generation============================================
1110  !===JLG July 20, 2019, p3 mesh
1111  temp_mesh%edge_stab = .false.
1112  CALL gauss_points_2d(temp_mesh,2)
1113  !===JLG July 20, 2019, p3 mesh
1114 
1115 
1116  !===Create temperature_diffusivity_field=====================================
1118  DO m = 1, temp_mesh%me
1119  DO k=1, inputs%nb_dom_temp
1120  IF (temp_mesh%i_d(m) == list_dom_temp(k)) THEN
1121  temperature_diffusivity_field(m) = inputs%temperature_diffusivity(temp_in_to_new(k))
1122  END IF
1123  END DO
1124  END DO
1125 
1126  !===Create vol_heat_capacity_field===========================================
1127  ALLOCATE(vol_heat_capacity_field(temp_mesh%me))
1128  DO m = 1, temp_mesh%me
1129  DO k=1, inputs%nb_dom_temp
1130  IF (temp_mesh%i_d(m) == list_dom_temp(k)) THEN
1131  vol_heat_capacity_field(m) = inputs%vol_heat_capacity(temp_in_to_new(k))
1132  END IF
1133  END DO
1134  END DO
1135  END IF
1136 
1137  !===Check coherence of vv_mesh and H_mesh=======================================
1138  IF ((if_induction .AND. if_momentum) .OR. inputs%type_pb=='mxx') THEN
1139  IF (vv_mesh%me /=0) THEN
1140  DO m = 1, vv_mesh%me
1141  IF (maxval(abs(h_mesh%rr(:,h_mesh%jj(1:3,m))-vv_mesh%rr(:,vv_mesh%jj(1:3,m))))/=0.d0) THEN
1142  CALL error_petsc( ' BUG in init: H_mesh and vv_mesh do not coincide ')
1143  END IF
1144  END DO
1145  END IF
1146  END IF
1147  IF (ALLOCATED(list_dom_h)) DEALLOCATE(list_dom_h)
1148 
1149  !===Check coherence of vv_mesh and temp_mesh====================================
1150  IF (if_energy) THEN
1151  IF (vv_mesh%me /=0) THEN
1152  DO m = 1, vv_mesh%me
1153  IF (maxval(abs(temp_mesh%rr(:,temp_mesh%jj(1:3,m))-vv_mesh%rr(:,vv_mesh%jj(1:3,m))))/=0.d0) THEN
1154  CALL error_petsc( ' BUG in init: temp_mesh and vv_mesh do not coincide ')
1155  END IF
1156  END DO
1157  END IF
1158  END IF
1159  IF (ALLOCATED(list_dom_temp)) DEALLOCATE(list_dom_temp)
1160 
1161  !===Compute local mesh size for stabilization================================
1162  IF (if_momentum .OR. inputs%type_pb=='mxx') THEN
1163  CALL compute_local_mesh_size(pp_mesh)
1164  CALL compute_local_mesh_size(vv_mesh)
1166  END IF
1167  IF (if_induction) THEN
1171  END IF
1172  IF (if_energy) THEN
1174  END IF
1175 
1176  !===Allocate arrays for Navier-Stokes===========================================
1177  IF (if_momentum .OR. inputs%type_pb=='mxx') THEN
1178  IF(inputs%if_navier_stokes_with_taylor) THEN
1179  ALLOCATE(der_un(inputs%taylor_order-1))
1180  ALLOCATE(der_pn(inputs%taylor_order-1))
1181  DO kp = 1, inputs%taylor_order-1
1182  ALLOCATE(der_un(kp)%DRT(vv_mesh%np, 6, m_max_c))
1183  ALLOCATE(der_pn(kp)%DRT(pp_mesh%np, 2, m_max_c))
1184  END DO
1185  ELSE
1186  ALLOCATE(un_m1(vv_mesh%np, 6, m_max_c))
1187  ALLOCATE(pn_m1(pp_mesh%np, 2, m_max_c))
1188  ALLOCATE(incpn_m1(pp_mesh%np, 2, m_max_c))
1189  ALLOCATE(incpn(pp_mesh%np, 2, m_max_c))
1190  ALLOCATE(density_m2(vv_mesh%np, 2, m_max_c))
1191  ALLOCATE(density_m1(vv_mesh%np, 2, m_max_c))
1192  ALLOCATE(density(vv_mesh%np, 2, m_max_c))
1193  END IF
1194  ALLOCATE(un(vv_mesh%np, 6, m_max_c))
1195  ALLOCATE(pn(pp_mesh%np, 2, m_max_c))
1196  !===Allocate arrays for Level sets===========================================
1197  IF (if_mass) THEN
1198  IF (inputs%if_level_set_P2) THEN
1199  ALLOCATE(level_set_m1(inputs%nb_fluid-1, vv_mesh%np, 2, m_max_c))
1200  ALLOCATE(level_set(inputs%nb_fluid-1, vv_mesh%np, 2, m_max_c))
1201  CALL mpi_comm_size(comm_one_d_ns(2), nb_procs, code)
1202  bloc_size = vv_mesh%gauss%l_G*vv_mesh%dom_me/nb_procs+1
1203  bloc_size = vv_mesh%gauss%l_G*(bloc_size/vv_mesh%gauss%l_G)+vv_mesh%gauss%l_G
1204  m_max_pad = 3*SIZE(list_mode)*nb_procs/2
1205  ALLOCATE(visc_entro_level(2*m_max_pad-1,bloc_size))
1206  ELSE
1207  ALLOCATE(level_set_m1(inputs%nb_fluid-1, pp_mesh%np, 2, m_max_c))
1208  ALLOCATE(level_set(inputs%nb_fluid-1, pp_mesh%np, 2, m_max_c))
1209  CALL mpi_comm_size(comm_one_d_ns(2), nb_procs, code)
1210  bloc_size = pp_mesh%gauss%l_G*pp_mesh%dom_me/nb_procs+1
1211  bloc_size = pp_mesh%gauss%l_G*(bloc_size/pp_mesh%gauss%l_G)+pp_mesh%gauss%l_G
1212  m_max_pad = 3*SIZE(list_mode)*nb_procs/2
1213  ALLOCATE(visc_entro_level(2*m_max_pad-1,bloc_size))
1214  END IF
1215  END IF
1216  END IF
1217 
1218  !===Allocate arrays for Maxwell=================================================
1219  IF (if_induction) THEN
1220  ALLOCATE(hn1(h_mesh%np, 6, m_max_c))
1221  ALLOCATE(hn(h_mesh%np, 6, m_max_c))
1222  ALLOCATE(bn1(h_mesh%np, 6, m_max_c))
1223  ALLOCATE(bn(h_mesh%np, 6, m_max_c))
1224  ALLOCATE(phin1(phi_mesh%np,2, m_max_c))
1225  ALLOCATE(phin(phi_mesh%np,2, m_max_c))
1226  END IF
1227 
1228  !===Allocate arrays for temperature=============================================
1229  IF (if_energy) THEN
1230  ALLOCATE(tempn_m1(temp_mesh%np, 2, m_max_c))
1231  ALLOCATE(tempn(temp_mesh%np, 2, m_max_c))
1232  END IF
1233 
1234  !===Create data structure jj_v_to_H=============================================
1235  IF (if_induction) THEN
1236  ALLOCATE(v_to_max(h_mesh%np, 6, m_max_c))
1237  IF (if_momentum .OR. inputs%type_pb=='mxx') THEN
1238  ALLOCATE(jj_v_to_h(h_mesh%np))
1239  jj_v_to_h = -1
1240  DO m = 1, vv_mesh%me
1241  jj_v_to_h(h_mesh%jj(:,m)) = vv_mesh%jj(1:h_mesh%gauss%n_w,m)
1242  END DO
1243  ELSE
1244  ALLOCATE(jj_v_to_h(h_mesh%np))
1245  jj_v_to_h = -1
1246  END IF
1247  END IF
1248  IF (if_momentum) THEN
1249  ALLOCATE(h_to_ns(vv_mesh%np, 6, m_max_c))
1250  ALLOCATE(b_to_ns(vv_mesh%np, 6, m_max_c))
1251  ALLOCATE(hext(h_mesh%np, 6, m_max_c))
1252  ALLOCATE(bext(h_mesh%np, 6, m_max_c))
1253  ELSE
1254  ALLOCATE(h_to_ns(1, 1, 1))
1255  ALLOCATE(b_to_ns(1, 1, 1))
1256  END IF
1257 
1258  !===Create data structure jj_v_to_temp==========================================
1259  IF (if_energy) THEN
1260  ALLOCATE(v_to_energy(temp_mesh%np, 6, m_max_c))
1261  ALLOCATE(jj_v_to_temp(temp_mesh%np))
1262  jj_v_to_temp = -1
1263  IF (vv_mesh%me/=0) THEN
1264  DO m = 1, vv_mesh%me
1265  jj_v_to_temp(temp_mesh%jj(:,m)) = vv_mesh%jj(1:temp_mesh%gauss%n_w,m)
1266  END DO
1267  ALLOCATE(t_to_ns(vv_mesh%np, 2, m_max_c))
1268  ELSE
1269  ALLOCATE(t_to_ns(1, 1, 1))
1270  END IF
1271  END IF
1272 
1273  !===Create coupling variables H and pdt H to temp===============================
1274  IF (if_energy .AND. if_induction) THEN
1275  ALLOCATE(h_to_energy(temp_mesh%np, 6, m_max_c))
1276  h_to_energy = 0.d0
1277  ALLOCATE(pdt_h_to_energy(temp_mesh%np, 6, m_max_c))
1278  pdt_h_to_energy = 0.d0
1279  END IF
1280 
1281  !===Initialize Navier-Stokes====================================================
1282  time_u = 0.d0
1283  IF (if_momentum .OR. inputs%type_pb=='mxx') THEN
1284  IF (vv_mesh%me/=0) THEN
1285  IF (inputs%irestart_u) THEN
1286  IF(inputs%if_navier_stokes_with_taylor) THEN
1287  CALL read_restart_ns_taylor(comm_one_d_ns, time_u, list_mode, un, der_un, pn, der_pn, inputs%file_name)
1288  ELSE
1289  IF (.NOT. if_mass) THEN
1290  CALL read_restart_ns(comm_one_d_ns, time_u, list_mode, un, un_m1, pn, pn_m1, &
1291  incpn, incpn_m1, inputs%file_name)
1292  ELSE
1293  CALL read_restart_ns(comm_one_d_ns, time_u, list_mode, un, un_m1, pn, pn_m1, &
1294  incpn, incpn_m1, inputs%file_name, opt_level_set=level_set, &
1295  opt_level_set_m1=level_set_m1, opt_max_vel=max_vel)
1296  END IF
1297  END IF
1298  ELSE
1299  IF(inputs%if_navier_stokes_with_taylor) THEN
1300  time_u = 0.d0 !===ATTENTION: Fixed initialization time for Taylor method
1301  CALL init_velocity_pressure_taylor(vv_mesh, pp_mesh, list_mode, time_u, pn, der_pn, un, der_un)
1302  ELSE
1303  CALL init_velocity_pressure(vv_mesh, pp_mesh, time_u, &
1304  inputs%dt, list_mode, un_m1, un, pn_m1, pn, incpn_m1, incpn)
1305  END IF
1306  IF (if_mass) THEN
1307  IF (inputs%if_level_set_P2) THEN
1308  CALL init_level_set(vv_mesh, time_u, &
1309  inputs%dt, list_mode, level_set_m1, level_set)
1310  ELSE
1311  CALL init_level_set(pp_mesh, time_u, &
1312  inputs%dt, list_mode, level_set_m1, level_set)
1313  END IF
1314  bloc_size = SIZE(un,1)/inputs%ndim(2) + 1
1315  m_max_pad = 3*SIZE(list_mode)*inputs%ndim(2)/2
1316  CALL fft_max_vel_dcl(comm_one_d_ns(2), 2*un-un_m1, max_vel_s, inputs%ndim(2), bloc_size, m_max_pad)
1317  CALL mpi_allreduce(max_vel_s, max_vel, 1, mpi_double_precision, &
1318  mpi_max, comm_one_d_ns(1), code)
1319  max_vel = max(1.1d0*max_vel, 0.1d0)
1320  END IF
1321  END IF
1322  IF (if_mass) THEN
1323  CALL reconstruct_variable(comm_one_d_ns, list_mode, pp_mesh, vv_mesh, level_set_m1, &
1324  inputs%density_fluid, density_m1)
1325  CALL reconstruct_variable(comm_one_d_ns, list_mode, pp_mesh, vv_mesh, level_set, &
1326  inputs%density_fluid, density)
1327  visc_entro_level = 0.d0
1328  END IF
1329 
1330  !===Force sine coefficients of zero mode to zero==========================
1331  DO i = 1, m_max_c
1332  IF (list_mode(i) == 0) THEN
1333  DO k= 1, 3
1334  un(:,2*k,i) = 0.d0
1335  IF(inputs%if_navier_stokes_with_taylor) THEN
1336  DO kp = 1, inputs%taylor_order-1
1337  der_un(kp)%DRT( :,2*k,i)= 0.d0
1338  END DO
1339  ELSE
1340  un_m1(:,2*k,i) = 0.d0
1341  END IF
1342  END DO
1343  pn(:,2,i) = 0.d0
1344  IF(inputs%if_navier_stokes_with_taylor) THEN
1345  DO kp = 1, inputs%taylor_order-1
1346  der_pn(kp)%DRT( :,2,i) = 0.d0
1347  END DO
1348  ELSE
1349  incpn(:,2,i) = 0.d0
1350  density(:,2,i) = 0.d0
1351  pn_m1(:,2,i) = 0.d0
1352  incpn_m1(:,2,i) = 0.d0
1353  density_m1(:,2,i) = 0.d0
1354  END IF
1355  IF (if_mass) THEN
1356  level_set(:,:,2,i) = 0.d0
1357  level_set_m1(:,:,2,i) = 0.d0
1358  END IF
1359  END IF
1360  END DO
1361  !===End force sine coefficients of zero mode to zero======================
1362  IF(.NOT.inputs%if_navier_stokes_with_taylor) THEN
1363  density_m2 = density_m1
1364  END IF
1365  END IF
1366  END IF
1367 
1368  !===Initialize velocity (time-independent) if mxw===============================
1369  IF ( (inputs%type_pb=='mxw') .AND. (h_mesh%me/=0) ) THEN
1370  DO i = 1, m_max_c !===Initialization of vel
1371  v_to_max(:,:,i) = vexact(list_mode(i), h_mesh)
1372  END DO
1373  ENDIF
1374 
1375  !===Initialize velocity using un (time-independent) if mxx======================
1376  IF (inputs%type_pb=='mxx') THEN
1377  !===Use extension_velocity===================================================
1378  IF (h_mesh%np>0) THEN !We extend v_to_Max
1379  DO i = 1, m_max_c
1380  DO k= 1, 6 !===The user has to code extension_vel
1381  v_to_max(:,k,i) = extension_velocity(k, h_mesh, list_mode(i), time_u, 1)
1382  END DO
1383  END DO
1384  END IF
1385 
1386  !===Use extension_velocity===================================================
1387  IF (vv_mesh%me /=0) THEN
1388  DO j = 1, SIZE(jj_v_to_h)
1389  IF (jj_v_to_h(j) == -1) cycle
1390  v_to_max(j,:,:) = un(jj_v_to_h(j),:,:)
1391  END DO
1392  END IF
1393 
1394  !===Cleanup==================================================================
1395  IF(inputs%if_navier_stokes_with_taylor) THEN
1396  DO kp = 1, inputs%taylor_order-1
1397  DEALLOCATE(der_un(kp)%DRT)
1398  DEALLOCATE(der_pn(kp)%DRT)
1399  END DO
1400  DEALLOCATE(der_un)
1401  DEALLOCATE(der_pn)
1402  ELSE
1403  DEALLOCATE(un_m1)
1404  DEALLOCATE(pn_m1)
1405  DEALLOCATE(incpn_m1)
1406  DEALLOCATE(incpn)
1407  DEALLOCATE(density_m2)
1408  DEALLOCATE(density_m1)
1409  DEALLOCATE(density)
1410  END IF
1411  DEALLOCATE(un)
1412  DEALLOCATE(pn)
1413  IF (if_mass) THEN
1414  IF (ALLOCATED(level_set)) DEALLOCATE(level_set,level_set_m1)
1415  END IF
1416  ENDIF
1417 
1418  !===Initialize Maxwell==========================================================
1419  time_h = 0.d0
1420  IF (if_induction) THEN
1421  IF (inputs%irestart_h) THEN
1422  CALL read_restart_maxwell(comm_one_d, h_mesh, phi_mesh, time_h, list_mode, hn, hn1, bn, bn1, &
1423  phin, phin1, inputs%file_name)
1424  ELSE
1425  CALL init_maxwell(h_mesh,phi_mesh,time_h,inputs%dt,mu_h_field,inputs%mu_phi,list_mode,&
1426  hn1,hn,phin1,phin)
1427  !===Initialize Bn and Bn1
1428  IF (h_mesh%me/=0) THEN
1429  IF (inputs%if_permeability_variable_in_theta) THEN
1430  CALL mpi_comm_size(comm_one_d(2), nb_procs, code)
1431  m_max_pad = 3*SIZE(list_mode)*nb_procs/2
1432  bloc_size = SIZE(bn,1)/nb_procs+1
1433  CALL fft_par_var_eta_prod_t_dcl(comm_one_d(2), mu_in_real_space, &
1434  h_mesh, hn, bn, nb_procs, bloc_size, m_max_pad, time)
1435  CALL fft_par_var_eta_prod_t_dcl(comm_one_d(2), mu_in_real_space, &
1436  h_mesh, hn1, bn1, nb_procs, bloc_size, m_max_pad, time)
1437  ELSE
1438  DO i = 1, m_max_c
1439  DO k = 1, 6
1440  bn(:,k,i) = mu_h_field*hn(:,k,i)
1441  bn1(:,k,i) = mu_h_field*hn1(:,k,i)
1442  END DO
1443  END DO
1444  END IF
1445  END IF
1446  END IF
1447  !===Force sine coefficients of zero mode to zero=============================
1448  DO i = 1, m_max_c
1449  IF (list_mode(i) == 0) THEN
1450  IF (h_mesh%me/=0) THEN
1451  DO k = 1, 3
1452  hn(:,2*k,i) = 0.d0
1453  hn1(:,2*k,i) = 0.d0
1454  END DO
1455  END IF
1456  IF (phi_mesh%me/=0) THEN
1457  phin(:,2,i) = 0.d0
1458  phin1(:,2,i) = 0.d0
1459  END IF
1460  END IF
1461  END DO
1462  END IF
1463 
1464  !===Initialize temperature======================================================
1465  time_t = 0.d0
1466  IF (if_energy) THEN
1467  IF (temp_mesh%me/=0) THEN
1468  IF (inputs%irestart_T) THEN
1469  CALL read_restart_temp(comm_one_d_temp, time_t, list_mode, tempn, tempn_m1, &
1470  inputs%file_name)
1471  ELSE
1472  CALL init_temperature(temp_mesh, time_t, inputs%dt, list_mode, tempn_m1, tempn)
1473  END IF
1474  !===Force sine coefficients of zero mode to zero==========================
1475  DO i = 1, m_max_c
1476  IF (list_mode(i) == 0) THEN
1477  tempn(:,2,i) = 0.d0
1478  tempn_m1(:,2,i) = 0.d0
1479  END IF
1480  END DO
1481 
1482  END IF
1483  END IF
1484 
1485  !===Initialize time=============================================================
1486  IF (inputs%irestart_h .OR. inputs%irestart_u .OR. inputs%irestart_T) THEN
1487  time = max(time_u,time_h,time_t)
1488  ELSE
1489  time = 0.d0
1490  END IF
1491 
1492  !===Guardrail===================================================================
1493  IF (if_mass.AND.inputs%variation_sigma_fluid) THEN
1494  IF (inputs%analytical_permeability.OR.inputs%nb_dom_phi>0) THEN
1495  CALL error_petsc(' BUG in INIT : sigma reconstruct via level set not implemented with vacuum or variable mu')
1496  END IF
1497  END IF
1498 
1499  END SUBROUTINE init
1500 
1501  SUBROUTINE prodmat_maxwell_int_by_parts(vect_in, vect_out, ndim, i)
1503  IMPLICIT NONE
1504  INTEGER :: ndim
1505  REAL(KIND=8), DIMENSION(ndim) :: vect_in
1506  REAL(KIND=8), DIMENSION(ndim) :: vect_out
1507  INTEGER :: i
1508  INTEGER :: TYPE, i_deb, i_fin
1509  REAL(KIND=8), DIMENSION(vv_mesh%np,2,SIZE(list_mode)) :: sigma_ns
1510 
1511  time = 0.d0
1512  DO TYPE = 1, 6
1513  i_deb = (type-1)*h_mesh%np+1
1514  i_fin = i_deb + h_mesh%np -1
1515  IF (modulo(TYPE,2)==0 .AND. list_mode(i)==0) THEN
1516  hn(:,TYPE,i) = 0.d0
1517  ELSE
1518  hn(:,TYPE,i) = vect_in(i_deb:i_fin)
1519  END IF
1520  END DO
1521  DO TYPE = 1, 2
1522  phin(:,TYPE,i) =0.d0
1523  END DO
1524 
1525  DO TYPE = 1, 6
1526  i_deb = 6*h_mesh%np + (type-1)*h_mesh%np+1
1527  i_fin = i_deb + h_mesh%np -1
1528  IF (modulo(TYPE,2)==0 .AND. list_mode(i)==0) THEN
1529  hn1(:,TYPE,i) = 0.d0
1530  ELSE
1531  hn1(:,TYPE,i) = vect_in(i_deb:i_fin)
1532  END IF
1533  END DO
1534  DO TYPE = 1, 2
1535  phin1(:,TYPE,i) =0.d0
1536  END DO
1537 
1540  mu_h_field, inputs%mu_phi, time, inputs%dt, inputs%Rem, list_mode, h_phi_per, la_h, la_pmag, &
1541  la_phi, la_mhd, sigma_ns, jj_v_to_h)
1542 
1543  DO TYPE = 1, 6
1544  i_deb = (type-1)*h_mesh%np+1
1545  i_fin = i_deb + h_mesh%np -1
1546  vect_out(i_deb:i_fin) = hn(:,TYPE,i)
1547  END DO
1548 
1549  DO TYPE = 1, 6
1550  i_deb = 6*h_mesh%np + (type-1)*h_mesh%np+1
1551  i_fin = i_deb + h_mesh%np -1
1552  vect_out(i_deb:i_fin) = hn1(:,TYPE,i)
1553  END DO
1554 
1555  END SUBROUTINE prodmat_maxwell_int_by_parts
1556 
1557 
1558  SUBROUTINE sfemansinitialize
1559  IMPLICIT NONE
1560  INTEGER :: narg, i
1561  CHARACTER(len=200),DIMENSION(:,:), ALLOCATABLE :: inline
1562  LOGICAL :: ok
1563  CHARACTER(len=3) :: tit
1564 
1565  narg = 0
1566  ok = .true.
1567 
1568  DO WHILE (ok)
1569  CALL getarg(narg+1,tit)
1570  IF (tit == ' ') THEN
1571  ok = .false.
1572  ELSE
1573  narg = narg+1
1574  END IF
1575  END DO
1576 
1577  narg = narg/2
1578  ALLOCATE(inline(2,narg))
1579 
1580  DO i = 1, narg
1581  CALL getarg(2*(i-1)+1,inline(1,i))
1582  CALL getarg(2*i ,inline(2,i))
1583  END DO
1584 
1585  inputs%test_de_convergence = .false.
1586  inputs%numero_du_test_debug = 0
1587  inputs%data_directory_debug = '.'
1588  DO i = 1, narg
1589  IF (trim(adjustl(inline(1,i))) == 'debug') THEN
1590  inputs%test_de_convergence = .true.
1591  READ(inline(2,i),*) inputs%numero_du_test_debug
1592  ELSE IF (trim(adjustl(inline(1,i))) == 'debug_dir') THEN
1593  inputs%data_directory_debug=inline(2,i)
1594  END IF
1595  END DO
1596 
1597  END SUBROUTINE sfemansinitialize
1598 
1599  SUBROUTINE compute_local_mesh_size(mesh)
1601  TYPE(mesh_type) :: mesh
1602  INTEGER :: m, type_fe, index, l, ierr, i
1603  REAL(KIND=8) :: diam_loc, diam
1604 
1605  IF (mesh%gauss%n_w==3) THEN
1606  type_fe = 1
1607  ELSE IF (mesh%gauss%n_w==6) THEN
1608  type_fe = 2
1609  ELSE IF (mesh%gauss%n_w==10) THEN
1610  type_fe = 3
1611  ELSE
1612  CALL error_petsc('BUG in compute_local_mesh_size')
1613  END IF
1614  ALLOCATE(mesh%hloc(mesh%dom_me))
1615  ALLOCATE(mesh%hloc_gauss(mesh%gauss%l_G*mesh%dom_me))
1616 
1617  index = 0
1618  DO m = 1, mesh%dom_me
1619  mesh%hloc(m) = sqrt(sum(mesh%gauss%rj(:,m)))/type_fe
1620  DO l = 1, mesh%gauss%l_G
1621  index = index + 1
1622  mesh%hloc_gauss(index) = mesh%hloc(m)
1623  END DO
1624  END DO
1625 
1626  !===JLG+CN Dec 14 2016
1627  !===Compute characteristic diameter of meridian section of domain associated with mesh
1628  !===BUG diam_loc = SUM(mesh%gauss%rj) !===BUG JLG+HF (not defined if mesh%dom_me=0)
1629  if(mesh%dom_me==0) THEN !===JLG+HF Dec 9 2019
1630  diam_loc =0.d0
1631  else
1632  diam_loc = sum(mesh%gauss%rj)
1633  end if
1634  CALL mpi_allreduce(diam_loc,diam,1,mpi_double_precision,mpi_sum,comm_one_d(1),ierr)
1635  mesh%global_diameter = sqrt(diam)
1636  !===End JLG+CN Dec 14 2016
1637  !===hm (JLG April 7, 2017)
1638  diam_loc = maxval(mesh%rr(1,:))
1639  CALL mpi_allreduce(diam_loc,diam,1,mpi_double_precision,mpi_max,comm_one_d(1),ierr)
1640  ALLOCATE(mesh%hm(m_max_c))
1641  DO i = 1, m_max_c
1642  mesh%hm(i) = 0.5d0*diam/inputs%m_max
1643  END DO
1644  !===end hm (JLG April 7, 2017)
1645  END SUBROUTINE compute_local_mesh_size
1646 
1648  REAL(KIND=8) :: h_min, h_min_F
1649  INTEGER :: code
1650  !===Compute h_min
1651  IF (inputs%if_level_set_P2) THEN
1652  h_min_f=minval(vv_mesh%hloc_gauss)
1653  ELSE
1654  h_min_f=minval(pp_mesh%hloc_gauss)
1655  END IF
1656  CALL mpi_allreduce(h_min_f, h_min, 1, mpi_double_precision, &
1657  mpi_min, comm_one_d_ns(1), code)
1658  inputs%h_min_distance = inputs%multiplier_for_h_min_distance*h_min
1659  !===End compute h_min
1660  END SUBROUTINE compute_local_mesh_size_level_set
1661 
1662 END MODULE initialization
type(petsc_csr_la), public vizu_grad_phi_la
real(kind=8), dimension(:,:,:), allocatable, target v_to_max
subroutine write_restart_ns_taylor(communicator, vv_mesh, pp_mesh, time, list_mode, un, der_un, pn, der_pn, filename, it, freq_restart, opt_level_set, opt_level_set_m1, opt_max_vel, opt_mono)
Definition: restart.f90:352
real(kind=8), dimension(:,:,:), allocatable, target tempn_m1
subroutine, public st_scr_maxwell_mu_h_p_phi(communicator, H_mesh_glob, H_mesh, pmag_mesh_glob, pmag_mesh, phi_mesh_glob, phi_mesh, interface_glob, interface_H_mu_glob, LA_H, LA_pmag, LA_phi, LA_mhd, opt_per)
Definition: st_csr_mhd.f90:12
subroutine write_restart_temp(communicator, temp_mesh, time, list_mode, tempn, tempn_m1, filename, it, freq_restart, opt_mono)
Definition: restart.f90:1004
subroutine, public load_interface(mesh_master, mesh_slave, list_inter, mesh_INTERFACE, disjoint)
real(kind=8) max_vel
real(kind=8), dimension(:,:,:), allocatable, target bn
subroutine read_restart_ns_taylor(communicator, time, list_mode, un, der_un, pn, der_pn, filename, val_init, interpol, opt_level_set, opt_level_set_m1, opt_max_vel, opt_mono, opt_it)
Definition: restart.f90:446
integer, dimension(:), allocatable jj_v_to_h
subroutine, public read_my_data(data_fichier)
subroutine, public prep_periodic_bloc(my_periodic, mesh, periodic, nb_bloc)
real(kind=8), dimension(:,:,:), allocatable, target pdt_h_to_energy
type(petsc_csr_la) la_h
subroutine, public fft_max_vel_dcl(communicator, V1_in, V_out, nb_procs, bloc_size, m_max_pad)
subroutine, public load_dg_mesh_free_format(dir, fil, list_dom, list_inter, type_fe, mesh, mesh_formatted)
Definition: prep_mesh.f90:276
type(interface_type), target interface_h_mu
subroutine, public prodmat_maxwell_int_by_parts(vect_in, vect_out, ndim, i)
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 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, opt_it, opt_dt)
Definition: restart.f90:110
subroutine, public three_level_temperature(comm_one_d, time, temp_1_LA, dt, list_mode, temp_mesh, tempn_m1, tempn, chmp_vit, chmp_mag, chmp_pdt_H, vol_heat_capacity, temp_diffusivity, my_par_cc, temp_list_dirichlet_sides, temp_list_robin_sides, convection_coeff, exterior_temperature, temp_per)
subroutine compute_local_mesh_size(mesh)
subroutine, public navier_stokes_decouple(comm_one_d_ns, time, vv_3_LA, pp_1_LA, list_mode, pp_mesh, vv_mesh, incpn_m1, incpn, pn_m1, pn, un_m1, un, vvz_per, pp_per, Hn_p2, Bn_p2, density_m2, density_m1, density, visco_dyn, tempn, level_set_m1, level_set, visc_entro_level)
subroutine, public prep_periodic_h_p_phi_bc(my_periodic, H_mesh, pmag_mesh, phi_mesh, H_p_phi_per)
subroutine projection_temperature(mesh, vn, connectivity_structure, coupling_variable)
subroutine, public create_p3_mesh(p1_mesh, p2_mesh, p3_mesh, type_fe)
Definition: prep_mesh.f90:18
type(periodic_type) vvrtz_per
type(petsc_csr_la) pp_1_la
real(kind=8), dimension(:,:,:), allocatable, target h_to_energy
subroutine error_petsc(string)
Definition: my_util.f90:16
type(my_data), public inputs
type(dyn_real_array_three), dimension(:), allocatable der_pn
subroutine zero_out_modes
real(kind=8) r_fourier
subroutine read_restart_maxwell(communicator, H_mesh, phi_mesh, time, list_mode, Hn, Hn1, Bn, Bn1, phin, phin1, filename, val_init, interpol, opt_mono, opt_it, opt_dt)
Definition: restart.f90:781
type(petsc_csr_la) temp_1_la
subroutine, public free_interface(interf)
type(mesh_type), target temp_mesh
real(kind=8), dimension(:,:,:), allocatable t_to_ns
subroutine prepare_zero_out_modes(list_mode, list_mode_to_zero_out, select_mode)
real(kind=8), dimension(:), allocatable, target temperature_diffusivity_field
subroutine, public reconstruct_variable(comm_one_d, list_mode, mesh_P1, mesh_P2, level_set, values, variable)
Definition: sub_mass.f90:96
real(kind=8), dimension(:,:,:), allocatable, target bext
integer, dimension(:), allocatable, public vv_mz_la
Definition: symmetry.f90:10
subroutine, public save_run(it, freq_restart)
subroutine compute_local_mesh_size_level_set
real(kind=8), dimension(:,:,:), allocatable, target bn1
real(kind=8), dimension(:,:,:), allocatable incpn_m1
subroutine, public maxwell_decouple(comm_one_d, H_mesh, pmag_mesh, phi_mesh, interface_H_phi,interface_H_mu, Hn, Bn, phin, Hn1, Bn1, phin1, vel, stab_in, sigma_in,R_fourier, index_fourier, mu_H_field, mu_phi, time, dt, Rem, list_mode,
Definition: sub_maxwell.f90:11
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)
real(kind=8), dimension(:,:,:), allocatable, target pn
subroutine, public free_mesh(mesh)
real(kind=8), dimension(:,:,:,:), allocatable, target level_set_m1
type(petsc_csr_la) la_pmag
type(periodic_type) h_phi_per
type(petsc_csr_la), public vizu_rot_u_la
type(petsc_csr_la) la_phi
subroutine, public symmetric_points(mesh_loc, mesh_glob, ltg_LA)
Definition: symmetry.f90:19
real(kind=8), dimension(:,:,:), allocatable b_to_ns
type(interface_type), target interface_h_phi
subroutine projection_mag_field(mesh, vn, connectivity_structure, if_restriction, coupling_variable)
subroutine, public sfemans_initialize_postprocessing(comm_one_d, vv_mesh_in, pp_mesh, H_mesh, phi_mesh, temp_mesh, list_mode_in, opt_nb_plane)
real(kind=8), dimension(:), allocatable, target sigma_field
type(petsc_csr_la) la_mhd
type(periodic_type) vvrt_per
type(periodic_type) temp_per
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)
type(periodic_type) pp_per
Definition: tn_axi.f90:5
subroutine, public create_cart_comm(ndim, comm_cart, comm_one_d, coord_cart)
real(kind=8), dimension(:,:,:), allocatable, target hext
type(mesh_type), target h_mesh
subroutine, public prep_periodic(my_periodic, mesh, periodic)
subroutine, public st_aij_csr_glob_block(communicator, kmax, mesh_glob, mesh, LA, opt_per)
Definition: st_csr.f90:165
real(kind=8), dimension(:), allocatable, target vol_heat_capacity_field
subroutine write_restart_maxwell(communicator, H_mesh, phi_mesh, time, list_mode, Hn, Hn1, Bn, Bn1, phin, phin1, filename, it, freq_restart, opt_mono, opt_dt)
Definition: restart.f90:677
subroutine sfemansinitialize
type(mesh_type), target phi_mesh
real(kind=8), dimension(:,:,:), allocatable, target v_to_energy
subroutine projection_velocity(mesh, vn, connectivity_structure, coupling_variable)
real(kind=8), dimension(:,:,:), allocatable h_to_ns
real(kind=8), dimension(:,:,:), allocatable, target hn1
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, opt_dt)
Definition: restart.f90:11
integer, dimension(:), allocatable, public h_mz_la
Definition: symmetry.f90:10
subroutine, public extract_mesh(communicator, nb_proc, mesh_glob, part, list_dom, mesh, mesh_loc)
real(kind=8), dimension(:,:,:), allocatable, target hn
type(petsc_csr_la), public vizu_rot_h_la
subroutine, public run_sfemans(time_in, it)
type(dyn_real_array_three), dimension(:), allocatable, target der_un
subroutine, public three_level_mass(comm_one_d, time, level_set_LA_P1, level_set_LA_P2, list_mode, mesh_P1, mesh_P2, chmp_vit_P2, max_vel, level_set_per, density_m2, density_m1, density, level_set_m1, level_set, visc_entro_level)
Definition: sub_mass.f90:12
real(kind=8), dimension(:,:,:,:), allocatable, target level_set
real(kind=8), dimension(:,:), allocatable visc_entro_level
integer, dimension(:), allocatable jj_v_to_temp
subroutine, public navier_stokes_taylor(comm_one_d_ns, time, vv_3_LA, pp_1_LA, list_mode, pp_mesh, vv_mesh, pn, der_pn, un, der_un, vvz_per, pp_per)
real(kind=8), dimension(:), allocatable, target mu_h_field
subroutine read_restart_temp(communicator, time, list_mode, tempn, tempn_m1, filename, val_init, interpol, opt_mono)
Definition: restart.f90:1081
type(mesh_type), target pmag_mesh
real(kind=8), dimension(:,:,:), allocatable, target phin1
subroutine, public init_velocity_pressure_taylor(vv_mesh, pp_mesh, list_mode, time, pn, der_pn, un, der_un)
real(kind=8), dimension(:,:,:), allocatable, target phin
real(kind=8), dimension(:,:,:), allocatable incpn
subroutine assign_boundary
Definition: boundary.f90:47
subroutine, public gauss_points_2d(mesh, type_fe)
type(periodic_type) level_set_per
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:190