SFEMaNS  version 5.3
Reference documentation for SFEMaNS
condlim_test_4.f90
Go to the documentation of this file.
2  USE my_util
3  USE def_type_mesh
4  USE input_data
5  USE bessel
6 !!$ATTENTION
7 !!$Some subroutines have been commented to avoid warning messages when compiling executable.
8 !!$It can not be done in the module boundary_generic that expects all subroutines to be present.
9 !!$END ATTENTION
10 !!$ PUBLIC :: init_velocity_pressure
11 !!$ PUBLIC :: init_temperature
12 !!$ PUBLIC :: init_level_set
13 !!$ PUBLIC :: source_in_NS_momentum
14 !!$ PUBLIC :: source_in_temperature
15 !!$ PUBLIC :: source_in_level_set
16 !!$ PUBLIC :: vv_exact
17 !!$ PUBLIC :: imposed_velocity_by_penalty
18 !!$ PUBLIC :: pp_exact
19 !!$ PUBLIC :: temperature_exact
20 !!$ PUBLIC :: level_set_exact
21 !!$ PUBLIC :: penal_in_real_space
22 !!$ PUBLIC :: extension_velocity
23  PUBLIC :: vexact
24 !!$ PUBLIC :: H_B_quasi_static
25  PUBLIC :: hexact
26  PUBLIC :: phiexact
27  PUBLIC :: jexact_gauss
28  PUBLIC :: eexact_gauss
29  PUBLIC :: init_maxwell
30 !!$ PUBLIC :: mu_bar_in_fourier_space
31 !!$ PUBLIC :: grad_mu_bar_in_fourier_space
32 !!$ PUBLIC :: mu_in_real_space
33  PRIVATE
34  !maxwell parameters
35  REAL(KIND=8), PRIVATE :: r0 = 0.5d0
36  REAL(KIND=8), PRIVATE :: k0=6.28318530717958d0
37  INTEGER , PRIVATE :: m0=1
38 
39 CONTAINS
40  !===============================================================================
41  ! Boundary conditions for Navier-Stokes
42  !===============================================================================
43 
44 !!$ !===Initialize velocity, pressure
45 !!$ SUBROUTINE init_velocity_pressure(mesh_f, mesh_c, time, dt, list_mode, &
46 !!$ un_m1, un, pn_m1, pn, phin_m1, phin)
47 !!$ IMPLICIT NONE
48 !!$ TYPE(mesh_type) :: mesh_f, mesh_c
49 !!$ REAL(KIND=8), INTENT(OUT):: time
50 !!$ REAL(KIND=8), INTENT(IN) :: dt
51 !!$ INTEGER, DIMENSION(:), INTENT(IN) :: list_mode
52 !!$ REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT):: un_m1, un
53 !!$ REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT):: pn_m1, pn, phin_m1, phin
54 !!$ INTEGER :: mode, i, j
55 !!$ REAL(KIND=8), DIMENSION(mesh_c%np) :: pn_m2
56 !!$
57 !!$ time = 0.d0
58 !!$ DO i= 1, SIZE(list_mode)
59 !!$ mode = list_mode(i)
60 !!$ DO j = 1, 6
61 !!$ !===velocity
62 !!$ un_m1(:,j,i) = vv_exact(j,mesh_f%rr,mode,time-dt)
63 !!$ un (:,j,i) = vv_exact(j,mesh_f%rr,mode,time)
64 !!$ END DO
65 !!$ DO j = 1, 2
66 !!$ !===pressure
67 !!$ pn_m2(:) = pp_exact(j,mesh_c%rr,mode,time-2*dt)
68 !!$ pn_m1 (:,j,i) = pp_exact(j,mesh_c%rr,mode,time-dt)
69 !!$ pn (:,j,i) = pp_exact(j,mesh_c%rr,mode,time)
70 !!$ phin_m1(:,j,i) = pn_m1(:,j,i) - pn_m2(:)
71 !!$ phin (:,j,i) = Pn (:,j,i) - pn_m1(:,j,i)
72 !!$ ENDDO
73 !!$ ENDDO
74 !!$ END SUBROUTINE init_velocity_pressure
75 
76 !!$ !===Initialize temperature
77 !!$ SUBROUTINE init_temperature(mesh, time, dt, list_mode, tempn_m1, tempn)
78 !!$ IMPLICIT NONE
79 !!$ TYPE(mesh_type) :: mesh
80 !!$ REAL(KIND=8), INTENT(OUT):: time
81 !!$ REAL(KIND=8), INTENT(IN) :: dt
82 !!$ INTEGER, DIMENSION(:), INTENT(IN) :: list_mode
83 !!$ REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT):: tempn_m1, tempn
84 !!$ INTEGER :: mode, i, j
85 !!$
86 !!$ time = 0.d0
87 !!$ DO i= 1, SIZE(list_mode)
88 !!$ mode = list_mode(i)
89 !!$ DO j = 1, 2
90 !!$ tempn_m1(:,j,i) = temperature_exact(j, mesh%rr, mode, time-dt)
91 !!$ tempn (:,j,i) = temperature_exact(j, mesh%rr, mode, time)
92 !!$ ENDDO
93 !!$ ENDDO
94 !!$ END SUBROUTINE init_temperature
95 
96 !!$ !===Initialize level_set
97 !!$ SUBROUTINE init_level_set(vv_mesh, time, &
98 !!$ dt, list_mode, level_set_m1, level_set)
99 !!$ IMPLICIT NONE
100 !!$ TYPE(mesh_type) :: vv_mesh
101 !!$ REAL(KIND=8), INTENT(OUT):: time
102 !!$ REAL(KIND=8), INTENT(IN) :: dt
103 !!$ INTEGER, DIMENSION(:), INTENT(IN) :: list_mode
104 !!$ REAL(KIND=8), DIMENSION(:,:,:,:), INTENT(OUT):: level_set, level_set_m1
105 !!$ INTEGER :: mode, i, j, n
106 !!$
107 !!$ time = 0.d0
108 !!$ DO i= 1, SIZE(list_mode)
109 !!$ mode = list_mode(i)
110 !!$ DO j = 1, 2
111 !!$ !===level_set
112 !!$ DO n = 1, inputs%nb_fluid -1
113 !!$ level_set_m1(n,:,j,i) = level_set_exact(n,j,vv_mesh%rr,mode,time-dt)
114 !!$ level_set (n,:,j,i) = level_set_exact(n,j,vv_mesh%rr,mode,time)
115 !!$ END DO
116 !!$ END DO
117 !!$ END DO
118 !!$
119 !!$ END SUBROUTINE init_level_set
120 
121 !!$ !===Source in momemtum equation. Always called.
122 !!$ FUNCTION source_in_NS_momentum(TYPE, rr, mode, i, time, Re, ty, opt_density, opt_tempn) RESULT(vv)
123 !!$ IMPLICIT NONE
124 !!$ INTEGER , INTENT(IN) :: TYPE
125 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
126 !!$ INTEGER , INTENT(IN) :: mode, i
127 !!$ REAL(KIND=8), INTENT(IN) :: time
128 !!$ REAL(KIND=8), INTENT(IN) :: Re
129 !!$ CHARACTER(LEN=2), INTENT(IN) :: ty
130 !!$ REAL(KIND=8), DIMENSION(:,:,:), OPTIONAL, INTENT(IN) :: opt_density
131 !!$ REAL(KIND=8), DIMENSION(:,:,:), OPTIONAL, INTENT(IN) :: opt_tempn
132 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
133 !!$
134 !!$ vv = 0.d0
135 !!$ CALL error_petsc('source_in_NS_momentum: should not be called for this test')
136 !!$ RETURN
137 !!$ END FUNCTION source_in_NS_momentum
138 
139 !!$ !===Extra source in level set equation. Always called.
140 !!$ !===Extra source in temperature equation. Always called.
141 !!$ FUNCTION source_in_temperature(TYPE, rr, m, t)RESULT(vv)
142 !!$ IMPLICIT NONE
143 !!$ INTEGER , INTENT(IN) :: TYPE
144 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
145 !!$ INTEGER , INTENT(IN) :: m
146 !!$ REAL(KIND=8), INTENT(IN) :: t
147 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
148 !!$
149 !!$ vv = 0.d0
150 !!$ CALL error_petsc('source_in_temperature: should not be called for this test')
151 !!$ RETURN
152 !!$ END FUNCTION source_in_temperature
153 
154 !!$ FUNCTION source_in_level_set(interface_nb,TYPE, rr, m, t)RESULT(vv)
155 !!$ IMPLICIT NONE
156 !!$ INTEGER , INTENT(IN) :: TYPE
157 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
158 !!$ INTEGER , INTENT(IN) :: m, interface_nb
159 !!$ REAL(KIND=8), INTENT(IN) :: t
160 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
161 !!$
162 !!$ vv=0.d0
163 !!$ CALL error_petsc('sourece_in_temperature: should not be called for this test')
164 !!$ END FUNCTION source_in_level_set
165 
166 !!$ !===Velocity for boundary conditions in Navier-Stokes.
167 !!$ !===Can be used also to initialize velocity in: init_velocity_pressure_temperature
168 !!$ FUNCTION vv_exact(TYPE,rr,m,t) RESULT(vv)
169 !!$
170 !!$ IMPLICIT NONE
171 !!$ INTEGER , INTENT(IN) :: TYPE
172 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
173 !!$ INTEGER, INTENT(IN) :: m
174 !!$ REAL(KIND=8), INTENT(IN) :: t
175 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
176 !!$
177 !!$ vv(:) = 0.d0
178 !!$ CALL error_petsc('vv_exact: should not be called for this test')
179 !!$ RETURN
180 !!$ END FUNCTION vv_exact
181 
182 !!$ !===Solid velocity imposed when using penalty technique
183 !!$ !===Defined in Fourier space on mode 0 only.
184 !!$ FUNCTION imposed_velocity_by_penalty(rr,t) RESULT(vv)
185 !!$ IMPLICIT NONE
186 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
187 !!$ REAL(KIND=8), INTENT(IN) :: t
188 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2),6) :: vv
189 !!$
190 !!$ vv=0.d0
191 !!$ RETURN
192 !!$ END FUNCTION imposed_velocity_by_penalty
193 
194 !!$ !===Pressure for boundary conditions in Navier-Stokes.
195 !!$ !===Can be used also to initialize pressure in the subroutine init_velocity_pressure.
196 !!$ !===Use this routine for outflow BCs only.
197 !!$ !===CAUTION: Do not enfore BCs on pressure where normal component
198 !!$ ! of velocity is prescribed.
199 !!$ FUNCTION pp_exact(TYPE,rr,m,t) RESULT (vv)
200 !!$ IMPLICIT NONE
201 !!$ INTEGER , INTENT(IN) :: TYPE
202 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
203 !!$ INTEGER , INTENT(IN) :: m
204 !!$ REAL(KIND=8), INTENT(IN) :: t
205 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
206 !!$
207 !!$ vv=0.d0
208 !!$ RETURN
209 !!$ END FUNCTION pp_exact
210 
211 !!$ !===Temperature for boundary conditions in temperature equation.
212 !!$ FUNCTION temperature_exact(TYPE,rr,m,t) RESULT (vv)
213 !!$ IMPLICIT NONE
214 !!$ INTEGER , INTENT(IN) :: TYPE
215 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
216 !!$ INTEGER , INTENT(IN) :: m
217 !!$ REAL(KIND=8), INTENT(IN) :: t
218 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
219 !!$
220 !!$ vv = 0.d0
221 !!$ CALL error_petsc('temperature_exact: should not be called for this test')
222 !!$ RETURN
223 !!$ END FUNCTION temperature_exact
224 
225 !!$ !===Can be used to initialize level set in the subroutine init_level_set.
226 !!$ FUNCTION level_set_exact(interface_nb,TYPE,rr,m,t) RESULT (vv)
227 !!$ IMPLICIT NONE
228 !!$ INTEGER , INTENT(IN) :: TYPE
229 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
230 !!$ INTEGER , INTENT(IN) :: m, interface_nb
231 !!$ REAL(KIND=8), INTENT(IN) :: t
232 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
233 !!$
234 !!$ vv = 0.d0
235 !!$ CALL error_petsc('level_set_exact: should not be called for this test')
236 !!$ RETURN
237 !!$
238 !!$ END FUNCTION level_set_exact
239 
240 !!$ !===Penalty coefficient (if needed)
241 !!$ !===This coefficient is equal to zero in subdomain
242 !!$ !===where penalty is applied (penalty is zero in solid)
243 !!$ FUNCTION penal_in_real_space(mesh,rr_gauss,angles,nb_angles,nb,ne,time) RESULT(vv)
244 !!$ IMPLICIT NONE
245 !!$ TYPE(mesh_type) :: mesh
246 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr_gauss
247 !!$ REAL(KIND=8), DIMENSION(:), INTENT(IN) :: angles
248 !!$ INTEGER, INTENT(IN) :: nb_angles
249 !!$ INTEGER, INTENT(IN) :: nb, ne
250 !!$ REAL(KIND=8), INTENT(IN) :: time
251 !!$ REAL(KIND=8), DIMENSION(nb_angles,ne-nb+1) :: vv
252 !!$
253 !!$ vv = 1.d0
254 !!$ CALL error_petsc('penal_in_real_space: should not be called for this test')
255 !!$ RETURN
256 !!$ END FUNCTION penal_in_real_space
257 
258 !!$ !===Extension of the velocity field in the solid.
259 !!$ !===Used when temperature or Maxwell equations are solved.
260 !!$ !===It extends the velocity field on the Navier-Stokes domain to a
261 !!$ !===velocity field on the temperature and the Maxwell domain.
262 !!$ !===It is also used if problem type=mxw and restart velocity
263 !!$ !===is set to true in data (type problem denoted mxx in the code).
264 !!$ FUNCTION extension_velocity(TYPE, H_mesh, mode, t, n_start) RESULT(vv)
265 !!$ IMPLICIT NONE
266 !!$ TYPE(mesh_type), INTENT(IN) :: H_mesh
267 !!$ INTEGER , INTENT(IN) :: TYPE, n_start
268 !!$ INTEGER, INTENT(IN) :: mode
269 !!$ REAL(KIND=8), INTENT(IN) :: t
270 !!$ REAL(KIND=8), DIMENSION(H_Mesh%np) :: vv
271 !!$
272 !!$ vv = 0.d0
273 !!$ RETURN
274 !!$
275 !!$ END FUNCTION extension_velocity
276 
277  !===============================================================================
278  ! Boundary conditions for Maxwell
279  !===============================================================================
280  !===Velocity used in the induction equation.
281  !===Used only if problem type is mxw and restart velocity is false
282  FUNCTION vexact(m, H_mesh) RESULT(vv) !Set uniquement a l'induction
283  IMPLICIT NONE
284  TYPE(mesh_type), INTENT(IN) :: H_mesh
285  INTEGER, INTENT(IN) :: m
286  REAL(KIND=8), DIMENSION(H_mesh%np,6) :: vv
287  INTEGER :: n !dummy
288 
289  vv = 0.d0
290  RETURN
291 
292  !===Dummies variables to avoid warning
293  n=m
294  !===Dummies variables to avoid warning
295  END FUNCTION vexact
296 
297 !!$ !===Magnetic field and magnetic induction for quasi-static approximation
298 !!$ !===if needed
299 !!$ FUNCTION H_B_quasi_static(char_h_b, rr, m) RESULT(vv)
300 !!$ IMPLICIT NONE
301 !!$ CHARACTER(LEN=1), INTENT(IN) :: char_h_b
302 !!$ REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
303 !!$ INTEGER, INTENT(IN) :: m
304 !!$ REAL(KIND=8), DIMENSION(SIZE(rr,2),6) :: vv
305 !!$
306 !!$ vv = 0.d0
307 !!$ RETURN
308 !!$ END FUNCTION H_B_quasi_static
309 
310  !===Magnetic field for boundary conditions in the Maxwell equations.
311  FUNCTION hexact(H_mesh, TYPE, rr, m, mu_H_field, t) RESULT(vv)
312  IMPLICIT NONE
313  TYPE(mesh_type), INTENT(IN) :: H_mesh
314  INTEGER , INTENT(IN) :: TYPE
315  REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
316  INTEGER , INTENT(IN) :: m
317  REAL(KIND=8), INTENT(IN) :: t
318  REAL(KIND=8), DIMENSION(:), INTENT(IN) :: mu_H_field
319  REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
320  REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: r, z
321  REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: f1, f2, f3, f4
322  REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: df2, df3
323  REAL(KIND=8) :: f1_r0, f2_r0, f3_r0
324  REAL(KIND=8) :: df2_r0, df3_r0
325  REAL(KIND=8) :: A, B, z0
326 
327  r = rr(1,:)
328  z = rr(2,:)
329 
330  IF (m/=m0) THEN
331  vv = 0
332  RETURN
333  END IF
334  !value in r0
335  z0 = r0*k0
336  f3_r0 = 1.d0
337  df3_r0 = 2.d0/r0
338  f1_r0 = 1.d0/k0*(df3_r0-m0/r0*bessk(m0,z0))
339  !f2_r0 = m0/(k0*r0)*f3_r0 - (BESSI(m0-1,z0)-m0/(k0*r0)*BESSI(m0,z0))
340  f2_r0 = m0/(k0*r0)*f3_r0 - (-bessk(m0-1,z0)-m0/(k0*r0)*bessk(m0,z0))
341  df2_r0 = (m0/r0*f1_r0-f2_r0/r0-k0*bessk(m0,z0))
342  !to evaluate f2
343  a = 3*f2_r0 - r0*df2_r0
344  b = r0*df2_r0-2*f2_r0
345  !function for all points
346  f1 = (r/r0)**2*f1_r0
347  f2 = (r/r0)**2*(a+b*r/r0)
348  f3 = (r/r0)**2
349  df3 = 2*r/r0**2
350  df2 = r/r0**2*(2*a+3*b*r/r0)
351  f4 = r/r0**2*(a+b*r/r0) + df2 - m0*r/r0**2*f1_r0
352 
353  IF (TYPE == 1) then
354  vv = (m0*r/r0**2-k0*f2)*cos(k0*z)
355  ELSEIF (TYPE == 2) then
356  vv = 0.d0
357  ELSEIF (TYPE ==3) then
358  vv = 0.d0
359  ELSEIF (TYPE == 4) then
360  vv = (k0*f1-df3)*cos(k0*z)
361  ELSEIF (TYPE == 5) then
362  vv = f4*sin(k0*z)
363  ELSEIF (TYPE == 6) then
364  vv = 0.d0
365  ENDIF
366  vv = vv * cos(t)
367  RETURN
368 
369  !===Dummies variables to avoid warning
370  r=mu_h_field; r=h_mesh%rr(1,1)
371  !===Dummies variables to avoid warning
372  END FUNCTION hexact
373 
374  !===Scalar potential for boundary conditions in the Maxwell equations.
375  FUNCTION phiexact(TYPE, rr, m, mu_phi,t) RESULT(vv)
376  IMPLICIT NONE
377  INTEGER , INTENT(IN) :: TYPE
378  REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: rr
379  INTEGER , INTENT(IN) :: m
380  REAL(KIND=8), INTENT(IN) :: mu_phi, t
381  REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: vv
382  REAL(KIND=8), DIMENSION(SIZE(rr,2)) :: r, z
383  INTEGER :: n
384 
385  r = rr(1,:)
386  z = rr(2,:)
387  vv(:) = 0.d0
388  IF (m/=m0) RETURN
389  IF (TYPE == 1) then
390  DO n= 1, SIZE(rr,2)
391  vv(n) = bessk(m0,k0*r(n))*cos(k0*z(n))
392  END DO
393  ELSEIF (TYPE == 2) then
394  vv = 0.d0
395  ENDIF
396  vv = vv*cos(t)
397  RETURN
398 
399  !===Dummies variables to avoid warning
400  r=mu_phi
401  !===Dummies variables to avoid warning
402  END FUNCTION phiexact
403 
404  !===Current in Ohm's law. Curl(H) = sigma(E + uxB) + current
405  FUNCTION jexact_gauss(TYPE, rr, m, mu_phi, sigma, mu_H, t, mesh_id, opt_B_ext) RESULT(vv)
406  IMPLICIT NONE
407  INTEGER , INTENT(IN) :: TYPE
408  REAL(KIND=8), DIMENSION(:), INTENT(IN) :: rr
409  INTEGER , INTENT(IN) :: m
410  REAL(KIND=8), INTENT(IN) :: mu_phi, sigma, mu_H, t
411  INTEGER , INTENT(IN) :: mesh_id
412  REAL(KIND=8), DIMENSION(6), OPTIONAL,INTENT(IN) :: opt_B_ext
413  REAL(KIND=8) :: vv
414  REAL(KIND=8) :: r, z
415  REAL(KIND=8) :: f1, f2, f3, f4
416  REAL(KIND=8) :: df2, df3, d2f2, df1, d2f3, df4
417  REAL(KIND=8) :: f1_r0, f2_r0, f3_r0
418  REAL(KIND=8) :: df2_r0, df3_r0
419  REAL(KIND=8) :: A, B, z0
420  REAL(KIND=8) :: H1, H2, H3, dH3, dH2
421  INTEGER :: n
422 
423  r = rr(1)
424  z = rr(2)
425 
426  vv=0.d0
427  IF (m/=m0) THEN
428  vv = 0.d0
429  RETURN
430  END IF
431  !calcul du rotationnel de H
432  !valeur en r0
433  z0 = r0*k0
434  f3_r0 = 1.d0
435  df3_r0 = 2.d0/r0
436  f1_r0 = 1.d0/k0*(df3_r0-m0/r0*bessk(m0,z0))
437  !f2_r0 = m0/(k0*r0)*f3_r0 - (BESSI(m0-1,z0)-m0/(k0*r0)*BESSI(m0,z0))
438  f2_r0 = m0/(k0*r0)*f3_r0 - (-bessk(m0-1,z0)-m0/(k0*r0)*bessk(m0,z0))
439  df2_r0 = (m0/r0*f1_r0-f2_r0/r0-k0*bessk(m0,z0))
440  !pour evaluer f2
441  a = 3*f2_r0 - r0*df2_r0
442  b = r0*df2_r0-2*f2_r0
443  !fonction pour tous les points
444  f1 = (r/r0)**2*f1_r0
445  f2 = (r/r0)**2*(a+b*r/r0)
446  f3 = (r/r0)**2
447  df3 = 2*r/r0**2
448  df2 = r/r0**2*(2*a+3*b*r/r0)
449  f4 = r/r0**2*(a+b*r/r0) + df2 - m0*r/r0**2*f1_r0
450  df1 = 2*r/r0**2*f1_r0
451  d2f3= 2/r0**2
452  d2f2= (1/r0**2)*(2*a+6*b*r/r0)
453  df4 = (1/r0**2)*(a+2*b*r/r0) + d2f2 -m0/r0**2*f1_r0
454 
455  !champ mag en r
456  h1 = (m0*r/r0**2-k0*f2)
457  h2 = (k0*f1-df3)
458  h3 = f4
459  dh2= k0*df1 - d2f3
460  dh3= df4
461 
462  IF (TYPE == 1) then
463  vv = 0.d0
464  ELSEIF (TYPE == 2) then
465  vv = ((-m0/r)*h3+k0*h2)*sin(k0*z)
466  ELSEIF (TYPE ==3) then
467  vv = (-k0*h1-dh3)*sin(k0*z)
468  ELSEIF (TYPE == 4) then
469  vv = 0.d0
470  ELSEIF (TYPE == 5) then
471  vv = 0.d0
472  ELSEIF (TYPE == 6) then
473  vv = 1/r*(h2 + r*dh2 + m0*h1)*cos(k0*z)
474  ENDIF
475  vv = vv*cos(t) - sigma* eexact_gauss(TYPE, rr, m, mu_phi, sigma, mu_H, t)
476  ! vv = - sigma* Eexact_gauss(type, rr, m, mu_phi, sigma, mu_H, t)
477 
478  RETURN
479 
480  !===Dummies variables to avoid warning
481  n=mesh_id
482  IF (PRESENT(opt_b_ext)) r=opt_b_ext(1)
483  !===Dummies variables to avoid warning
484  END FUNCTION jexact_gauss
485 
486  !===Electric field for Neumann BC (cf. doc)
487  FUNCTION eexact_gauss(TYPE, rr, m, mu_phi, sigma, mu_H, t) RESULT(vv)
488  IMPLICIT NONE
489  INTEGER, INTENT(IN) :: TYPE
490  REAL(KIND=8), DIMENSION(:), INTENT(IN) :: rr
491  INTEGER, INTENT(IN) :: m
492  REAL(KIND=8), INTENT(IN) :: mu_phi, sigma, mu_H, t
493  REAL(KIND=8) :: vv
494  REAL(KIND=8) :: r, z
495  REAL(KIND=8) :: f1, f2, f3
496  REAL(KIND=8) :: f1_r0, f2_r0, f3_r0
497  REAL(KIND=8) :: df2_r0, df3_r0
498  REAL(KIND=8) :: A, B, z0
499 
500  r = rr(1)
501  z = rr(2)
502 
503  vv = 0.d0
504  IF (m/=m0) THEN
505  vv = 0.d0
506  RETURN
507  END IF
508  !valeur en r0
509  z0 = r0*k0
510  f3_r0 = 1.d0
511  df3_r0 = 2.d0/r0
512  f1_r0 = 1.d0/k0*(df3_r0-m0/r0*bessk(m0,z0))
513  !f2_r0 = m0/(k0*r0)*f3_r0 - (BESSI(m0-1,z0)-m0/(k0*r0)*BESSI(m0,z0))
514  f2_r0 = m0/(k0*r0)*f3_r0 - (-bessk(m0-1,z0)-m0/(k0*r0)*bessk(m0,z0))
515  df2_r0 = (m0/r0*f1_r0-f2_r0/r0-k0*bessk(m0,z0))
516  !pour evaluer f2
517  a = 3*f2_r0 - r0*df2_r0
518  b = r0*df2_r0-2*f2_r0
519  !fonction pour tous les points
520  f1 = (r/r0)**2*f1_r0
521  f2 = (r/r0)**2*(a+b*r/r0)
522  f3 = (r/r0)**2
523 
524  IF (TYPE == 1) then
525  vv = 0.d0
526  ELSEIF (TYPE == 2) then
527  vv = f1*sin(k0*z)
528  ELSEIF (TYPE ==3) then
529  vv = f2*sin(k0*z)
530  ELSEIF (TYPE == 4) then
531  vv = 0.d0
532  ELSEIF (TYPE == 5) then
533  vv = 0.d0
534  ELSEIF (TYPE == 6) then
535  vv = f3*cos(k0*z)
536  ENDIF
537  vv = vv*sin(t)/mu_h
538  RETURN
539 
540  !===Dummies variables to avoid warning
541  r=mu_phi; r=sigma
542  !===Dummies variables to avoid warning
543  END FUNCTION eexact_gauss
544 
545  !===Initialization of magnetic field and scalar potential (if present)
546  SUBROUTINE init_maxwell(H_mesh, phi_mesh, time, dt, mu_H_field, mu_phi, &
547  list_mode, hn1, hn, phin1, phin)
548  IMPLICIT NONE
549  TYPE(mesh_type) :: H_mesh, phi_mesh
550  REAL(KIND=8), INTENT(OUT):: time
551  REAL(KIND=8), INTENT(IN) :: dt
552  REAL(KIND=8), DIMENSION(:), INTENT(IN) :: mu_H_field
553  REAL(KIND=8), INTENT(IN) :: mu_phi
554  INTEGER, DIMENSION(:), INTENT(IN) :: list_mode
555  REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT):: Hn, Hn1
556  REAL(KIND=8), DIMENSION(:,:,:), INTENT(OUT):: phin, phin1
557  INTEGER :: i, k
558 
559  time = -dt
560  DO k=1,6
561  DO i=1, SIZE(list_mode)
562  hn1(:,k,i) = hexact(h_mesh,k, h_mesh%rr, list_mode(i), mu_h_field, time)
563  IF (inputs%nb_dom_phi>0) THEN
564  IF (k<3) THEN
565  phin1(:,k,i) = phiexact(k, phi_mesh%rr, list_mode(i) , mu_phi, time)
566  ENDIF
567  END IF
568  ENDDO
569  ENDDO
570 
571  time = time + dt
572  DO k=1,6
573  DO i=1, SIZE(list_mode)
574  hn(:,k,i) = hexact(h_mesh,k, h_mesh%rr, list_mode(i), mu_h_field, time)
575  IF (inputs%nb_dom_phi>0) THEN
576  IF (k<3) THEN
577  phin(:,k,i) = phiexact(k, phi_mesh%rr, list_mode(i), mu_phi, time)
578  ENDIF
579  END IF
580  ENDDO
581  ENDDO
582  END SUBROUTINE init_maxwell
583 
584 !!$ !===Analytical permeability (if needed)
585 !!$ !===This function is not needed unless the flag
586 !!$ !=== ===Use FEM Interpolation for magnetic permeability (true/false)
587 !!$ !===is activated and set to .FALSE. in the data data file. Default is .TRUE.
588 !!$ FUNCTION mu_bar_in_fourier_space(H_mesh,nb,ne,pts,pts_ids) RESULT(vv)
589 !!$ IMPLICIT NONE
590 !!$ TYPE(mesh_type), INTENT(IN) :: H_mesh
591 !!$ REAL(KIND=8), DIMENSION(ne-nb+1) :: vv
592 !!$ INTEGER, INTENT(IN) :: nb, ne
593 !!$ REAL(KIND=8),DIMENSION(2,ne-nb+1),OPTIONAL :: pts
594 !!$ INTEGER, DIMENSION(ne-nb+1), OPTIONAL :: pts_ids
595 !!$
596 !!$ vv = 1.d0
597 !!$ CALL error_petsc('mu_bar_in_fourier_space: should not be called for this test')
598 !!$ RETURN
599 !!$ END FUNCTION mu_bar_in_fourier_space
600 
601 !!$ !===Analytical mu_in_fourier_space (if needed)
602 !!$ !===This function is not needed unless the flag
603 !!$ !=== ===Use FEM Interpolation for magnetic permeability (true/false)
604 !!$ !===is activated and set to .FALSE. in the data data file. Default is .TRUE.
605 !!$ FUNCTION grad_mu_bar_in_fourier_space(pt,pt_id) RESULT(vv)
606 !!$ IMPLICIT NONE
607 !!$ REAL(KIND=8),DIMENSION(2), INTENT(in):: pt
608 !!$ INTEGER,DIMENSION(1), INTENT(in) :: pt_id
609 !!$ REAL(KIND=8),DIMENSION(2) :: vv
610 !!$
611 !!$ vv=0.d0
612 !!$ CALL error_petsc('grad_mu_bar_in_fourier_space: should not be called for this test')
613 !!$ RETURN
614 !!$ END FUNCTION grad_mu_bar_in_fourier_space
615 
616 !!$ !===Analytical permeability, mu in real space (if needed)
617 !!$ FUNCTION mu_in_real_space(H_mesh,angles,nb_angles,nb,ne,time) RESULT(vv)
618 !!$ IMPLICIT NONE
619 !!$ TYPE(mesh_type), INTENT(IN) :: H_mesh
620 !!$ REAL(KIND=8), DIMENSION(:), INTENT(IN) :: angles
621 !!$ INTEGER, INTENT(IN) :: nb_angles
622 !!$ INTEGER, INTENT(IN) :: nb, ne
623 !!$ REAL(KIND=8), INTENT(IN) :: time
624 !!$ REAL(KIND=8), DIMENSION(nb_angles,ne-nb+1) :: vv
625 !!$
626 !!$ vv = 1.d0
627 !!$ CALL error_petsc('mu_in_real_space: should not be called for this test')
628 !!$ RETURN
629 !!$ END FUNCTION mu_in_real_space
630 
631 END MODULE boundary_test_4
real(kind=8) function, dimension(h_mesh%np, 6), public vexact(m, H_mesh)
Definition: bessel.f90:4
type(my_data), public inputs
subroutine, public init_maxwell(H_mesh, phi_mesh, time, dt, mu_H_field, mu_phi, list_mode, Hn1, Hn, phin1, phin)
real(kind=8) function, public eexact_gauss(TYPE, rr, m, mu_phi, sigma, mu_H, t)
real(kind=8) function, dimension(size(rr, 2)), public hexact(H_mesh, TYPE, rr, m, mu_H_field, t)
real *8 function, public bessk(N, X)
Definition: bessel.f90:15
real(kind=8) function, dimension(size(rr, 2)), public phiexact(TYPE, rr, m, mu_phi, t)
integer, private m0
real(kind=8) function, public jexact_gauss(TYPE, rr, m, mu_phi, sigma, mu_H, t, mesh_id, opt_B_ext)
real(kind=8), private k0