10 REAL(KIND=8),
PARAMETER,
PRIVATE :: alpha=0.6d0
17 interface_h_mu, hn, bn, phin, hn1, bn1, phin1, vel, stab_in, sigma_in, &
18 r_fourier, index_fourier, mu_h_field, mu_phi, time, dt, rem, list_mode, &
19 h_phi_per, la_h, la_pmag, la_phi, la_mhd, sigma_ns_in, jj_v_to_h)
36 TYPE(mesh_type),
INTENT(IN) :: h_mesh, phi_mesh, pmag_mesh
37 TYPE(interface_type),
INTENT(IN) :: interface_h_phi, interface_h_mu
38 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
39 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(INOUT) :: vel
40 REAL(KIND=8),
DIMENSION(H_mesh%np,6,SIZE(list_mode)),
INTENT(INOUT) :: hn, hn1
41 REAL(KIND=8),
DIMENSION(H_mesh%np,6,SIZE(list_mode)),
INTENT(INOUT) :: bn, bn1
42 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(INOUT) :: phin, phin1
43 REAL(KIND=8),
DIMENSION(3),
INTENT(IN) :: stab_in
44 REAL(KIND=8),
INTENT(IN) :: r_fourier
45 INTEGER,
INTENT(IN) :: index_fourier
46 REAL(KIND=8),
INTENT(IN) :: mu_phi, time, dt, rem
47 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: sigma_in, mu_h_field
51 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: sigma_ns_in
52 INTEGER,
DIMENSION(:) ,
INTENT(IN) :: jj_v_to_h
55 REAL(KIND=8),
DIMENSION(:),
ALLOCATABLE,
SAVE :: sigma_ns_bar
57 REAL(KIND=8),
DIMENSION(:),
ALLOCATABLE,
SAVE :: sigma_np
58 REAL(KIND=8),
DIMENSION(:),
ALLOCATABLE,
SAVE :: sigma
59 REAL(KIND=8),
SAVE :: sigma_min
60 REAL(KIND=8),
DIMENSION(:),
POINTER,
SAVE :: pmag_bv_d, phi_bv1_d, phi_bv2_d
61 INTEGER,
DIMENSION(:),
POINTER,
SAVE :: pmag_js_d, phi_js_d
62 INTEGER,
DIMENSION(:),
ALLOCATABLE,
SAVE :: dirichlet_bdy_h_sides
63 LOGICAL,
SAVE :: once=.true.
64 INTEGER,
SAVE :: m_max_c
66 REAL(KIND=8),
DIMENSION(3),
SAVE :: stab
67 INTEGER,
SAVE :: my_petscworld_rank
68 REAL(KIND=8),
ALLOCATABLE ,
DIMENSION(:,:,:),
SAVE :: sigma_curl_bdy
69 REAL(KIND=8),
DIMENSION(H_mesh%gauss%n_w,H_mesh%me) :: sigma_nj_m
70 REAL(KIND=8),
DIMENSION(H_mesh%gauss%l_G*H_mesh%me,6,SIZE(list_mode)) :: sigma_curl
71 REAL(KIND=8),
DIMENSION(H_mesh%np,6,SIZE(list_mode)) :: j_over_sigma
72 REAL(KIND=8),
DIMENSION(SIZE(Hn,1),6,SIZE(Hn,3)) :: h_ns
73 REAL(KIND=8),
DIMENSION(SIZE(Hn,1),2,SIZE(Hn,3)) :: sigma_tot
74 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: dir_pmag
75 REAL(KIND=8),
DIMENSION(H_mesh%np,6) :: rhs_h
76 REAL(KIND=8),
DIMENSION(phi_mesh%np,2) :: rhs_phi
77 REAL(KIND=8),
DIMENSION(SIZE(Hn,1),6,SIZE(Hn,3)) :: nl, h_ext
78 REAL(KIND=8),
DIMENSION(3) :: temps_par
79 INTEGER,
POINTER,
DIMENSION(:) :: h_ifrom, pmag_ifrom, phi_ifrom, h_p_phi_ifrom
80 REAL(KIND=8),
DIMENSION(phi_mesh%np, 2) :: phin_p1
81 REAL(KIND=8),
DIMENSION(H_mesh%np, 6) :: hn_p1
82 INTEGER :: mode, k, i, n, m, ms, code, nj, j
83 INTEGER :: nb_procs, bloc_size, m_max_pad
84 REAL(KIND=8) :: tps, nr_vel, tps_tot, tps_cumul, norm
86 REAL(KIND=8) :: one_and_half
87 DATA one_and_half/1.5d0/
90 #include "petsc/finclude/petscsys.h"
91 #include "petsc/finclude/petscmat.h"
92 #include "petsc/finclude/petscksp.h"
93 #include "petsc/finclude/petscvec.h"
94 #include "petsc/finclude/petscvec.h90"
95 petscerrorcode :: ierr
96 mpi_comm,
DIMENSION(:),
POINTER :: comm_one_d
97 mat,
DIMENSION(:),
POINTER,
SAVE :: h_p_phi_mat1, h_p_phi_mat2
98 mat :: tampon1, tampon2, precond1, precond2
99 ksp,
DIMENSION(:),
POINTER,
SAVE :: h_p_phi_ksp1, h_p_phi_ksp2
100 vec,
SAVE :: vx_1, vb_1, vx_1_ghost, vx_2, vb_2, vx_2_ghost
113 CALL mpi_comm_rank(petsc_comm_world,my_petscworld_rank,code)
119 n =
SIZE(h_ifrom)+
SIZE(pmag_ifrom)+
SIZE(phi_ifrom)
120 ALLOCATE(h_p_phi_ifrom(n))
121 IF (
SIZE(h_ifrom)/=0)
THEN
122 h_p_phi_ifrom(1:
SIZE(h_ifrom)) = h_ifrom
124 IF (
SIZE(pmag_ifrom)/=0)
THEN
125 h_p_phi_ifrom(
SIZE(h_ifrom)+1:
SIZE(h_ifrom)+
SIZE(pmag_ifrom)) = pmag_ifrom
127 IF (
SIZE(phi_ifrom)/=0)
THEN
128 h_p_phi_ifrom(
SIZE(h_ifrom)+
SIZE(pmag_ifrom)+1:)=phi_ifrom
131 n = 3*h_mesh%dom_np + pmag_mesh%dom_np + phi_mesh%dom_np
132 CALL veccreateghost(comm_one_d(1), n, &
133 petsc_determine,
SIZE(h_p_phi_ifrom), h_p_phi_ifrom, vx_1, ierr)
134 CALL vecghostgetlocalform(vx_1, vx_1_ghost, ierr)
135 CALL vecduplicate(vx_1, vb_1, ierr)
136 CALL veccreateghost(comm_one_d(1), n, &
137 petsc_determine,
SIZE(h_p_phi_ifrom), h_p_phi_ifrom, vx_2, ierr)
138 CALL vecghostgetlocalform(vx_2, vx_2_ghost, ierr)
139 CALL vecduplicate(vx_2, vb_2, ierr)
143 ALLOCATE(sigma(
SIZE(sigma_in)))
144 sigma = sigma_in * rem
147 CALL mpi_allreduce(minval(sigma),sigma_min,1,mpi_double_precision, mpi_min,comm_one_d(1), ierr)
154 IF (inputs%type_pb==
'mhd')
THEN
157 stab = stab_in*(1/sigma_min+1.d0)
161 IF (inputs%if_level_set.AND.inputs%variation_sigma_fluid)
THEN
162 stab = stab_in*(1/(minval(inputs%sigma_fluid)*rem)+1.d0)
166 nr_vel =
norm_sf(comm_one_d,
'L2', h_mesh, list_mode, vel)
168 IF (nr_vel .LE. 1.d-10)
THEN
171 stab = stab_in*(1/sigma_min)
177 stab = stab_in*(1/sigma_min+1.d0)
183 WRITE(*,*)
'stab = ',stab
189 m_max_c =
SIZE(list_mode)
193 IF (inputs%if_level_set.AND.inputs%variation_sigma_fluid)
THEN
196 ALLOCATE(sigma_ns_bar(
SIZE(hn,1)))
206 DO nj = 1, h_mesh%gauss%n_w
208 IF (jj_v_to_h(j) == -1)
THEN
209 sigma_nj_m(nj,m) = sigma(m)
213 sigma_nj_m(nj,m) = sigma_ns_bar(j)
220 sigma_nj_m(:,m) = sigma(m)
224 ALLOCATE(sigma_np(
SIZE(hn,1)))
227 DO nj = 1, h_mesh%gauss%n_w
228 sigma_np(h_mesh%jj(nj,m)) = sigma_nj_m(nj,m)
236 ALLOCATE (dir_pmag(maxval(pmag_mesh%sides)))
238 DO ms = 1,
SIZE(dir_pmag)
239 IF (minval(abs(inputs%list_dirichlet_sides_H-ms)) == 0)
THEN
240 dir_pmag(ms) = .true.
242 IF (minval(abs(inputs%list_inter_H_phi-ms)) == 0)
THEN
243 dir_pmag(ms) = .true.
247 CALL
dirichlet_nodes(pmag_mesh%jjs, pmag_mesh%sides, dir_pmag, pmag_js_d)
249 ALLOCATE(pmag_bv_d(
SIZE(pmag_js_d)))
256 DO ms = 1, h_mesh%mes
257 IF (minval(abs(h_mesh%sides(ms)-inputs%list_dirichlet_sides_H))/=0) cycle
258 IF (maxval(abs(h_mesh%rr(1,h_mesh%jjs(:,ms)))) .LT.1d-12) cycle
261 ALLOCATE(dirichlet_bdy_h_sides(n))
263 DO ms = 1, h_mesh%mes
264 IF (minval(abs(h_mesh%sides(ms)-inputs%list_dirichlet_sides_H))/=0) cycle
265 IF (maxval(abs(h_mesh%rr(1,h_mesh%jjs(:,ms)))) .LT.1d-12) cycle
267 dirichlet_bdy_h_sides(n) = ms
273 ALLOCATE(phi_bv1_d(
SIZE(phi_js_d)), phi_bv2_d(
SIZE(phi_js_d)))
277 ALLOCATE(h_p_phi_mat1(m_max_c),h_p_phi_ksp1(m_max_c))
278 ALLOCATE(h_p_phi_mat2(m_max_c),h_p_phi_ksp2(m_max_c))
279 IF (
SIZE(dirichlet_bdy_h_sides).GE.1)
THEN
280 ALLOCATE(sigma_curl_bdy(h_mesh%gauss%l_Gs*
SIZE(dirichlet_bdy_h_sides),6,
SIZE(list_mode)))
282 ALLOCATE(sigma_curl_bdy(1,6,
SIZE(list_mode)))
283 sigma_curl_bdy = 0.d0
305 mode,mu_h_field, mu_phi, one_and_half/dt, stab, r_fourier, index_fourier, &
306 la_h, la_pmag, la_phi, h_p_phi_mat1(i), h_p_phi_mat2(i), sigma_np)
314 mu_h_field, sigma, la_h, h_p_phi_mat1(i), h_p_phi_mat2(i))
321 mode, stab, la_h, h_p_phi_mat1(i), h_p_phi_mat2(i), sigma_np)
327 IF (inputs%my_periodic%nb_periodic_pairs/=0)
THEN
329 h_phi_per%perlist, h_p_phi_mat1(i), la_mhd)
331 h_phi_per%perlist, h_p_phi_mat2(i), la_mhd)
343 CALL
init_solver(inputs%my_par_H_p_phi,h_p_phi_ksp1(i),h_p_phi_mat1(i),comm_one_d(1),&
344 solver=inputs%my_par_H_p_phi%solver,precond=inputs%my_par_H_p_phi%precond)
345 CALL
init_solver(inputs%my_par_H_p_phi,h_p_phi_ksp2(i),h_p_phi_mat2(i),comm_one_d(1),&
346 solver=inputs%my_par_H_p_phi%solver,precond=inputs%my_par_H_p_phi%precond)
351 CALL matdestroy(h_p_phi_mat1(i),ierr)
352 CALL matdestroy(h_p_phi_mat2(i),ierr)
360 CALL mpi_comm_rank(petsc_comm_world, my_petscworld_rank, code)
364 nr_vel =
norm_sf(comm_one_d,
'L2', h_mesh, list_mode, vel)
367 IF (nr_vel .LE. 1.d-10)
THEN
370 CALL mpi_comm_size(comm_one_d(2), nb_procs, code)
371 bloc_size =
SIZE(vel,1)/nb_procs+1
372 m_max_pad = 3*
SIZE(list_mode)*nb_procs/2
376 IF (inputs%if_level_set.AND.inputs%variation_sigma_fluid)
THEN
380 DO nj = 1, h_mesh%gauss%n_w
383 IF (jj_v_to_h(j) /= -1)
THEN
384 h_ns(j,:,:) = 2*hn(j,:,:)- hn1(j,:,:)
385 sigma_tot(j,:,:) = sigma_ns_in(jj_v_to_h(j),:,:) * rem
387 DO i = 1,
SIZE(list_mode)
390 sigma_tot(j,1,i) = sigma(m)
399 sigma_ns_bar, sigma_tot, sigma_curl)
400 IF (
SIZE(dirichlet_bdy_h_sides).GE.1)
THEN
402 sigma_ns_bar, sigma_tot, sigma_curl_bdy)
404 sigma_curl_bdy = 0.d0
408 mu_h_field, mu_phi, sigma_tot, time, j_over_sigma)
411 sigma_curl_bdy = 0.d0
415 tps =
user_time() - tps; tps_cumul=tps_cumul+tps
428 rhs_h(:,k) = (4*bn(:,k,i)-bn1(:,k,i))/(2*dt)
431 rhs_phi(:,k) = mu_phi*(4*phin(:,k,i)-phin1(:,k,i))/(2*dt)
435 rhs_h, nl(:,:,i), la_h, la_phi, vb_1, vb_2, h_ext(:,:,i), &
436 sigma_curl(:,:,i), j_over_sigma(:,:,i))
443 tps =
user_time() - tps; tps_cumul=tps_cumul+tps
447 CALL
courant_mu(h_mesh, interface_h_mu,sigma, mu_h_field, time,mode, nl(:,:,i), &
448 la_h, vb_1, vb_2, h_ext(:,:,i))
449 tps =
user_time() - tps; tps_cumul=tps_cumul+tps
457 sigma, mu_h_field, time, mode, nl(:,:,i), stab, la_h, vb_1,vb_2, h_ext(:,:,i), &
458 j_over_sigma(:,:,i), sigma_curl_bdy(:,:,i))
463 CALL
surf_int(h_mesh,phi_mesh,interface_h_phi,interface_h_mu,inputs%list_dirichlet_sides_H, &
464 sigma,mu_phi,mu_h_field, time,mode,la_h, la_phi,vb_1,vb_2, r_fourier, index_fourier)
465 tps =
user_time() - tps; tps_cumul=tps_cumul+tps
471 IF (inputs%my_periodic%nb_periodic_pairs/=0)
THEN
472 CALL
periodic_rhs_petsc(h_phi_per%n_bord, h_phi_per%list, h_phi_per%perlist, vb_1, la_mhd)
473 CALL
periodic_rhs_petsc(h_phi_per%n_bord, h_phi_per%list, h_phi_per%perlist, vb_2, la_mhd)
478 CALL
dirichlet_rhs(la_pmag%loc_to_glob(1,pmag_js_d)-1, pmag_bv_d,vb_1)
479 CALL
dirichlet_rhs(la_pmag%loc_to_glob(1,pmag_js_d)-1, pmag_bv_d,vb_2)
480 IF (
SIZE(phi_js_d)>0)
THEN
481 phi_bv1_d =
phiexact(1,phi_mesh%rr(1:2,phi_js_d), mode, mu_phi, time)
482 phi_bv2_d =
phiexact(2,phi_mesh%rr(:,phi_js_d), mode, mu_phi, time)
488 CALL
dirichlet_rhs(la_phi%loc_to_glob(1,phi_js_d)-1, phi_bv1_d, vb_1)
489 CALL
dirichlet_rhs(la_phi%loc_to_glob(1,phi_js_d)-1, phi_bv2_d, vb_2)
495 tps =
user_time() - tps; tps_cumul=tps_cumul+tps
500 IF (inputs%my_par_H_p_phi%verbose .AND. (i==1))
WRITE(*,*)
'start solving'
503 CALL
solver(h_p_phi_ksp1(i),vb_1,vx_1,reinit=.false.,
verbose=inputs%my_par_H_p_phi%verbose)
505 CALL vecghostupdatebegin(vx_1,insert_values,scatter_forward,ierr)
506 CALL vecghostupdateend(vx_1,insert_values,scatter_forward,ierr)
507 IF (h_mesh%me/=0)
THEN
508 CALL
extract(vx_1_ghost,1,1,la_mhd,hn_p1(:,1))
509 CALL
extract(vx_1_ghost,2,2,la_mhd,hn_p1(:,4))
510 CALL
extract(vx_1_ghost,3,3,la_mhd,hn_p1(:,5))
512 IF (phi_mesh%me/=0)
THEN
513 CALL
extract(vx_1_ghost,5,5,la_mhd,phin_p1(:,1))
516 CALL
solver(h_p_phi_ksp2(i),vb_2,vx_2,reinit=.false.,
verbose=inputs%my_par_H_p_phi%verbose)
517 CALL vecghostupdatebegin(vx_2,insert_values,scatter_forward,ierr)
518 CALL vecghostupdateend(vx_2,insert_values,scatter_forward,ierr)
519 IF (h_mesh%me/=0)
THEN
520 CALL
extract(vx_2_ghost,1,1,la_mhd,hn_p1(:,2))
521 CALL
extract(vx_2_ghost,2,2,la_mhd,hn_p1(:,3))
522 CALL
extract(vx_2_ghost,3,3,la_mhd,hn_p1(:,6))
524 IF (phi_mesh%me/=0)
THEN
525 CALL
extract(vx_2_ghost,5,5,la_mhd,phin_p1(:,2))
528 tps =
user_time() - tps; tps_cumul=tps_cumul+tps
536 IF (h_mesh%me /=0)
THEN
541 IF (phi_mesh%me /=0 )
THEN
548 IF (h_mesh%me /=0)
THEN
549 hn1(:,:,i) = hn(:,:,i)
551 hn(:,1,i) = hn_p1(:,1)
552 hn(:,4,i) = hn_p1(:,4)
553 hn(:,5,i) = hn_p1(:,5)
555 hn(:,2,i) = hn_p1(:,2)
556 hn(:,3,i) = hn_p1(:,3)
557 hn(:,6,i) = hn_p1(:,6)
560 bn1(:,k,i) = bn(:,k,i)
561 bn(:,k,i) = mu_h_field*hn(:,k,i)
566 IF (phi_mesh%me /= 0)
THEN
567 phin1(:,:,i) = phin(:,:,i)
569 phin(:,1,i) = phin_p1(:,1)
571 phin(:,2,i) = phin_p1(:,2)
573 tps =
user_time() - tps; tps_cumul=tps_cumul+tps
580 IF (inputs%verbose_divergence)
THEN
581 norm =
norm_sf(comm_one_d,
'L2', h_mesh, list_mode, bn)
582 talk_to_me%div_B_L2 =
norm_sf(comm_one_d,
'div', h_mesh, list_mode, bn)/norm
593 mode, mu_h_field, mu_phi, c_mass, stab, r_fourier, index_fourier, &
594 la_h, la_pmag, la_phi, h_p_phi_mat1, h_p_phi_mat2, sigma_np)
604 INTEGER,
INTENT(IN) :: mode
605 REAL(KIND=8),
INTENT(IN) :: mu_phi, c_mass
606 REAL(KIND=8),
DIMENSION(3),
INTENT(IN) :: stab
607 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: mu_h_field
608 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: sigma_np
609 REAL(KIND=8),
OPTIONAL :: r_fourier
610 INTEGER,
OPTIONAL :: index_fourier
611 REAL(KIND=8),
DIMENSION(phi_mesh%gauss%n_ws,phi_mesh%gauss%l_Gs) :: w_cs
612 REAL(KIND=8),
DIMENSION(2, H_mesh%gauss%n_w, phi_mesh%gauss%l_Gs, H_mesh%mes) :: dw_cs
613 INTEGER :: m, l, ms, ls, ni, nj, k, i, j, &
614 n_ws1, n_ws2, n_w2, n_w1, m1, m2, ki, kj,ib,jb, ms1, ms2
615 REAL(KIND=8) :: x, y, hm1, stab_div, stab_colle_h_phi
616 REAL(KIND=8) :: ray, error
617 LOGICAL :: mark=.false.
618 REAL(KIND=8),
DIMENSION(3,H_mesh%gauss%n_w,pmag_mesh%gauss%n_w) :: thpmag
619 REAL(KIND=8),
DIMENSION(pmag_mesh%gauss%n_w,pmag_mesh%gauss%n_w) :: tpmag
620 REAL(KIND=8),
DIMENSION(9,H_mesh%gauss%n_w,H_mesh%gauss%n_w) :: th
621 REAL(KIND=8),
DIMENSION(phi_mesh%gauss%n_w,phi_mesh%gauss%n_w):: tphi
649 REAL(KIND=8),
DIMENSION(9,H_mesh%gauss%n_w,H_mesh%gauss%n_w) :: hsij
650 REAL(KIND=8),
DIMENSION(phi_mesh%gauss%n_w,phi_mesh%gauss%n_w) :: phisij
651 REAL(KIND=8),
DIMENSION(6,phi_mesh%gauss%n_w,phi_mesh%gauss%n_w) :: sij
673 REAL(KIND=8),
DIMENSION(:,:),
POINTER :: ww_h
675 REAL(KIND=8),
DIMENSION(:,:,:,:),
POINTER :: dw_h
677 REAL(KIND=8),
DIMENSION(:,:),
POINTER :: rj_h
679 REAL(KIND=8),
DIMENSION(:,:),
POINTER :: ww_phi
681 REAL(KIND=8),
DIMENSION(:,:,:,:),
POINTER :: dw_phi
682 REAL(KIND=8),
DIMENSION(2,H_mesh%gauss%n_w,H_mesh%gauss%l_G) :: dwp
683 REAL(KIND=8),
DIMENSION(H_mesh%gauss%n_w,H_mesh%gauss%l_G) :: wwp
685 REAL(KIND=8),
DIMENSION(:,:),
POINTER :: rj_phi
687 REAL(KIND=8),
DIMENSION(2,phi_mesh%gauss%l_Gs) :: gauss1, gauss2
689 REAL(KIND=8) ::
ref, diff, mu_h, c_mu_h, c_mu_phi, muhl, &
690 dzmuhl, drmuhl, c_div, hloc, viscolm, xij, eps
692 REAL(KIND=8) :: c_sym=.0d0
695 REAL(KIND=8) :: c_lap
700 REAL(KIND=8),
DIMENSION(3*H_mesh%gauss%n_w+pmag_mesh%gauss%n_w+ &
phi_mesh%gauss%n_w , 3*H_mesh%gauss%n_w+pmag_mesh%gauss%n_w+ &
phi_mesh%gauss%n_w) :: mat_loc1, mat_loc2
701 INTEGER ,
DIMENSION(3*H_mesh%gauss%n_w+pmag_mesh%gauss%n_w+ &
phi_mesh%gauss%n_w) :: idxn, jdxn
704 INTEGER :: n_wpmag, n_wh, n_wphi, ix, jx
706 REAL(KIND=8) :: sigma_np_gauss
709 #include "petsc/finclude/petsc.h"
710 mat :: h_p_phi_mat1, h_p_phi_mat2
711 petscerrorcode :: ierr
713 CALL matzeroentries(h_p_phi_mat1, ierr)
714 CALL matzeroentries(h_p_phi_mat2, ierr)
715 CALL matsetoption(h_p_phi_mat1, mat_row_oriented, petsc_false, ierr)
716 CALL matsetoption(h_p_phi_mat2, mat_row_oriented, petsc_false, ierr)
720 stab_colle_h_phi = stab(2)
724 c_mu_phi = c_mass*mu_phi
726 ww_h => h_mesh%gauss%ww
727 dw_h => h_mesh%gauss%dw
728 rj_h => h_mesh%gauss%rj
729 ww_phi => phi_mesh%gauss%ww
730 dw_phi => phi_mesh%gauss%dw
731 rj_phi => phi_mesh%gauss%rj
733 n_wh = h_mesh%gauss%n_w
734 n_wpmag = pmag_mesh%gauss%n_w
735 n_wphi = phi_mesh%gauss%n_w
745 DO l = 1, h_mesh%gauss%l_G
746 hloc = sqrt(sum(h_mesh%gauss%rj(:,m)))**(2*alpha)
749 muhl = sum(mu_h_field(h_mesh%jj(:,m))*ww_h(:,l))
750 drmuhl = sum(mu_h_field(h_mesh%jj(:,m))*dw_h(1,:,l,m))
751 dzmuhl = sum(mu_h_field(h_mesh%jj(:,m))*dw_h(2,:,l,m))
755 sigma_np_gauss = sum(sigma_np(h_mesh%jj(:,m))*ww_h(:,l))
758 c_div = stab_div*hloc
767 DO ni = 1, h_mesh%gauss%n_w; i = h_mesh%jj(ni,m)
768 ray = ray + h_mesh%rr(1,i)*ww_h(ni,l)
771 DO ni = 1, h_mesh%gauss%n_w
772 DO nj = 1, h_mesh%gauss%n_w
777 th(1,ni,nj) = th(1,ni,nj) + rj_h(l,m) * ray* ( &
780 c_mass*mu_h_field(j)*ww_h(nj,l)*ww_h(ni,l) &
781 + (dw_h(2,ni,l,m)*dw_h(2,nj,l,m) + mode**2/ray**2*ww_h(ni,l)*ww_h(nj,l))/sigma_np_gauss &
783 + c_div*(muhl*(ww_h(ni,l)/ray+dw_h(1,ni,l,m)) + ww_h(ni,l)*drmuhl) &
784 *(muhl*(ww_h(nj,l)/ray+dw_h(1,nj,l,m)) + ww_h(nj,l)*drmuhl))
789 th(2,ni,nj) = th(2,ni,nj)+ rj_h(l,m) * ray* ( &
790 mode/ray**2 * ww_h(ni,l)*(ww_h(nj,l)+ray*dw_h(1,nj,l,m))/sigma_np_gauss &
792 + c_div*mode/ray*(muhl*(ww_h(ni,l)/ray+dw_h(1,ni,l,m)) &
793 + ww_h(ni,l)*drmuhl)*muhl*ww_h(nj,l))
797 th(8,ni,nj) = th(8,ni,nj)+ rj_h(l,m) * ray* ( &
798 - mode/ray**2 * ww_h(ni,l)*(ww_h(nj,l)+ray*dw_h(1,nj,l,m))/sigma_np_gauss &
800 - c_div*mode/ray*(muhl*(ww_h(ni,l)/ray+dw_h(1,ni,l,m)) &
801 + ww_h(ni,l)*drmuhl)*muhl*ww_h(nj,l))
805 th(3,ni,nj) = th(3,ni,nj)+ rj_h(l,m) * ray* ( &
806 - dw_h(2,ni,l,m)*dw_h(1,nj,l,m)/sigma_np_gauss &
808 + c_div*(muhl*(ww_h(ni,l)/ray+dw_h(1,ni,l,m)) + ww_h(ni,l)*drmuhl)*&
809 (muhl*dw_h(2,nj,l,m) + ww_h(nj,l)*dzmuhl))
813 th(4,ni,nj) = th(4,ni,nj) + rj_h(l,m) * ray* ( &
816 c_mass*mu_h_field(j)*ww_h(nj,l)*ww_h(ni,l) &
817 + (dw_h(2,ni,l,m)*dw_h(2,nj,l,m) &
818 + 1/ray**2 *(ww_h(ni,l)+ray*dw_h(1,ni,l,m))*(ww_h(nj,l)&
819 +ray*dw_h(1,nj,l,m)))/sigma_np_gauss &
821 +c_div*muhl**2*mode**2/ray**2*ww_h(ni,l)*ww_h(nj,l))
825 th(5,ni,nj) = th(5,ni,nj) + rj_h(l,m) * ray* (&
826 + mode/ray*dw_h(2,ni,l,m)*ww_h(nj,l)/sigma_np_gauss &
828 +c_div*mode/ray*muhl*ww_h(ni,l)*(muhl*dw_h(2,nj,l,m) + ww_h(nj,l)*dzmuhl))
832 th(9,ni,nj) = th(9,ni,nj) + rj_h(l,m) * ray* (&
833 - mode/ray*dw_h(2,ni,l,m)*ww_h(nj,l)/sigma_np_gauss &
835 - c_div*mode/ray*muhl*ww_h(ni,l)*(muhl*dw_h(2,nj,l,m) + ww_h(nj,l)*dzmuhl))
839 th(6,ni,nj) = th(6,ni,nj) + rj_h(l,m) * ray* ( &
842 c_mass*mu_h_field(j)*ww_h(nj,l)*ww_h(ni,l) &
843 + (mode**2/ray**2*ww_h(ni,l)*ww_h(nj,l) + dw_h(1,ni,l,m)*dw_h(1,nj,l,m))/sigma_np_gauss &
845 + c_div*(muhl*dw_h(2,ni,l,m) + ww_h(ni,l)*dzmuhl) &
846 *(muhl*dw_h(2,nj,l,m) + ww_h(nj,l)*dzmuhl))
928 ib = la_h%loc_to_glob(ki,i)
934 jb = la_h%loc_to_glob(kj,j)
938 IF ((ki == 1) .AND. (kj == 1))
THEN
939 mat_loc1(ix,jx) = th(1,ni,nj)
940 mat_loc2(ix,jx) = th(1,ni,nj)
941 ELSEIF ((ki == 1) .AND. (kj == 2))
THEN
942 mat_loc1(ix,jx) = th(2,ni,nj)
943 mat_loc2(ix,jx) = th(8,ni,nj)
944 ELSEIF ((ki == 2) .AND. (kj == 1))
THEN
945 mat_loc1(ix,jx) = th(2,nj,ni)
946 mat_loc2(ix,jx) = th(8,nj,ni)
947 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
948 mat_loc1(ix,jx) = th(3,ni,nj)
949 mat_loc2(ix,jx) = th(3,ni,nj)
950 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
951 mat_loc1(ix,jx) = th(3,nj,ni)
952 mat_loc2(ix,jx) = th(3,nj,ni)
953 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
954 mat_loc1(ix,jx) = th(4,ni,nj)
955 mat_loc2(ix,jx) = th(4,ni,nj)
956 ELSEIF ((ki == 2) .AND. (kj == 3))
THEN
957 mat_loc1(ix,jx) = th(5,ni,nj)
958 mat_loc2(ix,jx) = th(9,ni,nj)
959 ELSEIF ((ki == 3) .AND. (kj == 2))
THEN
960 mat_loc1(ix,jx) = th(5,nj,ni)
961 mat_loc2(ix,jx) = th(9,nj,ni)
962 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
963 mat_loc1(ix,jx) = th(6,ni,nj)
964 mat_loc2(ix,jx) = th(6,ni,nj)
971 CALL matsetvalues(h_p_phi_mat1, 3*n_wh, idxn(1:3*n_wh), 3*n_wh, jdxn(1:3*n_wh), &
972 mat_loc1(1:3*n_wh,1:3*n_wh), add_values, ierr)
973 CALL matsetvalues(h_p_phi_mat2, 3*n_wh, idxn(1:3*n_wh), 3*n_wh, jdxn(1:3*n_wh), &
974 mat_loc2(1:3*n_wh,1:3*n_wh), add_values, ierr)
978 DO m = 1, pmag_mesh%me
979 hloc = stab_div*sqrt(sum(pmag_mesh%gauss%rj(:,m)))**(2*(1-alpha))
981 DO l = 1, pmag_mesh%gauss%l_G
990 DO ni = 1, pmag_mesh%gauss%n_w
991 i = pmag_mesh%jj(ni,m)
992 ray = ray + pmag_mesh%rr(1,i)*pmag_mesh%gauss%ww(ni,l)
994 viscolm = hloc*muhl*pmag_mesh%gauss%rj(l,m)
995 DO nj = 1, pmag_mesh%gauss%n_w
996 j = pmag_mesh%jj(nj, m)
997 DO ni = 1, pmag_mesh%gauss%n_w
998 i = pmag_mesh%jj(ni, m)
1002 xij = xij + pmag_mesh%gauss%dw(k,nj,l,m) * pmag_mesh%gauss%dw(k,ni,l,m)
1005 tpmag(ni,nj) = tpmag(ni,nj) + ray * viscolm* xij &
1006 + viscolm*mode**2*pmag_mesh%gauss%ww(ni,l)*pmag_mesh%gauss%ww(nj,l)/ray
1011 DO ni = 1, pmag_mesh%gauss%n_w
1012 i = pmag_mesh%jj(ni, m)
1013 ib = la_pmag%loc_to_glob(1,i)
1015 DO nj = 1, pmag_mesh%gauss%n_w
1016 j = pmag_mesh%jj(nj, m)
1017 jb = la_pmag%loc_to_glob(1,j)
1021 CALL matsetvalues(h_p_phi_mat1, n_wpmag, idxn(1:n_wpmag), n_wpmag, jdxn(1:n_wpmag), &
1022 tpmag(1:n_wpmag,1:n_wpmag), add_values, ierr)
1023 CALL matsetvalues(h_p_phi_mat2, n_wpmag, idxn(1:n_wpmag), n_wpmag, jdxn(1:n_wpmag), &
1024 tpmag(1:n_wpmag,1:n_wpmag), add_values, ierr)
1029 DO m = 1, pmag_mesh%me
1030 IF (h_mesh%gauss%n_w==3)
THEN
1031 dwp=h_mesh%gauss%dw(:,:,:,m)
1034 dwp(:,1,:) = h_mesh%gauss%dw(:,1,:,m) + 0.5d0*(h_mesh%gauss%dw(:,5,:,m)+h_mesh%gauss%dw(:,6,:,m))
1035 dwp(:,2,:) = h_mesh%gauss%dw(:,2,:,m) + 0.5d0*(h_mesh%gauss%dw(:,6,:,m)+h_mesh%gauss%dw(:,4,:,m))
1036 dwp(:,3,:) = h_mesh%gauss%dw(:,3,:,m) + 0.5d0*(h_mesh%gauss%dw(:,4,:,m)+h_mesh%gauss%dw(:,5,:,m))
1037 wwp(1,:) = h_mesh%gauss%ww(1,:) + 0.5d0*(h_mesh%gauss%ww(5,:)+h_mesh%gauss%ww(6,:))
1038 wwp(2,:) = h_mesh%gauss%ww(2,:) + 0.5d0*(h_mesh%gauss%ww(6,:)+h_mesh%gauss%ww(4,:))
1039 wwp(3,:) = h_mesh%gauss%ww(3,:) + 0.5d0*(h_mesh%gauss%ww(4,:)+h_mesh%gauss%ww(5,:))
1043 DO l = 1, h_mesh%gauss%l_G
1045 DO ni = 1, h_mesh%gauss%n_w
1047 ray = ray + h_mesh%rr(1,i)*h_mesh%gauss%ww(ni,l)
1049 muhl = stab_div*ray*h_mesh%gauss%rj(l,m)*sum(mu_h_field(h_mesh%jj(:,m))*h_mesh%gauss%ww(:,l))
1050 DO nj = 1, pmag_mesh%gauss%n_w
1051 j = pmag_mesh%jj(nj, m)
1052 DO ni = 1, h_mesh%gauss%n_w
1053 i = h_mesh%jj(ni, m)
1054 thpmag(1,ni,nj) = thpmag(1,ni,nj) + muhl*dwp(1,nj,l)*h_mesh%gauss%ww(ni,l)
1055 thpmag(2,ni,nj) = thpmag(2,ni,nj) - muhl*mode*wwp(nj,l)*h_mesh%gauss%ww(ni,l)/ray
1056 thpmag(3,ni,nj) = thpmag(3,ni,nj) + muhl*dwp(2,nj,l)*h_mesh%gauss%ww(ni,l)
1066 i = h_mesh%jj(ni, m)
1073 ib = la_h%loc_to_glob(k,i)
1074 ix = (k-1)*n_wh + ni
1077 j = pmag_mesh%jj(nj, m)
1078 jb = la_pmag%loc_to_glob(1,j)
1081 mat_loc1(ix,jx) = thpmag(k,ni,nj)
1082 mat_loc2(ix,jx) = eps*thpmag(k,ni,nj)
1087 CALL matsetvalues(h_p_phi_mat1, 3*n_wh, idxn(1:3*n_wh), n_wpmag, jdxn(1:n_wpmag), &
1088 mat_loc1(1:3*n_wh,1:n_wpmag), add_values, ierr)
1089 CALL matsetvalues(h_p_phi_mat2, 3*n_wh, idxn(1:3*n_wh), n_wpmag, jdxn(1:n_wpmag), &
1090 mat_loc2(1:3*n_wh,1:n_wpmag), add_values, ierr)
1095 i = pmag_mesh%jj(ni, m)
1096 ib = la_pmag%loc_to_glob(1,i)
1106 j = h_mesh%jj(nj, m)
1107 jb = la_h%loc_to_glob(k,j)
1108 jx = (k-1)*n_wh + nj
1110 mat_loc1(ix,jx) = - thpmag(k,nj,ni)
1111 mat_loc2(ix,jx) = - eps*thpmag(k,nj,ni)
1115 CALL matsetvalues(h_p_phi_mat1, n_wpmag, idxn(1:n_wpmag), 3*n_wh, jdxn(1:3*n_wh), &
1116 mat_loc1(1:n_wpmag,1:3*n_wh), add_values, ierr)
1117 CALL matsetvalues(h_p_phi_mat2, n_wpmag, idxn(1:n_wpmag), 3*n_wh, jdxn(1:3*n_wh), &
1118 mat_loc2(1:n_wpmag,1:3*n_wh), add_values, ierr)
1123 DO m = 1,phi_mesh%me
1127 DO l = 1, phi_mesh%gauss%l_G
1131 DO ni = 1, phi_mesh%gauss%n_w; i = phi_mesh%jj(ni,m)
1132 ray = ray + phi_mesh%rr(1,i)*ww_phi(ni,l)
1135 DO ni = 1, phi_mesh%gauss%n_w
1136 DO nj = 1, phi_mesh%gauss%n_w
1144 tphi(ni,nj) = tphi(ni,nj) + rj_phi(l,m) * ray* (c_mass+c_lap)*mu_phi &
1145 *(dw_phi(1,ni,l,m)*dw_phi(1,nj,l,m)+dw_phi(2,ni,l,m)*dw_phi(2,nj,l,m) &
1146 +mode**2/ray**2*ww_phi(ni,l)*ww_phi(nj,l))
1156 DO ni = 1, phi_mesh%gauss%n_w
1157 i = phi_mesh%jj(ni, m)
1158 ib = la_phi%loc_to_glob(1,i)
1160 DO nj = 1, phi_mesh%gauss%n_w
1161 j = phi_mesh%jj(nj, m)
1162 jb = la_phi%loc_to_glob(1,j)
1166 CALL matsetvalues(h_p_phi_mat1, n_wphi, idxn(1:n_wphi), n_wphi, jdxn(1:n_wphi), &
1167 tphi(1:n_wphi,1:n_wphi), add_values, ierr)
1168 CALL matsetvalues(h_p_phi_mat2, n_wphi, idxn(1:n_wphi), n_wphi, jdxn(1:n_wphi), &
1169 tphi(1:n_wphi,1:n_wphi), add_values, ierr)
1177 CALL
gauss(phi_mesh)
1178 n_ws1 = h_mesh%gauss%n_ws
1179 n_ws2 = phi_mesh%gauss%n_ws
1180 n_w1 = h_mesh%gauss%n_w
1181 n_w2 = phi_mesh%gauss%n_w
1183 IF (h_mesh%gauss%n_ws == n_ws)
THEN
1185 DO ms = 1, interface_h_phi%mes
1187 ms2 = interface_h_phi%mesh2(ms)
1188 m2 = phi_mesh%neighs(ms2)
1189 ms1 = interface_h_phi%mesh1(ms)
1190 m1 = h_mesh%neighs(ms1)
1192 ref = 1.d-8+sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - h_mesh%rr(:,h_mesh%jjs(2,ms1)))**2)
1193 diff = sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - phi_mesh%rr(:,phi_mesh%jjs(1,ms2)))**2)
1194 IF (diff/
ref .LT. 1.d-10)
THEN
1198 w_cs(1,ls)= wws(2,ls)
1199 w_cs(2,ls)= wws(1,ls)
1200 w_cs(3,ls)= wws(3,ls)
1201 WRITE(*,*)
' Ouaps! oder of shape functions changed?'
1206 gauss2(1,ls) = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))*phi_mesh%gauss%wws(:,ls))
1207 gauss2(2,ls) = sum(phi_mesh%rr(2,phi_mesh%jjs(:,ms2))*phi_mesh%gauss%wws(:,ls))
1208 gauss1(1,ls) = sum( h_mesh%rr(1, h_mesh%jjs(:,ms1))* h_mesh%gauss%wws(:,ls))
1209 gauss1(2,ls) = sum( h_mesh%rr(2, h_mesh%jjs(:,ms1))* h_mesh%gauss%wws(:,ls))
1213 ref = sqrt(1.d-8+sum(gauss2(:,ls2)**2))
1216 diff = sqrt(sum((gauss2(:,ls2)-gauss1(:,ls1))**2))
1217 IF (diff .LT. 1.d-10)
THEN
1218 dw_cs(:,:,ls2,ms1) = h_mesh%gauss%dw_s(:,:,ls1,ms1)
1223 IF (.NOT.mark)
WRITE(*,*)
' BUG '
1229 DO ms = 1, interface_h_phi%mes
1231 ms2 = interface_h_phi%mesh2(ms)
1232 m2 = phi_mesh%neighs(ms2)
1233 ms1 = interface_h_phi%mesh1(ms)
1234 m1 = h_mesh%neighs(ms1)
1236 ref = 1.d-8+sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - h_mesh%rr(:,h_mesh%jjs(2,ms1)))**2)
1237 diff = sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - phi_mesh%rr(:,phi_mesh%jjs(1,ms2)))**2)
1238 IF (diff/
ref .LT. 1.d-10)
THEN
1240 w_cs(1,ls)= wws(1,ls)+0.5*wws(3,ls)
1241 w_cs(2,ls)= wws(2,ls)+0.5*wws(3,ls)
1246 w_cs(1,ls)= wws(2,ls)+0.5*wws(3,ls)
1247 w_cs(2,ls)= wws(1,ls)+0.5*wws(3,ls)
1249 WRITE(*,*)
' Ouaps! oder of shape functions changed?'
1254 dw_cs(1,:,ls,ms1) = h_mesh%gauss%dw(1,:,1,m1)
1255 dw_cs(2,:,ls,ms1) = h_mesh%gauss%dw(2,:,1,m1)
1262 DO ms = 1, interface_h_phi%mes
1264 ms2 = interface_h_phi%mesh2(ms)
1265 ms1 = interface_h_phi%mesh1(ms)
1266 m2 = phi_mesh%neighs(ms2)
1267 m1 = h_mesh%neighs(ms1)
1268 mu_h = sum(mu_h_field(h_mesh%jj(:,m1)))/h_mesh%gauss%n_w
1270 hm1 = stab_colle_h_phi/sum(rjs(:,ms2))
1284 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1285 x = hm1*rjs(ls,ms2)*ray
1289 y = x * w_cs(ni,ls)*w_cs(nj,ls)
1290 hsij(1,ni,nj) = hsij(1,ni,nj) + y*(rnorms(2,ls,ms2)**2)
1291 hsij(4,ni,nj) = hsij(4,ni,nj) - y*rnorms(1,ls,ms2)*rnorms(2,ls,ms2)
1292 hsij(5,ni,nj) = hsij(5,ni,nj) + y
1293 hsij(6,ni,nj) = hsij(6,ni,nj) + y*(rnorms(1,ls,ms2)**2)
1308 i = interface_h_phi%jjs1(ni,ms)
1309 ib = la_h%loc_to_glob(ki,i)
1310 ix = (ki-1)*n_ws1+ni
1314 j = interface_h_phi%jjs1(nj,ms)
1315 jb = la_h%loc_to_glob(kj,j)
1316 jx = (kj-1)*n_ws1+nj
1318 IF ((ki == 1) .AND. (kj == 1))
THEN
1319 mat_loc1(ix,jx) = hsij(1,ni,nj)
1320 mat_loc2(ix,jx) = hsij(1,ni,nj)
1321 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
1322 mat_loc1(ix,jx) = hsij(4,ni,nj)
1323 mat_loc2(ix,jx) = hsij(4,ni,nj)
1324 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
1325 mat_loc1(ix,jx) = hsij(4,nj,ni)
1326 mat_loc2(ix,jx) = hsij(4,nj,ni)
1327 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
1328 mat_loc1(ix,jx) = hsij(5,ni,nj)
1329 mat_loc2(ix,jx) = hsij(5,ni,nj)
1330 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
1331 mat_loc1(ix,jx) = hsij(6,ni,nj)
1332 mat_loc2(ix,jx) = hsij(6,ni,nj)
1338 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1, idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
1339 mat_loc1(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
1340 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1, idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
1341 mat_loc2(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
1348 DO ls = 1, phi_mesh%gauss%l_Gs
1351 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1354 x = rjs(ls,ms2)*ray/sum(sigma_np(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
1359 y = x*w_cs(ni,ls)*w_cs(nj,ls)
1360 hsij(2,ni,nj) = hsij(2,ni,nj) + y * (-mode/ray)*(-rnorms(1,ls,ms2))
1361 hsij(3,ni,nj) = hsij(3,ni,nj) + y * mode/ray *(-rnorms(1,ls,ms2))
1362 hsij(5,ni,nj) = hsij(5,ni,nj) + y * (-1/ray) *(-rnorms(1,ls,ms2))
1363 hsij(8,ni,nj) = hsij(8,ni,nj) + y * (-mode/ray)*(-rnorms(2,ls,ms2))
1364 hsij(9,ni,nj) = hsij(9,ni,nj) + y * mode/ray *(-rnorms(2,ls,ms2))
1378 i = interface_h_phi%jjs1(ni,ms)
1379 ib = la_h%loc_to_glob(ki,i)
1380 ix = (ki-1)*n_ws1 + ni
1384 j = interface_h_phi%jjs1(nj,ms)
1385 jb = la_h%loc_to_glob(kj,j)
1386 jx = (kj-1)*n_ws1 + nj
1388 IF ( (ki == 2) .AND. (kj == 1))
THEN
1389 mat_loc1(ix,jx) = hsij(2,ni,nj)
1390 mat_loc2(ix,jx) = hsij(3,ni,nj)
1391 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
1392 mat_loc1(ix,jx) = hsij(5,ni,nj)
1393 mat_loc2(ix,jx) = hsij(5,ni,nj)
1394 ELSEIF ( (ki == 2) .AND. (kj == 3))
THEN
1395 mat_loc1(ix,jx) = hsij(8,ni,nj)
1396 mat_loc2(ix,jx) = hsij(9,ni,nj)
1402 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1, idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
1403 mat_loc1(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
1404 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1, idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
1405 mat_loc2(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
1413 i = interface_h_phi%jjs1(ni,ms)
1414 ib = la_h%loc_to_glob(ki,i)
1415 ix = (ki-1)*n_ws1 + ni
1419 j = interface_h_phi%jjs1(nj,ms)
1420 jb = la_h%loc_to_glob(kj,j)
1421 jx = (kj-1)*n_ws1 + nj
1423 IF ( (kj == 2) .AND. (ki == 1))
THEN
1424 mat_loc1(ix,jx) = hsij(2,nj,ni)
1425 mat_loc2(ix,jx) = hsij(3,nj,ni)
1426 ELSEIF ((kj == 2) .AND. (ki == 2))
THEN
1427 mat_loc1(ix,jx) = hsij(5,nj,ni)
1428 mat_loc2(ix,jx) = hsij(5,nj,ni)
1429 ELSEIF ( (kj == 2) .AND. (ki == 3))
THEN
1430 mat_loc1(ix,jx) = hsij(8,nj,ni)
1431 mat_loc2(ix,jx) = hsij(9,nj,ni)
1438 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1, idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
1439 mat_loc1(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
1440 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1, idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
1441 mat_loc2(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
1444 DO ls = 1, phi_mesh%gauss%l_Gs
1447 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1450 x = rjs(ls,ms2)*ray/sum(sigma_np(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
1456 hsij(1,ni,nj) = hsij(1,ni,nj) + y*(-dw_cs(2,nj,ls,ms1))*(-rnorms(2,ls,ms2))
1457 hsij(4,ni,nj) = hsij(4,ni,nj) + y* dw_cs(1,nj,ls,ms1) *(-rnorms(2,ls,ms2))
1458 hsij(5,ni,nj) = hsij(5,ni,nj) + &
1459 y*(-dw_cs(2,nj,ls,ms1)*(-rnorms(2,ls,ms2))-dw_cs(1,nj,ls,ms1)*(-rnorms(1,ls,ms2)))
1460 hsij(6,ni,nj) = hsij(6,ni,nj) + y*(-dw_cs(1,nj,ls,ms1))*(-rnorms(1,ls,ms2))
1461 hsij(7,ni,nj) = hsij(7,ni,nj) + y* dw_cs(2,nj,ls,ms1) *(-rnorms(1,ls,ms2))
1474 i = interface_h_phi%jjs1(ni,ms)
1475 ib = la_h%loc_to_glob(ki,i)
1476 ix = (ki-1)*n_ws1 + ni
1480 j = h_mesh%jj(nj,m1)
1481 jb = la_h%loc_to_glob(kj,j)
1482 jx = (kj-1)*n_w1 + nj
1484 IF ((ki == 1) .AND. (kj == 1))
THEN
1485 mat_loc1(ix,jx) = hsij(1,ni,nj)
1486 mat_loc2(ix,jx) = hsij(1,ni,nj)
1487 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
1488 mat_loc1(ix,jx) = hsij(4,ni,nj)
1489 mat_loc2(ix,jx) = hsij(4,ni,nj)
1490 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
1491 mat_loc1(ix,jx) = hsij(5,ni,nj)
1492 mat_loc2(ix,jx) = hsij(5,ni,nj)
1493 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
1494 mat_loc1(ix,jx) = hsij(6,ni,nj)
1495 mat_loc2(ix,jx) = hsij(6,ni,nj)
1496 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
1497 mat_loc1(ix,jx) = hsij(7,ni,nj)
1498 mat_loc2(ix,jx) = hsij(7,ni,nj)
1505 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1, idxn(1:3*n_ws1), 3*n_w1, jdxn(1:3*n_w1), &
1506 mat_loc1(1:3*n_ws1,1:3*n_w1), add_values, ierr)
1507 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1, idxn(1:3*n_ws1), 3*n_w1, jdxn(1:3*n_w1), &
1508 mat_loc2(1:3*n_ws1,1:3*n_w1), add_values, ierr)
1516 i = h_mesh%jj(ni,m1)
1517 ib = la_h%loc_to_glob(ki,i)
1518 ix = (ki-1)*n_w1 + ni
1522 j = interface_h_phi%jjs1(nj,ms)
1523 jb = la_h%loc_to_glob(kj,j)
1524 jx = (kj-1)*n_ws1 + nj
1526 IF ((kj == 1) .AND. (ki == 1))
THEN
1527 mat_loc1(ix,jx) = hsij(1,nj,ni)
1528 mat_loc2(ix,jx) = hsij(1,nj,ni)
1529 ELSEIF ((kj == 1) .AND. (ki == 3))
THEN
1530 mat_loc1(ix,jx) = hsij(4,nj,ni)
1531 mat_loc2(ix,jx) = hsij(4,nj,ni)
1532 ELSEIF ((kj == 2) .AND. (ki == 2))
THEN
1533 mat_loc1(ix,jx) = hsij(5,nj,ni)
1534 mat_loc2(ix,jx) = hsij(5,nj,ni)
1535 ELSEIF ((kj == 3) .AND. (ki == 3))
THEN
1536 mat_loc1(ix,jx) = hsij(6,nj,ni)
1537 mat_loc2(ix,jx) = hsij(6,nj,ni)
1538 ELSEIF ((kj == 3) .AND. (ki == 1))
THEN
1539 mat_loc1(ix,jx) = hsij(7,nj,ni)
1540 mat_loc2(ix,jx) = hsij(7,nj,ni)
1546 CALL matsetvalues(h_p_phi_mat1, 3*n_w1, idxn(1:3*n_w1), 3*n_ws1, jdxn(1:3*n_ws1), &
1547 mat_loc1(1:3*n_w1,1:3*n_ws1), add_values, ierr)
1548 CALL matsetvalues(h_p_phi_mat2, 3*n_w1, idxn(1:3*n_w1), 3*n_ws1, jdxn(1:3*n_ws1), &
1549 mat_loc2(1:3*n_w1,1:3*n_ws1), add_values, ierr)
1562 DO ls = 1, phi_mesh%gauss%l_Gs
1565 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1566 x = hm1*rjs(ls,ms2)*ray
1571 phisij(ni,nj) = phisij(ni,nj) + x*mode**2/ray**2*wws(ni,ls)*wws(nj,ls)
1582 i = interface_h_phi%jjs2(ni,ms)
1583 ib = la_phi%loc_to_glob(1,i)
1586 j = interface_h_phi%jjs2(nj,ms)
1587 jb = la_phi%loc_to_glob(1,j)
1591 CALL matsetvalues(h_p_phi_mat1, n_ws2, idxn(1:n_ws2), n_ws2, jdxn(1:n_ws2), &
1592 phisij(1:n_ws2,1:n_ws2), add_values, ierr)
1593 CALL matsetvalues(h_p_phi_mat2, n_ws2, idxn(1:n_ws2), n_ws2, jdxn(1:n_ws2), &
1594 phisij(1:n_ws2,1:n_ws2), add_values, ierr)
1600 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1601 x = hm1*rjs(ls,ms2)*ray
1606 phisij(ni,nj) = phisij(ni,nj) + x*( &
1607 (dw_s(2,ni,ls,ms2)*rnorms(1,ls,ms2) - dw_s(1,ni,ls,ms2)*rnorms(2,ls,ms2))* &
1608 (dw_s(2,nj,ls,ms2)*rnorms(1,ls,ms2) - dw_s(1,nj,ls,ms2)*rnorms(2,ls,ms2)))
1618 i = phi_mesh%jj(ni, m2)
1619 ib = la_phi%loc_to_glob(1,i)
1622 j = phi_mesh%jj(nj, m2)
1623 jb = la_phi%loc_to_glob(1,j)
1627 CALL matsetvalues(h_p_phi_mat1, n_w2, idxn(1:n_w2), n_w2, jdxn(1:n_w2), &
1628 phisij(1:n_w2,1:n_w2), add_values, ierr)
1629 CALL matsetvalues(h_p_phi_mat2, n_w2, idxn(1:n_w2), n_w2, jdxn(1:n_w2), &
1630 phisij(1:n_w2,1:n_w2), add_values, ierr)
1644 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1645 x = hm1*rjs(ls,ms2)*ray
1650 sij(3,ni,nj) = sij(3,ni,nj) + x*(mode/ray)*w_cs(ni,ls)*wws(nj,ls)
1654 sij(4,:,:) = -sij(3,:,:)
1663 i = interface_h_phi%jjs1(ni,ms)
1664 ib = la_h%loc_to_glob(ki,i)
1667 j = interface_h_phi%jjs2(nj,ms)
1668 jb = la_phi%loc_to_glob(1,j)
1672 CALL matsetvalues(h_p_phi_mat1, n_ws1, idxn(1:n_ws1), n_ws2, jdxn(1:n_ws2), &
1673 sij(3,1:n_ws1,1:n_ws2), add_values, ierr)
1674 CALL matsetvalues(h_p_phi_mat2, n_ws1, idxn(1:n_ws1), n_ws2, jdxn(1:n_ws2), &
1675 sij(4,1:n_ws1,1:n_ws2), add_values, ierr)
1684 i = interface_h_phi%jjs2(ni,ms)
1685 ib = la_phi%loc_to_glob(1,i)
1688 j = interface_h_phi%jjs1(nj,ms)
1689 jb = la_h%loc_to_glob(kj,j)
1691 mat_loc1(ni,nj) = sij(3,nj,ni)
1692 mat_loc2(ni,nj) = sij(4,nj,ni)
1695 CALL matsetvalues(h_p_phi_mat1, n_ws2, idxn(1:n_ws2), n_ws1, jdxn(1:n_ws1), &
1696 mat_loc1(1:n_ws2,1:n_ws1), add_values, ierr)
1697 CALL matsetvalues(h_p_phi_mat2, n_ws2, idxn(1:n_ws2), n_ws1, jdxn(1:n_ws1), &
1698 mat_loc2(1:n_ws2,1:n_ws1), add_values, ierr)
1706 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1707 x = hm1*rjs(ls,ms2)*ray
1713 sij(1,ni,nj) = sij(1,ni,nj) + &
1714 y*(-dw_s(1,nj,ls,ms2)*rnorms(2,ls,ms2)**2 + dw_s(2,nj,ls,ms2)*rnorms(1,ls,ms2)*rnorms(2,ls,ms2))
1715 sij(5,ni,nj) = sij(5,ni,nj) + &
1716 y*(-dw_s(2,nj,ls,ms2)*rnorms(1,ls,ms2)**2 + dw_s(1,nj,ls,ms2)*rnorms(1,ls,ms2)*rnorms(2,ls,ms2))
1729 i = interface_h_phi%jjs1(ni,ms)
1730 ib = la_h%loc_to_glob(ki,i)
1731 ix = (ki-1)*n_ws1 + ni
1734 j = phi_mesh%jj(nj,m2)
1735 jb = la_phi%loc_to_glob(1,j)
1739 mat_loc1(ix,jx) = sij(1,ni,nj)
1740 mat_loc2(ix,jx) = sij(1,ni,nj)
1741 ELSEIF (ki == 3)
THEN
1742 mat_loc1(ix,jx) = sij(5,ni,nj)
1743 mat_loc2(ix,jx) = sij(5,ni,nj)
1748 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1, idxn(1:3*n_ws1), n_w2, jdxn(1:n_w2), &
1749 mat_loc1(1:3*n_ws1,1:n_w2), add_values, ierr)
1750 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1, idxn(1:3*n_ws1), n_w2, jdxn(1:n_w2), &
1751 mat_loc2(1:3*n_ws1,1:n_w2), add_values, ierr)
1759 i = phi_mesh%jj(ni,m2)
1760 ib = la_phi%loc_to_glob(1,i)
1765 j = interface_h_phi%jjs1(nj,ms)
1766 jb = la_h%loc_to_glob(kj,j)
1767 jx = (kj-1)*n_ws1 + nj
1770 mat_loc1(ix,jx) = sij(1,nj,ni)
1771 mat_loc2(ix,jx) = sij(1,nj,ni)
1772 ELSEIF (kj == 3)
THEN
1773 mat_loc1(ix,jx) = sij(5,nj,ni)
1774 mat_loc2(ix,jx) = sij(5,nj,ni)
1779 CALL matsetvalues(h_p_phi_mat1, n_w2, idxn(1:n_w2), 3*n_ws1, jdxn(1:3*n_ws1), &
1780 mat_loc1(1:n_w2,1:3*n_ws1), add_values, ierr)
1781 CALL matsetvalues(h_p_phi_mat2, n_w2, idxn(1:n_w2), 3*n_ws1, jdxn(1:3*n_ws1), &
1782 mat_loc2(1:n_w2,1:3*n_ws1), add_values, ierr)
1797 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1800 x = rjs(ls,ms2)*ray/sum(sigma_np(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
1805 y = x * wws(ni,ls)*w_cs(nj,ls)
1806 sij(1,ni,nj) = sij(1,ni,nj) + y*( mode/ray)**2*rnorms(1,ls,ms2)
1807 sij(3,ni,nj) = sij(3,ni,nj) + y*( mode/ray**2)*rnorms(1,ls,ms2)
1808 sij(4,ni,nj) = sij(4,ni,nj) + y*(-mode/ray**2)*rnorms(1,ls,ms2)
1809 sij(5,ni,nj) = sij(5,ni,nj) + y*( mode/ray)**2*rnorms(2,ls,ms2)
1821 i = interface_h_phi%jjs2(ni,ms)
1822 ib = la_phi%loc_to_glob(1,i)
1827 j = interface_h_phi%jjs1(nj,ms)
1828 jb = la_h%loc_to_glob(kj,j)
1829 jx = (kj-1)*n_ws1 + nj
1832 mat_loc1(ix,jx) = sij(1,ni,nj)
1833 mat_loc2(ix,jx) = sij(1,ni,nj)
1834 ELSEIF (kj == 2)
THEN
1835 mat_loc1(ix,jx) = sij(3,ni,nj)
1836 mat_loc2(ix,jx) = sij(4,ni,nj)
1837 ELSEIF (kj == 3)
THEN
1838 mat_loc1(ix,jx) = sij(5,ni,nj)
1839 mat_loc2(ix,jx) = sij(5,ni,nj)
1844 CALL matsetvalues(h_p_phi_mat1, n_ws2, idxn(1:n_ws2), 3*n_ws1, jdxn(1:3*n_ws1), &
1845 mat_loc1(1:n_ws2,1:3*n_ws1), add_values, ierr)
1846 CALL matsetvalues(h_p_phi_mat2, n_ws2, idxn(1:n_ws2), 3*n_ws1, jdxn(1:3*n_ws1), &
1847 mat_loc2(1:n_ws2,1:3*n_ws1), add_values, ierr)
1855 i = interface_h_phi%jjs1(ni,ms)
1856 ib = la_h%loc_to_glob(ki,i)
1857 ix = (ki-1)*n_ws1 + ni
1860 j = interface_h_phi%jjs2(nj,ms)
1861 jb = la_phi%loc_to_glob(1,j)
1865 mat_loc1(ix,jx) = sij(1,nj,ni)
1866 mat_loc2(ix,jx) = sij(1,nj,ni)
1867 ELSEIF (ki == 2)
THEN
1868 mat_loc1(ix,jx) = sij(3,nj,ni)
1869 mat_loc2(ix,jx) = sij(4,nj,ni)
1870 ELSEIF (ki == 3)
THEN
1871 mat_loc1(ix,jx) = sij(5,nj,ni)
1872 mat_loc2(ix,jx) = sij(5,nj,ni)
1877 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1, idxn(1:3*n_ws1), n_ws2, jdxn(1:n_ws2), &
1878 mat_loc1(1:3*n_ws1,1:n_ws2), add_values, ierr)
1879 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1, idxn(1:3*n_ws1), n_ws2, jdxn(1:n_ws2), &
1880 mat_loc2(1:3*n_ws1,1:n_ws2), add_values, ierr)
1888 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1891 x = rjs(ls,ms2)*ray/sum(sigma_np(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
1895 y = x*wws(ni,ls)*mode/ray
1897 sij(3,ni,nj) = sij(3,ni,nj) + &
1898 y*(dw_cs(2,nj,ls,ms1)*rnorms(2,ls,ms2) + dw_cs(1,nj,ls,ms1)*rnorms(1,ls,ms2))
1902 sij(4,:,:) = -sij(3,:,:)
1908 i = interface_h_phi%jjs2(ni,ms)
1909 ib = la_phi%loc_to_glob(1,i)
1912 j = h_mesh%jj(nj,m1)
1913 jb = la_h%loc_to_glob(kj,j)
1917 CALL matsetvalues(h_p_phi_mat1, n_ws2, idxn(1:n_ws2), n_w1, jdxn(1:n_w1), &
1918 sij(3,1:n_ws2,1:n_w1), add_values, ierr)
1919 CALL matsetvalues(h_p_phi_mat2, n_ws2, idxn(1:n_ws2), n_w1, jdxn(1:n_w1), &
1920 sij(4,1:n_ws2,1:n_w1), add_values, ierr)
1929 i = h_mesh%jj(ni,m1)
1930 ib = la_h%loc_to_glob(ki,i)
1933 j = interface_h_phi%jjs2(nj,ms)
1934 jb = la_phi%loc_to_glob(1,j)
1936 mat_loc1(ix,jx) = sij(3,nj,ni)
1937 mat_loc2(ix,jx) = sij(4,nj,ni)
1940 CALL matsetvalues(h_p_phi_mat1, n_w1, idxn(1:n_w1), n_ws2, jdxn(1:n_ws2), &
1941 mat_loc1(1:n_w1,1:n_ws2), add_values, ierr)
1942 CALL matsetvalues(h_p_phi_mat2, n_w1, idxn(1:n_w1), n_ws2, jdxn(1:n_ws2), &
1943 mat_loc2(1:n_w1,1:n_ws2), add_values, ierr)
1950 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
1953 x = rjs(ls,ms2)*ray/sum(sigma_np(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
1957 y = x*(dw_s(2,ni,ls,ms2)*rnorms(1,ls,ms2) - dw_s(1,ni,ls,ms2)*rnorms(2,ls,ms2))
1959 sij(1,ni,nj) = sij(1,ni,nj) + y *dw_cs(2,nj,ls,ms1)
1960 sij(5,ni,nj) = sij(5,ni,nj) + (-y)*dw_cs(1,nj,ls,ms1)
1972 i = phi_mesh%jj(ni,m2)
1973 ib = la_phi%loc_to_glob(1,i)
1977 j = h_mesh%jj(nj,m1)
1979 jb = la_h%loc_to_glob(kj,j)
1980 jx = (kj-1)*n_w1 + nj
1983 mat_loc1(ix,jx) = sij(1,ni,nj)
1984 mat_loc2(ix,jx) = sij(1,ni,nj)
1985 ELSEIF (kj == 3)
THEN
1986 mat_loc1(ix,jx) = sij(5,ni,nj)
1987 mat_loc2(ix,jx) = sij(5,ni,nj)
1992 CALL matsetvalues(h_p_phi_mat1, n_w2, idxn(1:n_w2), 3*n_w1, jdxn(1:3*n_w1), &
1993 mat_loc1(1:n_w2,1:3*n_w1), add_values, ierr)
1994 CALL matsetvalues(h_p_phi_mat2, n_w2, idxn(1:n_w2), 3*n_w1, jdxn(1:3*n_w1), &
1995 mat_loc2(1:n_w2,1:3*n_w1), add_values, ierr)
2003 i = h_mesh%jj(ni,m1)
2004 ib = la_h%loc_to_glob(ki,i)
2005 ix = (ki-1)*n_w1 + ni
2008 j = phi_mesh%jj(nj,m2)
2009 jb = la_phi%loc_to_glob(1,j)
2013 mat_loc1(ix,jx) = sij(1,nj,ni)
2014 mat_loc2(ix,jx) = sij(1,nj,ni)
2015 ELSEIF (ki == 3)
THEN
2016 mat_loc1(ix,jx) = sij(5,nj,ni)
2017 mat_loc2(ix,jx) = sij(5,nj,ni)
2022 CALL matsetvalues(h_p_phi_mat1, 3*n_w1, idxn(1:3*n_w1), n_w2, jdxn(1:n_w2), &
2023 mat_loc1(1:3*n_w1,1:n_w2), add_values, ierr)
2024 CALL matsetvalues(h_p_phi_mat2, 3*n_w1, idxn(1:3*n_w1), n_w2, jdxn(1:n_w2), &
2025 mat_loc2(1:3*n_w1,1:n_w2), add_values, ierr)
2032 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms2))* phi_mesh%gauss%wws(:,ls))
2033 muhl = sum(mu_h_field(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
2034 x = c_lap*muhl*rjs(ls,ms2)*ray
2037 sij(1,ni,nj) = sij(1,ni,nj) - x*w_cs(nj,ls)*wws(ni,ls)*rnorms(1,ls,ms2)
2038 sij(5,ni,nj) = sij(5,ni,nj) - x*w_cs(nj,ls)*wws(ni,ls)*rnorms(2,ls,ms2)
2046 i = interface_h_phi%jjs2(ni,ms)
2047 ib = la_phi%loc_to_glob(1,i)
2051 j = interface_h_phi%jjs1(nj,ms)
2052 jb = la_h%loc_to_glob(1,j)
2055 mat_loc1(ix,jx) = sij(1,ni,nj)
2056 mat_loc2(ix,jx) = sij(1,ni,nj)
2058 jb = la_h%loc_to_glob(3,j)
2061 mat_loc1(ix,jx) = sij(5,ni,nj)
2062 mat_loc2(ix,jx) = sij(5,ni,nj)
2065 CALL matsetvalues(h_p_phi_mat1, n_ws2, idxn(1:n_ws2), 2*n_ws1, jdxn(1:2*n_ws1), &
2066 mat_loc1(1:n_ws2,1:2*n_ws1), add_values, ierr)
2067 CALL matsetvalues(h_p_phi_mat2, n_ws2, idxn(1:n_ws2), 2*n_ws1, jdxn(1:2*n_ws1), &
2068 mat_loc2(1:n_ws2,1:2*n_ws1), add_values, ierr)
2079 IF (stab(2) > 1.d-12)
THEN
2088 ms2 = interface_h_phi%mesh2(ms)
2089 hm1 = sum(rjs(:,ms2))**(2*alpha-1)
2094 muhl = sum(mu_h_field(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
2097 DO ni = 1, n_ws2; i = phi_mesh%jjs(ni,ms2)
2098 ray = ray + phi_mesh%rr(1,i)* phi_mesh%gauss%wws(ni,ls)
2104 ray = stab_div*ray*hm1*rjs(ls,ms2)
2110 x = muhl**2*w_cs(ni,ls)*w_cs(nj,ls)*ray
2111 hsij(1,ni,nj) = hsij(1,ni,nj) + x*rnorms(1,ls,ms2)**2
2112 hsij(4,ni,nj) = hsij(4,ni,nj) + x*rnorms(1,ls,ms2)*rnorms(2,ls,ms2)
2113 hsij(6,ni,nj) = hsij(6,ni,nj) + x*rnorms(2,ls,ms2)**2
2117 x = muhl*mu_phi*w_cs(ni,ls)*(dw_s(1,nj,ls,ms2)*rnorms(1,ls,ms2) +&
2118 dw_s(2,nj,ls,ms2)*rnorms(2,ls,ms2))*ray
2119 sij(1,ni,nj) = sij(1,ni,nj) - x*rnorms(1,ls,ms2)
2120 sij(5,ni,nj) = sij(5,ni,nj) - x*rnorms(2,ls,ms2)
2126 x = mu_phi**2*(dw_s(1,ni,ls,ms2)*rnorms(1,ls,ms2) + dw_s(2,ni,ls,ms2)*rnorms(2,ls,ms2))* &
2127 (dw_s(1,nj,ls,ms2)*rnorms(1,ls,ms2) + dw_s(2,nj,ls,ms2)*rnorms(2,ls,ms2))*ray
2128 phisij(ni,nj) = phisij(ni,nj) + x
2133 sij(2,:,:) = sij(1,:,:)
2134 sij(6,:,:) = sij(5,:,:)
2140 i = h_mesh%jjs(ni,ms1)
2142 ib = la_h%loc_to_glob(ki,i)
2143 ix = (ki/2)*n_ws1 + ni
2146 j = h_mesh%jjs(nj,ms1)
2148 jb = la_h%loc_to_glob(kj,j)
2149 jx = (kj/2)*n_ws1 + nj
2152 mat_loc1(ix,jx) = hsij(1,ni,nj)
2153 mat_loc2(ix,jx) = hsij(1,ni,nj)
2154 ELSE IF (ki*kj==9)
THEN
2155 mat_loc1(ix,jx) = hsij(6,ni,nj)
2156 mat_loc2(ix,jx) = hsij(6,ni,nj)
2157 ELSE IF (ki*kj==3)
THEN
2158 mat_loc1(ix,jx) = hsij(4,ni,nj)
2159 mat_loc2(ix,jx) = hsij(4,ni,nj)
2165 j = phi_mesh%jj(nj,m2)
2166 jb = la_phi%loc_to_glob(1,j)
2169 mat_loc1(ix,jx) = sij(2*ki-1,ni,nj)
2170 mat_loc2(ix,jx) = sij(2*ki-1,ni,nj)
2174 CALL matsetvalues(h_p_phi_mat1, 2*n_ws1, idxn(1:2*n_ws1), 2*n_ws1+n_w2, jdxn(1:2*n_ws1+n_w2), &
2175 mat_loc1(1:2*n_ws1,1:2*n_ws1+n_w2), add_values, ierr)
2176 CALL matsetvalues(h_p_phi_mat2, 2*n_ws1, idxn(1:2*n_ws1), 2*n_ws1+n_w2, jdxn(1:2*n_ws1+n_w2), &
2177 mat_loc2(1:2*n_ws1,1:2*n_ws1+n_w2), add_values, ierr)
2182 i = phi_mesh%jj(ni,m2)
2183 ib = la_phi%loc_to_glob(1,i)
2187 j = h_mesh%jjs(nj,ms1)
2189 jb = la_h%loc_to_glob(kj,j)
2190 jx = (kj/2)*n_ws1 + nj
2192 mat_loc1(ix,jx) = sij(2*kj-1,nj,ni)
2193 mat_loc2(ix,jx) = sij(2*kj-1,nj,ni)
2198 j = phi_mesh%jj(nj,m2)
2199 jb = la_phi%loc_to_glob(1,j)
2202 mat_loc1(ix,jx) = phisij(ni,nj)
2203 mat_loc2(ix,jx) = phisij(ni,nj)
2206 CALL matsetvalues(h_p_phi_mat1, n_w2, idxn(1:n_w2), 2*n_ws1+n_w2, jdxn(1:2*n_ws1+n_w2), &
2207 mat_loc1(1:n_w2,1:2*n_ws1+n_w2), add_values, ierr)
2208 CALL matsetvalues(h_p_phi_mat2, n_w2, idxn(1:n_w2), 2*n_ws1+n_w2, jdxn(1:2*n_ws1+n_w2), &
2209 mat_loc2(1:n_w2,1:2*n_ws1+n_w2), add_values, ierr)
2220 IF (.NOT.present(index_fourier) .OR. .NOT.present(r_fourier))
RETURN
2221 IF (r_fourier.GT.0.d0)
THEN
2223 DO ms = 1, phi_mesh%mes
2224 IF (phi_mesh%sides(ms) /= index_fourier) cycle
2228 DO ls = 1, phi_mesh%gauss%l_Gs
2231 ray = sum(phi_mesh%rr(1,phi_mesh%jjs(:,ms))* phi_mesh%gauss%wws(:,ls))
2233 x = c_mu_phi*rjs(ls,ms)*ray/r_fourier
2235 DO ni=1, phi_mesh%gauss%n_ws
2236 DO nj=1, phi_mesh%gauss%n_ws
2237 phisij(ni,nj) = phisij(ni,nj) + x*wws(ni,ls)*wws(nj,ls)
2244 DO ni = 1, phi_mesh%gauss%n_ws
2245 i = phi_mesh%jjs(ni,ms)
2246 ib = la_phi%loc_to_glob(1,i)
2248 DO nj = 1, phi_mesh%gauss%n_ws
2249 j = phi_mesh%jjs(nj,ms)
2250 jb = la_phi%loc_to_glob(1,j)
2254 CALL matsetvalues(h_p_phi_mat1, n_ws2, idxn(1:n_ws2), n_ws2, jdxn(1:n_ws2), &
2255 phisij(1:n_ws2,1:n_ws2), add_values, ierr)
2256 CALL matsetvalues(h_p_phi_mat2, n_ws2, idxn(1:n_ws2), n_ws2, jdxn(1:n_ws2), &
2257 phisij(1:n_ws2,1:n_ws2), add_values, ierr)
2261 CALL matassemblybegin(h_p_phi_mat1,mat_final_assembly,ierr)
2262 CALL matassemblyend(h_p_phi_mat1,mat_final_assembly,ierr)
2263 CALL matassemblybegin(h_p_phi_mat2,mat_final_assembly,ierr)
2264 CALL matassemblyend(h_p_phi_mat2,mat_final_assembly,ierr)
2271 mode, stab, la_h, h_p_phi_mat1, h_p_phi_mat2, sigma_np)
2279 INTEGER,
DIMENSION(:),
INTENT(IN) :: dirichlet_bdy_h_sides
2280 INTEGER,
INTENT(IN) :: mode
2281 REAL(KIND=8),
DIMENSION(3),
INTENT(IN) :: stab
2282 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: sigma_np
2284 INTEGER :: ms, ls, ni, nj, i, j, &
2285 n_ws1, n_w1, m1, ki, kj, ib, jb
2286 REAL(KIND=8) :: x, y, hm1
2287 REAL(KIND=8) :: ray, error, stab_colle_h_mu
2288 REAL(KIND=8),
DIMENSION(9,H_mesh%gauss%n_w,H_mesh%gauss%n_w) :: hsij
2308 REAL(KIND=8) :: c_sym=.0d0
2313 REAL(KIND=8),
DIMENSION(3*H_mesh%gauss%n_w,3*H_mesh%gauss%n_w) :: mat_loc1, mat_loc2
2314 INTEGER ,
DIMENSION(3*H_mesh%gauss%n_w) :: idxn, jdxn
2319 #include "petsc/finclude/petsc.h"
2320 petscerrorcode :: ierr
2321 mat :: h_p_phi_mat1, h_p_phi_mat2
2324 stab_colle_h_mu = stab(3)
2331 n_ws1 = h_mesh%gauss%n_ws
2332 n_w1 = h_mesh%gauss%n_w
2340 DO count = 1,
SIZE(dirichlet_bdy_h_sides)
2341 ms = dirichlet_bdy_h_sides(count)
2342 hm1 = stab_colle_h_mu/sum(h_mesh%gauss%rjs(:,ms))
2343 m1 = h_mesh%neighs(ms)
2352 DO ls = 1, h_mesh%gauss%l_Gs
2354 ray = sum(h_mesh%rr(1,h_mesh%jjs(:,ms))*h_mesh%gauss%wws(:,ls))
2355 x = hm1*h_mesh%gauss%rjs(ls,ms)*ray
2357 DO ni = 1, h_mesh%gauss%n_ws
2358 DO nj = 1, h_mesh%gauss%n_ws
2359 y = x * h_mesh%gauss%wws(ni,ls)*h_mesh%gauss%wws(nj,ls)
2360 hsij(1,ni,nj) = hsij(1,ni,nj) + y*(h_mesh%gauss%rnorms(2,ls,ms)**2)
2361 hsij(4,ni,nj) = hsij(4,ni,nj) - y*h_mesh%gauss%rnorms(1,ls,ms)*h_mesh%gauss%rnorms(2,ls,ms)
2362 hsij(5,ni,nj) = hsij(5,ni,nj) + y
2363 hsij(6,ni,nj) = hsij(6,ni,nj) + y*(h_mesh%gauss%rnorms(1,ls,ms)**2)
2378 i = h_mesh%jjs(ni,ms)
2379 ib = la_h%loc_to_glob(ki,i)
2380 ix = ni + (ki-1)*n_ws1
2384 j = h_mesh%jjs(nj,ms)
2385 jb = la_h%loc_to_glob(kj,j)
2386 jx = nj + (kj-1)*n_ws1
2388 IF ((ki == 1) .AND. (kj == 1))
THEN
2389 mat_loc1(ix,jx) = hsij(1,ni,nj)
2390 mat_loc2(ix,jx) = hsij(1,ni,nj)
2391 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
2392 mat_loc1(ix,jx) = hsij(4,ni,nj)
2393 mat_loc2(ix,jx) = hsij(4,ni,nj)
2394 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
2395 mat_loc1(ix,jx) = hsij(4,nj,ni)
2396 mat_loc2(ix,jx) = hsij(4,nj,ni)
2397 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
2398 mat_loc1(ix,jx) = hsij(5,ni,nj)
2399 mat_loc2(ix,jx) = hsij(5,ni,nj)
2400 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
2401 mat_loc1(ix,jx) = hsij(6,ni,nj)
2402 mat_loc2(ix,jx) = hsij(6,ni,nj)
2409 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
2410 mat_loc1(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
2411 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
2412 mat_loc2(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
2423 DO ls = 1, h_mesh%gauss%l_Gs
2425 ray = sum(h_mesh%rr(1,h_mesh%jjs(:,ms))* h_mesh%gauss%wws(:,ls))
2426 x = h_mesh%gauss%rjs(ls,ms)*ray/sum(sigma_np(h_mesh%jjs(:,ms))*h_mesh%gauss%wws(:,ls))
2431 y = x*h_mesh%gauss%wws(ni,ls)*h_mesh%gauss%wws(nj,ls)
2432 hsij(2,ni,nj) = hsij(2,ni,nj) + y * (-mode/ray)*(rnorms(1,ls,ms))
2433 hsij(3,ni,nj) = hsij(3,ni,nj) + y * mode/ray *(rnorms(1,ls,ms))
2434 hsij(5,ni,nj) = hsij(5,ni,nj) + y * (-1/ray) *(rnorms(1,ls,ms))
2435 hsij(8,ni,nj) = hsij(8,ni,nj) + y * (-mode/ray)*(rnorms(2,ls,ms))
2436 hsij(9,ni,nj) = hsij(9,ni,nj) + y * mode/ray *(rnorms(2,ls,ms))
2450 i = h_mesh%jjs(ni,ms)
2451 ib = la_h%loc_to_glob(ki,i)
2452 ix = ni + (ki-1)*n_ws1
2456 j = h_mesh%jjs(nj,ms)
2457 jb = la_h%loc_to_glob(kj,j)
2458 jx = nj + (kj-1)*n_ws1
2460 IF ( (ki == 2) .AND. (kj == 1))
THEN
2461 mat_loc1(ix,jx) = hsij(2,ni,nj)
2462 mat_loc2(ix,jx) = hsij(3,ni,nj)
2463 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
2464 mat_loc1(ix,jx) = hsij(5,ni,nj)
2465 mat_loc2(ix,jx) = hsij(5,ni,nj)
2466 ELSEIF ( (ki == 2) .AND. (kj == 3))
THEN
2467 mat_loc1(ix,jx) = hsij(8,ni,nj)
2468 mat_loc2(ix,jx) = hsij(9,ni,nj)
2475 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
2476 mat_loc1(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
2477 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
2478 mat_loc2(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
2486 i = h_mesh%jjs(ni,ms)
2487 ib = la_h%loc_to_glob(ki,i)
2488 ix = ni + (ki-1)*n_ws1
2492 j = h_mesh%jjs(nj,ms)
2493 jb = la_h%loc_to_glob(kj,j)
2494 jx = nj + (kj-1)*n_ws1
2496 IF ( (kj == 2) .AND. (ki == 1))
THEN
2497 mat_loc1(ix,jx) = hsij(2,nj,ni)
2498 mat_loc2(ix,jx) = hsij(3,nj,ni)
2499 ELSEIF ((kj == 2) .AND. (ki == 2))
THEN
2500 mat_loc1(ix,jx) = hsij(5,nj,ni)
2501 mat_loc2(ix,jx) = hsij(5,nj,ni)
2502 ELSEIF ( (kj == 2) .AND. (ki == 3))
THEN
2503 mat_loc1(ix,jx) = hsij(8,nj,ni)
2504 mat_loc2(ix,jx) = hsij(9,nj,ni)
2510 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
2511 mat_loc1(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
2512 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_ws1, jdxn(1:3*n_ws1), &
2513 mat_loc2(1:3*n_ws1,1:3*n_ws1), add_values, ierr)
2519 DO ls = 1, h_mesh%gauss%l_Gs
2521 ray = sum(h_mesh%rr(1,h_mesh%jjs(:,ms))* h_mesh%gauss%wws(:,ls))
2522 x = h_mesh%gauss%rjs(ls,ms)*ray /sum(sigma_np(h_mesh%jjs(:,ms))*h_mesh%gauss%wws(:,ls))
2526 y = x*h_mesh%gauss%wws(ni,ls)
2528 hsij(1,ni,nj) = hsij(1,ni,nj) + y*(-h_mesh%gauss%dw_s(2,nj,ls,ms))*(rnorms(2,ls,ms))
2529 hsij(4,ni,nj) = hsij(4,ni,nj) + y* h_mesh%gauss%dw_s(1,nj,ls,ms) *(rnorms(2,ls,ms))
2530 hsij(5,ni,nj) = hsij(5,ni,nj) + &
2531 y*(-h_mesh%gauss%dw_s(2,nj,ls,ms)*(rnorms(2,ls,ms))-h_mesh%gauss%dw_s(1,nj,ls,ms)*(rnorms(1,ls,ms)))
2532 hsij(6,ni,nj) = hsij(6,ni,nj) + y*(-h_mesh%gauss%dw_s(1,nj,ls,ms))*(rnorms(1,ls,ms))
2533 hsij(7,ni,nj) = hsij(7,ni,nj) + y* h_mesh%gauss%dw_s(2,nj,ls,ms) *(rnorms(1,ls,ms))
2548 i = h_mesh%jjs(ni,ms)
2549 ib = la_h%loc_to_glob(ki,i)
2550 ix = ni + (ki-1)*n_ws1
2554 j = h_mesh%jj(nj,m1)
2555 jb = la_h%loc_to_glob(kj,j)
2556 jx = nj + (kj-1)*n_w1
2558 IF ((ki == 1) .AND. (kj == 1))
THEN
2559 mat_loc1(ix,jx) = hsij(1,ni,nj)
2560 mat_loc2(ix,jx) = hsij(1,ni,nj)
2561 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
2562 mat_loc1(ix,jx) = hsij(4,ni,nj)
2563 mat_loc2(ix,jx) = hsij(4,ni,nj)
2564 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
2565 mat_loc1(ix,jx) = hsij(5,ni,nj)
2566 mat_loc2(ix,jx) = hsij(5,ni,nj)
2567 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
2568 mat_loc1(ix,jx) = hsij(6,ni,nj)
2569 mat_loc2(ix,jx) = hsij(6,ni,nj)
2570 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
2571 mat_loc1(ix,jx) = hsij(7,ni,nj)
2572 mat_loc2(ix,jx) = hsij(7,ni,nj)
2579 CALL matsetvalues(h_p_phi_mat1, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_w1, jdxn(1:3*n_w1), &
2580 mat_loc1(1:3*n_ws1,1:3*n_w1), add_values, ierr)
2581 CALL matsetvalues(h_p_phi_mat2, 3*n_ws1 , idxn(1:3*n_ws1), 3*n_w1, jdxn(1:3*n_w1), &
2582 mat_loc2(1:3*n_ws1,1:3*n_w1), add_values, ierr)
2590 i = h_mesh%jj(ni,m1)
2591 ib = la_h%loc_to_glob(ki,i)
2592 ix = ni + (ki-1)*n_w1
2596 j = h_mesh%jjs(nj,ms)
2597 jb = la_h%loc_to_glob(kj,j)
2598 jx = nj + (kj-1)*n_ws1
2600 IF ((kj == 1) .AND. (ki == 1))
THEN
2601 mat_loc1(ix,jx) = hsij(1,nj,ni)
2602 mat_loc2(ix,jx) = hsij(1,nj,ni)
2603 ELSEIF ((kj == 1) .AND. (ki == 3))
THEN
2604 mat_loc1(ix,jx) = hsij(4,nj,ni)
2605 mat_loc2(ix,jx) = hsij(4,nj,ni)
2606 ELSEIF ((kj == 2) .AND. (ki == 2))
THEN
2607 mat_loc1(ix,jx) = hsij(5,nj,ni)
2608 mat_loc2(ix,jx) = hsij(5,nj,ni)
2609 ELSEIF ((kj == 3) .AND. (ki == 3))
THEN
2610 mat_loc1(ix,jx) = hsij(6,nj,ni)
2611 mat_loc2(ix,jx) = hsij(6,nj,ni)
2612 ELSEIF ((kj == 3) .AND. (ki == 1))
THEN
2613 mat_loc1(ix,jx) = hsij(7,nj,ni)
2614 mat_loc2(ix,jx) = hsij(7,nj,ni)
2621 CALL matsetvalues(h_p_phi_mat1, 3*n_w1 , idxn(1:3*n_w1), 3*n_ws1, jdxn(1:3*n_ws1), &
2622 mat_loc1(1:3*n_w1,1:3*n_ws1), add_values, ierr)
2623 CALL matsetvalues(h_p_phi_mat2, 3*n_w1 , idxn(1:3*n_w1), 3*n_ws1, jdxn(1:3*n_ws1), &
2624 mat_loc2(1:3*n_w1,1:3*n_ws1), add_values, ierr)
2628 CALL matassemblybegin(h_p_phi_mat1,mat_final_assembly,ierr)
2629 CALL matassemblyend(h_p_phi_mat1,mat_final_assembly,ierr)
2630 CALL matassemblybegin(h_p_phi_mat2,mat_final_assembly,ierr)
2631 CALL matassemblyend(h_p_phi_mat2,mat_final_assembly,ierr)
2641 SUBROUTINE courant_int_by_parts(H_mesh,phi_mesh,interface_H_phi,sigma,mu_phi,mu_H_field,time,mode,&
2642 rhs_h,nl, la_h, la_phi, vb_1, vb_2, h_ext, sigma_curl, j_over_sigma)
2652 TYPE(mesh_type),
INTENT(IN) :: h_mesh, phi_mesh
2654 REAL(KIND=8),
INTENT(IN) :: mu_phi, time
2655 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: sigma
2656 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: mu_h_field
2657 INTEGER,
INTENT(IN) :: mode
2658 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: nl
2659 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: h_ext
2660 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: rhs_h
2661 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: j_over_sigma
2662 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: sigma_curl
2663 REAL(KIND=8),
DIMENSION(6) :: j_over_sigma_gauss
2665 REAL(KIND=8),
DIMENSION(H_mesh%np,6) :: src_h
2666 REAL(KIND=8),
DIMENSION(phi_mesh%np,2) :: src_phi
2672 REAL(KIND=8),
DIMENSION(phi_mesh%gauss%n_ws,phi_mesh%gauss%l_Gs) :: w_cs
2673 REAL(KIND=8),
DIMENSION(2) :: gaussp
2675 INTEGER :: m, l, i, ni, k, ms, ls, n_ws1, n_ws2, ms1, ms2, h_bloc_size, n_w2, m1
2677 REAL(KIND=8),
DIMENSION(6) :: jsolh_anal, rhs_hl
2678 REAL(KIND=8),
DIMENSION(2,H_mesh%gauss%n_w) :: dwh
2681 REAL(KIND=8) :: ray_rjl, muhl
2686 INTEGER,
DIMENSION(H_mesh%np) :: idxn_h
2687 INTEGER,
DIMENSION(phi_mesh%np) :: idxn_phi
2690 REAL(KIND=8),
DIMENSION(6) :: h_ext_l
2691 #include "petsc/finclude/petsc.h"
2692 petscerrorcode :: ierr
2697 CALL veczeroentries(vb_1, ierr)
2698 CALL veczeroentries(vb_2, ierr)
2710 mesh_id1 = h_mesh%i_d(m)
2711 DO l = 1, h_mesh%gauss%l_G
2714 muhl=sum(mu_h_field(h_mesh%jj(:,m))*h_mesh%gauss%ww(:,l))
2716 dwh = h_mesh%gauss%dw(:,:,l,m)
2719 h_ext_l(k) = sum(h_ext(h_mesh%jj(:,m),k)*h_mesh%gauss%ww(:,l))
2725 j_over_sigma_gauss = 0.d0
2726 DO ni = 1, h_mesh%gauss%n_w; i = h_mesh%jj(ni,m)
2727 gaussp = gaussp + h_mesh%rr(:,i)*h_mesh%gauss%ww(ni,l)
2728 jsolh_anal(:) = jsolh_anal(:) + muhl*nl(i,:)*h_mesh%gauss%ww(ni,l)
2729 rhs_hl(:) = rhs_hl(:) + rhs_h(i,:)*h_mesh%gauss%ww(ni,l)
2730 j_over_sigma_gauss(:) = j_over_sigma_gauss(:) + j_over_sigma(i,:)*h_mesh%gauss%ww(ni,l)
2733 ray_rjl = h_mesh%gauss%rj(l,m)*ray
2735 IF (inputs%if_level_set.AND.inputs%variation_sigma_fluid)
THEN
2737 jsolh_anal(k) = jsolh_anal(k) + j_over_sigma_gauss(k) + sigma_curl(index,k)
2742 jsolh_anal(k) = jsolh_anal(k) + &
2743 jexact_gauss(k, gaussp, mode, mu_phi, sigma(m), muhl, time, mesh_id1, h_ext_l)/sigma(m)
2747 DO ni = 1,h_mesh%gauss%n_w
2752 src_h(i,1) = src_h(i,1)+ ray_rjl &
2753 *(jsolh_anal(3)*dwh(2,ni) &
2754 + mode/ray*jsolh_anal(6)*h_mesh%gauss%ww(ni,l) &
2755 + rhs_hl(1)*h_mesh%gauss%ww(ni,l))
2757 src_h(i,2) = src_h(i,2)+ ray_rjl &
2758 *(jsolh_anal(4)*dwh(2,ni) &
2759 - mode/ray*jsolh_anal(5)*h_mesh%gauss%ww(ni,l) &
2760 + rhs_hl(2)*h_mesh%gauss%ww(ni,l))
2763 src_h(i,3) = src_h(i,3)+ ray_rjl &
2764 * (-jsolh_anal(1)*dwh(2,ni) &
2765 + 1/ray*jsolh_anal(5)*(ray*dwh(1,ni) + h_mesh%gauss%ww(ni,l)) &
2766 + rhs_hl(3)*h_mesh%gauss%ww(ni,l))
2768 src_h(i,4) = src_h(i,4)+ ray_rjl &
2769 * (-jsolh_anal(2)*dwh(2,ni) &
2770 + 1/ray*jsolh_anal(6)*(ray*dwh(1,ni) + h_mesh%gauss%ww(ni,l)) &
2771 + rhs_hl(4)*h_mesh%gauss%ww(ni,l))
2774 src_h(i,5) = src_h(i,5)+ ray_rjl* &
2775 (-mode/ray*jsolh_anal(2)*h_mesh%gauss%ww(ni,l) &
2776 - jsolh_anal(3)*dwh(1,ni) &
2777 + rhs_hl(5)*h_mesh%gauss%ww(ni,l))
2779 src_h(i,6) = src_h(i,6)+ ray_rjl* &
2780 (mode/ray*jsolh_anal(1)*h_mesh%gauss%ww(ni,l) &
2781 - jsolh_anal(4)*dwh(1,ni) &
2782 + rhs_hl(6)*h_mesh%gauss%ww(ni,l))
2839 CALL
gauss(phi_mesh)
2841 n_ws1 = h_mesh%gauss%n_ws
2842 n_ws2 = phi_mesh%gauss%n_ws
2843 n_w2 = phi_mesh%gauss%n_w
2845 h_bloc_size = h_mesh%np
2847 IF (interface_h_phi%mes /=0)
THEN
2848 IF (h_mesh%gauss%n_ws == n_ws)
THEN
2852 w_cs(1,ls)= wws(1,ls)+0.5*wws(3,ls)
2853 w_cs(2,ls)= wws(2,ls)+0.5*wws(3,ls)
2861 DO ms = 1, interface_h_phi%mes
2863 ms2 = interface_h_phi%mesh2(ms)
2864 ms1 = interface_h_phi%mesh1(ms)
2865 m = phi_mesh%neighs(ms2)
2866 m1 = h_mesh%neighs(ms1)
2867 mesh_id1 = h_mesh%i_d(m1)
2870 muhl=sum(mu_h_field(interface_h_phi%jjs1(1:n_ws1,ms))*w_cs(1:n_ws1,ls))
2873 h_ext_l(k) = sum(h_ext(interface_h_phi%jjs1(1:n_ws1,ms),k)*w_cs(1:n_ws1,ls))
2874 j_over_sigma_gauss(k) = sum(j_over_sigma(interface_h_phi%jjs1(1:n_ws1,ms),k)*w_cs(1:n_ws1,ls))
2879 DO ni = 1, n_ws2; i = phi_mesh%jjs(ni,interface_h_phi%mesh2(ms))
2880 ray = ray + phi_mesh%rr(1,i)* wws(ni,ls)
2885 i=phi_mesh%jjs(ni,ms2)
2886 gaussp = gaussp + phi_mesh%rr(:,i)*phi_mesh%gauss%wws(ni,ls)
2890 jsolh_anal(k) =
jexact_gauss(k, gaussp, mode, mu_phi ,sigma(m1), &
2891 muhl, time, mesh_id1, h_ext_l)/sigma(m1) &
2892 + muhl * sum(nl(h_mesh%jjs(1:n_ws1,ms1),k)*w_cs(1:n_ws1,ls))
2912 i = interface_h_phi%jjs1(ni,ms)
2913 src_h(i,1) = src_h(i,1)+rjs(ls,ms2)*ray*( &
2914 -jsolh_anal(3)*w_cs(ni,ls)*(-rnorms(2,ls,ms2)))
2916 src_h(i,2) = src_h(i,2)+rjs(ls,ms2)*ray*( &
2917 -jsolh_anal(4)*w_cs(ni,ls)*(-rnorms(2,ls,ms2)))
2919 src_h(i,3) = src_h(i,3)+rjs(ls,ms2)*ray*( &
2920 jsolh_anal(1)*w_cs(ni,ls)*(-rnorms(2,ls,ms2)) &
2921 -jsolh_anal(5)*w_cs(ni,ls)*(-rnorms(1,ls,ms2)))
2923 src_h(i,4) = src_h(i,4)+rjs(ls,ms2)*ray*( &
2924 jsolh_anal(2)*w_cs(ni,ls)*(-rnorms(2,ls,ms2)) &
2925 -jsolh_anal(6)*w_cs(ni,ls)*(-rnorms(1,ls,ms2)))
2927 src_h(i,5) = src_h(i,5)+rjs(ls,ms2)*ray*( &
2928 jsolh_anal(3)*w_cs(ni,ls)*(-rnorms(1,ls,ms2)))
2930 src_h(i,6) = src_h(i,6)+rjs(ls,ms2)*ray*( &
2931 jsolh_anal(4)*w_cs(ni,ls)*(-rnorms(1,ls,ms2)))
2937 i = interface_h_phi%jjs2(ni,ms)
2940 src_phi(i,1) = src_phi(i,1)+rjs(ls,ms2)*( &
2941 - mode*jsolh_anal(2)*wws(ni,ls) * rnorms(2,ls,ms2) &
2942 + mode*jsolh_anal(6)*wws(ni,ls) * rnorms(1,ls,ms2))
2944 src_phi(i,2) = src_phi(i,2)+rjs(ls,ms2)*( &
2945 + mode*jsolh_anal(1)*wws(ni,ls) * rnorms(2,ls,ms2) &
2946 - mode*jsolh_anal(5)*wws(ni,ls) * rnorms(1,ls,ms2))
2952 i = phi_mesh%jj(ni,m)
2953 src_phi(i,1) = src_phi(i,1)+rjs(ls,ms2)*ray*( &
2954 + jsolh_anal(3) *(dw_s(2,ni,ls,ms2) * rnorms(1,ls,ms2)&
2955 -dw_s(1,ni,ls,ms2) * rnorms(2,ls,ms2)))
2957 src_phi(i,2) = src_phi(i,2)+rjs(ls,ms2)*ray*( &
2958 + jsolh_anal(4)*(dw_s(2,ni,ls,ms2) * rnorms(1,ls,ms2)&
2959 -dw_s(1,ni,ls,ms2) * rnorms(2,ls,ms2)))
2966 i = interface_h_phi%jjs1(ni,ms)
2967 rhs_hl(:) = rhs_hl(:) + rhs_h(i,:)*w_cs(ni,ls)
2971 i = interface_h_phi%jjs2(ni,ms)
2972 src_phi(i,1) = src_phi(i,1)+rjs(ls,ms2)*ray*wws(ni,ls)*( &
2973 rhs_hl(1)*rnorms(1,ls,ms2) + rhs_hl(5)*rnorms(2,ls,ms2))
2974 src_phi(i,2) = src_phi(i,2)+rjs(ls,ms2)*ray*wws(ni,ls)*( &
2975 rhs_hl(2)*rnorms(1,ls,ms2) + rhs_hl(6)*rnorms(2,ls,ms2))
2983 IF (h_mesh%np /= 0)
THEN
2985 idxn_h = la_h%loc_to_glob(1,:)-1
2986 CALL vecsetvalues(vb_1, h_mesh%np, idxn_h, src_h(:,1), add_values, ierr)
2987 CALL vecsetvalues(vb_2, h_mesh%np, idxn_h, src_h(:,2), add_values, ierr)
2988 idxn_h = la_h%loc_to_glob(2,:)-1
2989 CALL vecsetvalues(vb_1, h_mesh%np, idxn_h, src_h(:,4), add_values, ierr)
2990 CALL vecsetvalues(vb_2, h_mesh%np, idxn_h, src_h(:,3), add_values, ierr)
2991 idxn_h = la_h%loc_to_glob(3,:)-1
2992 CALL vecsetvalues(vb_1, h_mesh%np, idxn_h, src_h(:,5), add_values, ierr)
2993 CALL vecsetvalues(vb_2, h_mesh%np, idxn_h, src_h(:,6), add_values, ierr)
2996 IF (phi_mesh%np /=0)
THEN
2998 idxn_phi = la_phi%loc_to_glob(1,:)-1
2999 CALL vecsetvalues(vb_1, phi_mesh%np, idxn_phi, src_phi(:,1), add_values, ierr)
3000 CALL vecsetvalues(vb_2, phi_mesh%np, idxn_phi, src_phi(:,2), add_values, ierr)
3004 CALL vecassemblybegin(vb_1,ierr)
3005 CALL vecassemblyend(vb_1,ierr)
3006 CALL vecassemblybegin(vb_2,ierr)
3007 CALL vecassemblyend(vb_2,ierr)
3016 SUBROUTINE surf_int(H_mesh,phi_mesh, interface_H_phi, interface_H_mu, &
3017 list_dirichlet_sides_h, sigma,mu_phi, mu_h_field,time,mode, &
3018 la_h, la_phi, vb_1, vb_2, r_fourier, index_fourier)
3025 TYPE(mesh_type),
INTENT(IN) :: h_mesh, phi_mesh
3026 TYPE(interface_type),
INTENT(IN) :: interface_h_phi, interface_h_mu
3027 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_dirichlet_sides_h
3028 REAL(KIND=8),
INTENT(IN) :: mu_phi, time
3029 REAL(KIND=8),
DIMENSION(H_mesh%me),
INTENT(IN):: sigma
3030 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: mu_h_field
3031 INTEGER,
INTENT(IN) :: mode
3032 REAL(KIND=8),
OPTIONAL :: r_fourier
3033 INTEGER,
OPTIONAL :: index_fourier
3034 REAL(KIND=8),
DIMENSION(H_mesh%np, 6) :: src_h
3035 REAL(KIND=8),
DIMENSION(phi_mesh%np, 2) :: src_phi
3039 REAL(KIND=8) :: ray, muhl
3040 INTEGER :: ms, ls, ns, i, k, m, n, ni
3041 REAL(KIND=8),
DIMENSION(2) :: gaussp
3042 REAL(KIND=8),
DIMENSION(6) :: esolh_anal, esolphi_anal
3045 INTEGER,
DIMENSION(H_mesh%np) :: idxn_h
3046 INTEGER,
DIMENSION(phi_mesh%np) :: idxn_phi
3051 INTEGER,
DIMENSION(:),
ALLOCATABLE,
SAVE :: neumann_bdy_h_sides
3052 INTEGER,
DIMENSION(:),
ALLOCATABLE,
SAVE :: neumann_bdy_phi_sides
3053 LOGICAL,
SAVE :: once_neumann_bdy=.true.
3054 LOGICAL,
DIMENSION(:),
ALLOCATABLE :: virgin1
3055 LOGICAL,
DIMENSION(:),
ALLOCATABLE :: virgin2
3057 #include "petsc/finclude/petsc.h"
3058 petscerrorcode :: ierr
3065 IF (once_neumann_bdy)
THEN
3066 once_neumann_bdy = .false.
3067 ALLOCATE(virgin1(h_mesh%mes))
3068 ALLOCATE(virgin2(phi_mesh%mes))
3071 IF (interface_h_phi%mes/=0)
THEN
3072 virgin1(interface_h_phi%mesh1) = .false.
3073 virgin2(interface_h_phi%mesh2) = .false.
3075 IF (interface_h_mu%mes/=0)
THEN
3076 virgin1(interface_h_mu%mesh1) = .false.
3077 virgin1(interface_h_mu%mesh2) = .false.
3081 DO ms = 1, h_mesh%mes
3082 IF (maxval(abs(h_mesh%rr(1,h_mesh%jjs(:,ms)))).LT.1d-12) cycle
3083 IF (.NOT.virgin1(ms)) cycle
3084 IF(minval(abs(h_mesh%sides(ms)-list_dirichlet_sides_h))==0) cycle
3087 ALLOCATE(neumann_bdy_h_sides(count))
3089 DO ms = 1, h_mesh%mes
3090 IF (maxval(abs(h_mesh%rr(1,h_mesh%jjs(:,ms)))).LT.1d-12) cycle
3091 IF (.NOT.virgin1(ms)) cycle
3092 IF(minval(abs(h_mesh%sides(ms)-list_dirichlet_sides_h))==0) cycle
3094 neumann_bdy_h_sides(count) = ms
3098 DO ms = 1, phi_mesh%mes
3099 IF (present(index_fourier))
THEN
3100 IF (phi_mesh%sides(ms)==index_fourier) cycle
3102 IF (.NOT.virgin2(ms)) cycle
3103 IF (maxval(abs(phi_mesh%rr(1,phi_mesh%jjs(:,ms)))).LT.1d-12) cycle
3104 IF (minval(abs(phi_mesh%sides(ms)-inputs%phi_list_dirichlet_sides))==0) cycle
3107 ALLOCATE(neumann_bdy_phi_sides(count))
3109 DO ms = 1, phi_mesh%mes
3110 IF (present(index_fourier))
THEN
3111 IF (phi_mesh%sides(ms)==index_fourier) cycle
3113 IF (.NOT.virgin2(ms)) cycle
3114 IF (maxval(abs(phi_mesh%rr(1,phi_mesh%jjs(:,ms)))).LT.1d-12) cycle
3115 IF (minval(abs(phi_mesh%sides(ms)-inputs%phi_list_dirichlet_sides))==0) cycle
3117 neumann_bdy_phi_sides(count) = ms
3126 DO count = 1,
SIZE(neumann_bdy_h_sides)
3127 ms = neumann_bdy_h_sides(count)
3128 m = h_mesh%neighs(ms)
3129 DO ls = 1, h_mesh%gauss%l_Gs
3131 muhl = sum(mu_h_field(h_mesh%jjs(:,ms))*h_mesh%gauss%wws(:,ls))
3136 DO ni = 1, h_mesh%gauss%n_ws; i = h_mesh%jjs(ni,ms)
3137 ray = ray + h_mesh%rr(1,i)* h_mesh%gauss%wws(ni,ls)
3140 IF (ray.LT.1.d-15) cycle
3143 DO ns=1, h_mesh%gauss%n_ws
3145 gaussp = gaussp + h_mesh%rr(:,i)*h_mesh%gauss%wws(ns,ls)
3149 esolh_anal(k) =
eexact_gauss(k,gaussp,mode,mu_phi,sigma(m),muhl, time)
3155 DO ns=1, h_mesh%gauss%n_ws
3156 i = h_mesh%jjs(ns,ms)
3157 src_h(i,1) = src_h(i,1)-h_mesh%gauss%rjs(ls,ms)*ray*( &
3158 -esolh_anal(3)*h_mesh%gauss%wws(ns,ls)* &
3159 (h_mesh%gauss%rnorms(2,ls,ms)))
3161 src_h(i,2) = src_h(i,2)-h_mesh%gauss%rjs(ls,ms)*ray*( &
3162 -esolh_anal(4)*h_mesh%gauss%wws(ns,ls)* &
3163 (h_mesh%gauss%rnorms(2,ls,ms)))
3165 src_h(i,3) = src_h(i,3)-h_mesh%gauss%rjs(ls,ms)*ray*( &
3166 esolh_anal(1)*h_mesh%gauss%wws(ns,ls)* &
3167 (h_mesh%gauss%rnorms(2,ls,ms)) - &
3168 esolh_anal(5)*h_mesh%gauss%wws(ns,ls) * &
3169 (h_mesh%gauss%rnorms(1,ls,ms)))
3171 src_h(i,4) = src_h(i,4)-h_mesh%gauss%rjs(ls,ms)*ray*( &
3172 esolh_anal(2)*h_mesh%gauss%wws(ns,ls) * &
3173 (h_mesh%gauss%rnorms(2,ls,ms)) - &
3174 esolh_anal(6)*h_mesh%gauss%wws(ns,ls) * &
3175 (h_mesh%gauss%rnorms(1,ls,ms)))
3177 src_h(i,5) = src_h(i,5)-h_mesh%gauss%rjs(ls,ms)*ray*( &
3178 esolh_anal(3)*h_mesh%gauss%wws(ns,ls)* &
3179 (h_mesh%gauss%rnorms(1,ls,ms)))
3181 src_h(i,6) = src_h(i,6)-h_mesh%gauss%rjs(ls,ms)*ray*( &
3182 esolh_anal(4)*h_mesh%gauss%wws(ns,ls) * &
3183 (h_mesh%gauss%rnorms(1,ls,ms)))
3191 DO count = 1,
SIZE(neumann_bdy_phi_sides)
3192 ms = neumann_bdy_phi_sides(count)
3193 m = phi_mesh%neighs(ms)
3194 DO ls = 1, phi_mesh%gauss%l_Gs
3197 DO ni = 1, phi_mesh%gauss%n_ws; i = phi_mesh%jjs(ni,ms)
3198 ray = ray + phi_mesh%rr(1,i)* phi_mesh%gauss%wws(ni,ls)
3202 DO ns=1, phi_mesh%gauss%n_ws
3203 i=phi_mesh%jjs(ns,ms)
3204 gaussp = gaussp + phi_mesh%rr(:,i)*phi_mesh%gauss%wws(ns,ls)
3210 esolphi_anal(k) =
eexact_gauss(k,gaussp,mode,mu_phi,sigma(1),mu_h_field(1),time)
3214 DO ns=1, phi_mesh%gauss%n_ws
3215 i = phi_mesh%jjs(ns,ms)
3216 DO n = 1, phi_mesh%gauss%n_w
3217 IF (phi_mesh%jj(n,m) == i)
EXIT
3220 src_phi(i,1) = src_phi(i,1)-phi_mesh%gauss%rjs(ls,ms)*ray*( &
3221 +esolphi_anal(3)*(phi_mesh%gauss%dw_s(2,n,ls,ms)*phi_mesh%gauss%rnorms(1,ls,ms) &
3222 -phi_mesh%gauss%dw_s(1,n,ls,ms)*phi_mesh%gauss%rnorms(2,ls,ms))) &
3223 -phi_mesh%gauss%rjs(ls,ms)*(&
3224 -mode*esolphi_anal(2)*phi_mesh%gauss%wws(ns,ls)*phi_mesh%gauss%rnorms(2,ls,ms) &
3225 +mode*esolphi_anal(6)*phi_mesh%gauss%wws(ns,ls)*phi_mesh%gauss%rnorms(1,ls,ms))
3227 src_phi(i,2) = src_phi(i,2)-phi_mesh%gauss%rjs(ls,ms)*ray*( &
3228 +esolphi_anal(4)*(phi_mesh%gauss%dw_s(2,n,ls,ms)*phi_mesh%gauss%rnorms(1,ls,ms) &
3229 -phi_mesh%gauss%dw_s(1,n,ls,ms)*phi_mesh%gauss%rnorms(2,ls,ms))) &
3230 -phi_mesh%gauss%rjs(ls,ms)*(&
3231 mode*esolphi_anal(1)*phi_mesh%gauss%wws(ns,ls)*phi_mesh%gauss%rnorms(2,ls,ms) &
3232 -mode*esolphi_anal(5)*phi_mesh%gauss%wws(ns,ls)*phi_mesh%gauss%rnorms(1,ls,ms))
3249 IF (present(r_fourier))
THEN
3250 IF (r_fourier.GE.0.d0) CALL
error_petsc(
'maxwell_update_time_with_H: R_fourier should be -1')
3273 IF (h_mesh%mes/=0)
THEN
3275 idxn_h = la_h%loc_to_glob(1,:)-1
3276 CALL vecsetvalues(vb_1, h_mesh%np, idxn_h, src_h(:,1), add_values, ierr)
3277 CALL vecsetvalues(vb_2, h_mesh%np, idxn_h, src_h(:,2), add_values, ierr)
3278 idxn_h = la_h%loc_to_glob(2,:)-1
3279 CALL vecsetvalues(vb_1, h_mesh%np, idxn_h, src_h(:,4), add_values, ierr)
3280 CALL vecsetvalues(vb_2, h_mesh%np, idxn_h, src_h(:,3), add_values, ierr)
3281 idxn_h = la_h%loc_to_glob(3,:)-1
3282 CALL vecsetvalues(vb_1, h_mesh%np, idxn_h, src_h(:,5), add_values, ierr)
3283 CALL vecsetvalues(vb_2, h_mesh%np, idxn_h, src_h(:,6), add_values, ierr)
3286 IF (phi_mesh%mes/=0)
THEN
3288 idxn_phi = la_phi%loc_to_glob(1,:)-1
3289 CALL vecsetvalues(vb_1, phi_mesh%np, idxn_phi, src_phi(:,1), add_values, ierr)
3290 CALL vecsetvalues(vb_2, phi_mesh%np, idxn_phi, src_phi(:,2), add_values, ierr)
3294 CALL vecassemblybegin(vb_1,ierr)
3295 CALL vecassemblyend(vb_1,ierr)
3296 CALL vecassemblybegin(vb_2,ierr)
3297 CALL vecassemblyend(vb_2,ierr)
3304 mu_h_field, sigma, la_h, h_p_phi_mat1, h_p_phi_mat2)
3311 INTEGER,
INTENT(IN) :: mode
3312 REAL(KIND=8),
DIMENSION(3),
INTENT(IN) :: stab
3313 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: sigma, mu_h_field
3314 INTEGER :: ms, ls, ni, nj, i, j, &
3315 n_ws1, n_ws2, n_w2, n_w1, m1, m2, ki, kj,ib,jb, ms1, ms2
3316 REAL(KIND=8) :: x, y,
z, norm, hm1
3317 REAL(KIND=8) :: ray, stab_colle_h_mu
3318 LOGICAL :: mark=.false.
3319 REAL(KIND=8),
DIMENSION(9,SIZE(H_mesh%jj,1),SIZE(H_mesh%jj,1),2,2) :: hsij, gsij
3334 REAL(KIND=8),
DIMENSION(H_mesh%gauss%n_ws,H_mesh%gauss%l_Gs) :: w_cs
3335 REAL(KIND=8),
DIMENSION(2, H_mesh%gauss%n_w, H_mesh%gauss%l_Gs, H_mesh%mes) :: dw_cs
3336 REAL(KIND=8),
DIMENSION(2, H_mesh%gauss%n_w) :: dwsi,dwsj
3337 REAL(KIND=8),
DIMENSION(2,H_mesh%gauss%l_Gs) :: gauss1, gauss2
3343 REAL(KIND=8),
DIMENSION(2) :: normi, normj
3344 REAL(KIND=8),
DIMENSION(SIZE(H_mesh%jjs,1)) :: wwsi, wwsj
3345 INTEGER :: n_wsi, n_wsj, ci, cj, n_wi, n_wj
3348 REAL(KIND=8) ::
ref, diff, mu_h, muhl1, muhl2, muhi, muhj, sigmai, sigmaj
3350 REAL(KIND=8) :: c_sym =.0d0
3351 REAL(KIND=8) :: wwiwwj, normt, stab_div
3356 REAL(KIND=8),
DIMENSION(6*H_mesh%gauss%n_w,6*H_mesh%gauss%n_w) :: mat_loc1, mat_loc2
3357 INTEGER ,
DIMENSION(6*H_mesh%gauss%n_w) :: idxn, jdxn
3362 #include "petsc/finclude/petsc.h"
3363 mat :: h_p_phi_mat1, h_p_phi_mat2
3364 petscerrorcode :: ierr
3367 stab_colle_h_mu = stab(3)
3377 n_ws1 = h_mesh%gauss%n_ws
3378 n_ws2 = h_mesh%gauss%n_ws
3379 n_w1 = h_mesh%gauss%n_w
3380 n_w2 = h_mesh%gauss%n_w
3392 DO ms = 1, interface_h_mu%mes
3394 ms2 = interface_h_mu%mesh2(ms)
3395 m2 = h_mesh%neighs(ms2)
3396 ms1 = interface_h_mu%mesh1(ms)
3397 m1 = h_mesh%neighs(ms1)
3399 ref = 1.d-8+sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - h_mesh%rr(:,h_mesh%jjs(2,ms1)))**2)
3400 diff = sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - h_mesh%rr(:,h_mesh%jjs(1,ms2)))**2)
3401 IF (diff/
ref .LT. 1.d-10)
THEN
3405 w_cs(1,ls)= wws(2,ls)
3406 w_cs(2,ls)= wws(1,ls)
3407 IF (n_ws1==3) w_cs(n_ws1,ls) = wws(n_ws1,ls)
3408 WRITE(*,*)
' Ouaps! oder of shape functions changed?'
3413 gauss2(1,ls) = sum(h_mesh%rr(1,h_mesh%jjs(:,ms2))*h_mesh%gauss%wws(:,ls))
3414 gauss2(2,ls) = sum(h_mesh%rr(2,h_mesh%jjs(:,ms2))*h_mesh%gauss%wws(:,ls))
3415 gauss1(1,ls) = sum(h_mesh%rr(1,h_mesh%jjs(:,ms1))*h_mesh%gauss%wws(:,ls))
3416 gauss1(2,ls) = sum(h_mesh%rr(2,h_mesh%jjs(:,ms1))*h_mesh%gauss%wws(:,ls))
3420 ref = sqrt(1.d-8+sum(gauss2(:,ls2)**2))
3423 diff = sqrt(sum((gauss2(:,ls2)-gauss1(:,ls1))**2))
3424 IF (diff .LT. 1.d-10)
THEN
3425 dw_cs(:,:,ls2,ms1) = h_mesh%gauss%dw_s(:,:,ls1,ms1)
3430 IF (.NOT.mark)
WRITE(*,*)
' BUG '
3435 DO ms = 1, interface_h_mu%mes
3437 ms2 = interface_h_mu%mesh2(ms)
3438 ms1 = interface_h_mu%mesh1(ms)
3439 m2 = h_mesh%neighs(ms2)
3440 m1 = h_mesh%neighs(ms1)
3441 mu_h = sum(mu_h_field(h_mesh%jj(:,m1)))/h_mesh%gauss%n_w
3444 hm1 = 1/sum(rjs(:,ms2))
3456 ray = sum(h_mesh%rr(1,h_mesh%jjs(:,ms2))* h_mesh%gauss%wws(:,ls))
3457 x = hm1*rjs(ls,ms2)*ray
3460 muhl1 = sum(mu_h_field(h_mesh%jjs(:,ms1))*w_cs(:,ls))
3461 muhl2 = sum(mu_h_field(h_mesh%jjs(:,ms2))* wws(:,ls))
3463 normt =stab_colle_h_mu
3464 norm = stab_div*sum(rjs(:,ms2))**(2*alpha)
3474 normi = rnorms(:,ls,ms1)
3479 normi = rnorms(:,ls,ms2)
3486 normj = rnorms(:,ls,ms1)
3491 normj = rnorms(:,ls,ms2)
3499 wwiwwj = x * wwsi(ni)*wwsj(nj)
3502 z = norm * muhi * muhj * wwiwwj
3504 hsij(1,ni,nj,ci,cj) = hsij(1,ni,nj,ci,cj) + y*normi(2)*normj(2) &
3505 +
z*normi(1)*normj(1)
3506 hsij(4,ni,nj,ci,cj) = hsij(4,ni,nj,ci,cj) - y*normj(1)*normi(2) &
3507 +
z*normi(1)*normj(2)
3508 hsij(5,ni,nj,ci,cj) = hsij(5,ni,nj,ci,cj) + y*(normi(1)*normj(1) + normi(2)*normj(2))
3509 hsij(6,ni,nj,ci,cj) = hsij(6,ni,nj,ci,cj) + y*normi(1)*normj(1) &
3510 +
z*normi(2)*normj(2)
3523 i = interface_h_mu%jjs1(ni,ms)
3525 i = interface_h_mu%jjs2(ni,ms)
3527 ib = la_h%loc_to_glob(ki,i)
3528 ix = ni + n_ws1*((ki-1) + 3*(ci-1))
3535 j = interface_h_mu%jjs1(nj,ms)
3537 j = interface_h_mu%jjs2(nj,ms)
3539 jb = la_h%loc_to_glob(kj,j)
3540 jx = nj + n_ws2*((kj-1) + 3*(cj-1))
3542 IF ((ki == 1) .AND. (kj == 1))
THEN
3543 mat_loc1(ix,jx) = hsij(1,ni,nj,ci,cj)
3544 mat_loc2(ix,jx) = hsij(1,ni,nj,ci,cj)
3545 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
3546 mat_loc1(ix,jx) = hsij(4,ni,nj,ci,cj)
3547 mat_loc2(ix,jx) = hsij(4,ni,nj,ci,cj)
3548 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
3549 mat_loc1(ix,jx) = hsij(4,nj,ni,cj,ci)
3550 mat_loc2(ix,jx) = hsij(4,nj,ni,cj,ci)
3551 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
3552 mat_loc1(ix,jx) = hsij(5,ni,nj,ci,cj)
3553 mat_loc2(ix,jx) = hsij(5,ni,nj,ci,cj)
3554 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
3555 mat_loc1(ix,jx) = hsij(6,ni,nj,ci,cj)
3556 mat_loc2(ix,jx) = hsij(6,ni,nj,ci,cj)
3565 CALL matsetvalues(h_p_phi_mat1, 6*n_ws1, idxn(1:6*n_ws1), 6*n_ws2, jdxn(1:6*n_ws2), &
3566 mat_loc1(1:6*n_ws1,1:6*n_ws2), add_values, ierr)
3567 CALL matsetvalues(h_p_phi_mat2, 6*n_ws1, idxn(1:6*n_ws1), 6*n_ws2, jdxn(1:6*n_ws2), &
3568 mat_loc2(1:6*n_ws1,1:6*n_ws2), add_values, ierr)
3577 DO ls = 1, h_mesh%gauss%l_Gs
3580 ray = sum(h_mesh%rr(1,h_mesh%jjs(:,ms2))* h_mesh%gauss%wws(:,ls))
3587 normi = rnorms(:,ls,ms1)
3595 normi = rnorms(:,ls,ms2)
3605 normj = rnorms(:,ls,ms1)
3613 normj = rnorms(:,ls,ms2)
3624 y = x*wwsi(ni)*wwsj(nj)/(2*sigmaj)
3625 hsij(2,ni,nj,ci,cj) = hsij(2,ni,nj,ci,cj) + y * (-mode/ray)*normi(1)
3626 hsij(3,ni,nj,ci,cj) = hsij(3,ni,nj,ci,cj) + y * mode/ray *normi(1)
3627 hsij(5,ni,nj,ci,cj) = hsij(5,ni,nj,ci,cj) + y * (-1/ray) *normi(1)
3628 hsij(8,ni,nj,ci,cj) = hsij(8,ni,nj,ci,cj) + y * (-mode/ray)*normi(2)
3629 hsij(9,ni,nj,ci,cj) = hsij(9,ni,nj,ci,cj) + y * mode/ray *normi(2)
3630 y = x*wwsi(ni)*wwsj(nj)/(2*sigmai)
3631 gsij(2,ni,nj,ci,cj) = gsij(2,ni,nj,ci,cj) + y * (-mode/ray)*normj(1)
3632 gsij(3,ni,nj,ci,cj) = gsij(3,ni,nj,ci,cj) + y * ( mode/ray)*normj(1)
3633 gsij(5,ni,nj,ci,cj) = gsij(5,ni,nj,ci,cj) + y * (-1/ray) *normj(1)
3634 gsij(8,ni,nj,ci,cj) = gsij(8,ni,nj,ci,cj) + y * (-mode/ray)*normj(2)
3635 gsij(9,ni,nj,ci,cj) = gsij(9,ni,nj,ci,cj) + y * mode/ray *normj(2)
3653 i = interface_h_mu%jjs1(ni,ms)
3655 i = interface_h_mu%jjs2(ni,ms)
3657 ib = la_h%loc_to_glob(ki,i)
3658 ix = ni + n_wsi*((ki-1) + 3*(ci-1))
3664 j = interface_h_mu%jjs1(nj,ms)
3666 j = interface_h_mu%jjs2(nj,ms)
3668 jb = la_h%loc_to_glob(kj,j)
3669 jx = nj + n_wsj*((kj-1) + 3*(cj-1))
3671 IF ((ki == 2) .AND. (kj == 1))
THEN
3672 mat_loc1(ix,jx) = hsij(2,ni,nj,ci,cj)
3673 mat_loc2(ix,jx) = hsij(3,ni,nj,ci,cj)
3674 ELSE IF((ki == 1) .AND. (kj == 2))
THEN
3675 mat_loc1(ix,jx) = gsij(2,ni,nj,ci,cj)
3676 mat_loc2(ix,jx) = gsij(3,ni,nj,ci,cj)
3677 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
3678 mat_loc1(ix,jx) = hsij(5,ni,nj,ci,cj)+gsij(5,ni,nj,ci,cj)
3679 mat_loc2(ix,jx) = hsij(5,ni,nj,ci,cj)+gsij(5,ni,nj,ci,cj)
3680 ELSEIF ((ki == 2) .AND. (kj == 3))
THEN
3681 mat_loc1(ix,jx) = hsij(8,ni,nj,ci,cj)
3682 mat_loc2(ix,jx) = hsij(9,ni,nj,ci,cj)
3683 ELSEIF ((ki == 3) .AND. (kj == 2))
THEN
3684 mat_loc1(ix,jx) = gsij(8,ni,nj,ci,cj)
3685 mat_loc2(ix,jx) = gsij(9,ni,nj,ci,cj)
3694 CALL matsetvalues(h_p_phi_mat1, 6*n_ws1, idxn(1:6*n_ws1), 6*n_ws2, jdxn(1:6*n_ws2), &
3695 mat_loc1(1:6*n_ws1,1:6*n_ws2), add_values, ierr)
3696 CALL matsetvalues(h_p_phi_mat2, 6*n_ws1, idxn(1:6*n_ws1), 6*n_ws2, jdxn(1:6*n_ws2), &
3697 mat_loc2(1:6*n_ws1,1:6*n_ws2), add_values, ierr)
3702 DO ls = 1, h_mesh%gauss%l_Gs
3705 ray = sum(h_mesh%rr(1,h_mesh%jjs(:,ms2))* h_mesh%gauss%wws(:,ls))
3713 normi = rnorms(:,ls,ms1)
3715 dwsi = dw_cs(:,:,ls,ms1)
3723 normi = rnorms(:,ls,ms2)
3725 dwsi = dw_s(:,:,ls,ms2)
3735 normj = rnorms(:,ls,ms1)
3737 dwsj = dw_cs(:,:,ls,ms1)
3745 normj = rnorms(:,ls,ms2)
3747 dwsj = dw_s(:,:,ls,ms2)
3759 y = x*wwsi(ni)/(2*sigmaj)
3760 hsij(1,ni,nj,ci,cj) = hsij(1,ni,nj,ci,cj) + y*(-dwsj(2,nj))*normi(2)
3761 hsij(4,ni,nj,ci,cj) = hsij(4,ni,nj,ci,cj) + y* dwsj(1,nj) *normi(2)
3762 hsij(5,ni,nj,ci,cj) = hsij(5,ni,nj,ci,cj) + y*(-dwsj(2,nj) *normi(2)-dwsj(1,nj)*normi(1))
3763 hsij(6,ni,nj,ci,cj) = hsij(6,ni,nj,ci,cj) + y*(-dwsj(1,nj))*normi(1)
3764 hsij(7,ni,nj,ci,cj) = hsij(7,ni,nj,ci,cj) + y* dwsj(2,nj) *normi(1)
3769 y = x*wwsj(nj)/(2*sigmai)
3770 gsij(1,ni,nj,ci,cj) = gsij(1,ni,nj,ci,cj) + y*(-dwsi(2,ni))*normj(2)
3771 gsij(4,ni,nj,ci,cj) = gsij(4,ni,nj,ci,cj) + y* dwsi(2,ni) *normj(1)
3772 gsij(5,ni,nj,ci,cj) = gsij(5,ni,nj,ci,cj) + y*(-dwsi(2,ni) *normj(2)-dwsi(1,ni)*normj(1))
3773 gsij(6,ni,nj,ci,cj) = gsij(6,ni,nj,ci,cj) + y*(-dwsi(1,ni))*normj(1)
3774 gsij(7,ni,nj,ci,cj) = gsij(7,ni,nj,ci,cj) + y* dwsi(1,ni) *normj(2)
3792 i = interface_h_mu%jjs1(ni,ms)
3794 i = interface_h_mu%jjs2(ni,ms)
3796 ib = la_h%loc_to_glob(ki,i)
3797 ix = ni + n_wsi*((ki-1) + 3*(ci-1))
3803 j = h_mesh%jj(nj,m1)
3805 j = h_mesh%jj(nj,m2)
3807 jb = la_h%loc_to_glob(kj,j)
3808 jx = nj + n_wj*((kj-1) + 3*(cj-1))
3810 IF ((ki == 1) .AND. (kj == 1))
THEN
3811 mat_loc1(ix,jx) = hsij(1,ni,nj,ci,cj)
3812 mat_loc2(ix,jx) = hsij(1,ni,nj,ci,cj)
3813 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
3814 mat_loc1(ix,jx) = hsij(4,ni,nj,ci,cj)
3815 mat_loc2(ix,jx) = hsij(4,ni,nj,ci,cj)
3816 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
3817 mat_loc1(ix,jx) = hsij(7,ni,nj,ci,cj)
3818 mat_loc2(ix,jx) = hsij(7,ni,nj,ci,cj)
3819 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
3820 mat_loc1(ix,jx) = hsij(5,ni,nj,ci,cj)
3821 mat_loc2(ix,jx) = hsij(5,ni,nj,ci,cj)
3822 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
3823 mat_loc1(ix,jx) = hsij(6,ni,nj,ci,cj)
3824 mat_loc2(ix,jx) = hsij(6,ni,nj,ci,cj)
3834 CALL matsetvalues(h_p_phi_mat1, 6*n_ws1, idxn(1:6*n_ws1), 6*n_w2, jdxn(1:6*n_w2), &
3835 mat_loc1(1:6*n_ws1,1:6*n_w2), add_values, ierr)
3836 CALL matsetvalues(h_p_phi_mat2, 6*n_ws1, idxn(1:6*n_ws1), 6*n_w2, jdxn(1:6*n_w2), &
3837 mat_loc2(1:6*n_ws1,1:6*n_w2), add_values, ierr)
3845 i = h_mesh%jj(ni,m1)
3847 i = h_mesh%jj(ni,m2)
3849 ib = la_h%loc_to_glob(ki,i)
3850 ix = ni + n_wi*((ki-1) + 3*(ci-1))
3856 j = interface_h_mu%jjs1(nj,ms)
3858 j = interface_h_mu%jjs2(nj,ms)
3860 jb = la_h%loc_to_glob(kj,j)
3861 jx = nj + n_wsj*((kj-1) + 3*(cj-1))
3863 IF ((ki == 1) .AND. (kj == 1))
THEN
3864 mat_loc1(ix,jx) = gsij(1,ni,nj,ci,cj)
3865 mat_loc2(ix,jx) = gsij(1,ni,nj,ci,cj)
3866 ELSEIF ((ki == 1) .AND. (kj == 3))
THEN
3867 mat_loc1(ix,jx) = gsij(4,ni,nj,ci,cj)
3868 mat_loc2(ix,jx) = gsij(4,ni,nj,ci,cj)
3869 ELSEIF ((ki == 3) .AND. (kj == 1))
THEN
3870 mat_loc1(ix,jx) = gsij(7,ni,nj,ci,cj)
3871 mat_loc2(ix,jx) = gsij(7,ni,nj,ci,cj)
3872 ELSEIF ((ki == 2) .AND. (kj == 2))
THEN
3873 mat_loc1(ix,jx) = gsij(5,ni,nj,ci,cj)
3874 mat_loc2(ix,jx) = gsij(5,ni,nj,ci,cj)
3875 ELSEIF ((ki == 3) .AND. (kj == 3))
THEN
3876 mat_loc1(ix,jx) = gsij(6,ni,nj,ci,cj)
3877 mat_loc2(ix,jx) = gsij(6,ni,nj,ci,cj)
3886 CALL matsetvalues(h_p_phi_mat1, 6*n_w1, idxn(1:6*n_w1), 6*n_ws2, jdxn(1:6*n_ws2), &
3887 mat_loc1(1:6*n_w1,1:6*n_ws2), add_values, ierr)
3888 CALL matsetvalues(h_p_phi_mat2, 6*n_w1, idxn(1:6*n_w1), 6*n_ws2, jdxn(1:6*n_ws2), &
3889 mat_loc2(1:6*n_w1,1:6*n_ws2), add_values, ierr)
3893 CALL matassemblybegin(h_p_phi_mat1,mat_final_assembly,ierr)
3894 CALL matassemblyend(h_p_phi_mat1,mat_final_assembly,ierr)
3895 CALL matassemblybegin(h_p_phi_mat2,mat_final_assembly,ierr)
3896 CALL matassemblyend(h_p_phi_mat2,mat_final_assembly,ierr)
3903 SUBROUTINE courant_mu(H_mesh,interface_H_mu,sigma,mu_H_field,time,mode,nl, &
3904 la_h, vb_1, vb_2, h_ext)
3915 REAL(KIND=8),
INTENT(IN) :: time
3916 REAL(KIND=8),
DIMENSION(H_mesh%me),
INTENT(IN) :: sigma
3917 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: mu_h_field
3918 INTEGER,
INTENT(IN) :: mode
3919 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: nl
3920 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: h_ext
3921 REAL(KIND=8),
DIMENSION(H_mesh%np,6) :: src_h
3923 REAL(KIND=8),
DIMENSION(H_mesh%gauss%n_ws,H_mesh%gauss%l_Gs) :: w_cs
3924 REAL(KIND=8),
DIMENSION(2) :: normi, gaussp1, gaussp2
3925 REAL(KIND=8),
DIMENSION(H_mesh%gauss%n_ws) :: wwsi
3926 REAL(KIND=8) :: x, ray
3927 INTEGER :: i, ni, ms, k, ls, n_ws1, n_ws2, ms1, ms2, n_w1, n_w2, m1, m2, ci, n_wsi
3928 INTEGER :: mesh_id1, mesh_id2
3929 REAL(KIND=8),
DIMENSION(6) :: jsolh_anal, test, h_ext_l
3930 REAL(KIND=8) :: muhl1, muhl2,
ref, diff
3937 INTEGER,
DIMENSION(H_mesh%np) :: idxn
3940 #include "petsc/finclude/petsc.h"
3941 petscerrorcode :: ierr
3951 n_ws1 = h_mesh%gauss%n_ws
3952 n_ws2 = h_mesh%gauss%n_ws
3953 n_w1 = h_mesh%gauss%n_w
3954 n_w2 = h_mesh%gauss%n_w
3956 DO ms = 1, interface_h_mu%mes
3957 ms1 = interface_h_mu%mesh1(ms)
3958 ms2 = interface_h_mu%mesh2(ms)
3959 m1 = h_mesh%neighs(ms1)
3960 m2 = h_mesh%neighs(ms2)
3962 ref = 1.d-8+sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - h_mesh%rr(:,h_mesh%jjs(2,ms1)))**2)
3963 diff = sum((h_mesh%rr(:,h_mesh%jjs(1,ms1)) - h_mesh%rr(:,h_mesh%jjs(1,ms2)))**2)
3964 IF (diff/
ref .LT. 1.d-10)
THEN
3968 w_cs(1,ls)= wws(2,ls)
3969 w_cs(2,ls)= wws(1,ls)
3970 IF (n_ws1==3) w_cs(n_ws1,ls) = wws(n_ws1,ls)
3971 WRITE(*,*)
' Ouaps! oder of shape functions changed?'
3976 DO ms = 1, interface_h_mu%mes
3977 ms2 = interface_h_mu%mesh2(ms)
3978 ms1 = interface_h_mu%mesh1(ms)
3979 m2 = h_mesh%neighs(ms2)
3980 m1 = h_mesh%neighs(ms1)
3981 mesh_id1 = h_mesh%i_d(m1)
3982 mesh_id2 = h_mesh%i_d(m2)
3985 ray = sum(h_mesh%rr(1,h_mesh%jjs(:,ms2))* h_mesh%gauss%wws(:,ls))
3990 h_ext_l(k) = sum(h_ext(h_mesh%jjs(:,ms1),k)*h_mesh%gauss%wws(:,ls))
3992 muhl1=sum(mu_h_field(h_mesh%jjs(:,ms1))*w_cs(:,ls))
3993 gaussp1(1) = sum(h_mesh%rr(1,h_mesh%jjs(:,ms1))*w_cs(:,ls))
3994 gaussp1(2) = sum(h_mesh%rr(2,h_mesh%jjs(:,ms1))*w_cs(:,ls))
3996 jsolh_anal(k) =
jexact_gauss(k, gaussp1, mode, one ,sigma(m1), &
3997 muhl1, time, mesh_id1, h_ext_l)/sigma(m1) &
3998 + muhl1 * sum(nl(h_mesh%jjs(1:n_ws1,ms1),k)*w_cs(1:n_ws1,ls))
4006 h_ext_l(k) = sum(h_ext(h_mesh%jjs(:,ms2),k)*h_mesh%gauss%wws(:,ls))
4008 muhl2=sum(mu_h_field(h_mesh%jjs(:,ms2))*wws(:,ls))
4009 gaussp2(1) = sum(h_mesh%rr(1,h_mesh%jjs(:,ms2))*wws(:,ls))
4010 gaussp2(2) = sum(h_mesh%rr(2,h_mesh%jjs(:,ms2))*wws(:,ls))
4011 IF (maxval(abs(gaussp1-gaussp2)) > 1.d-11)
THEN
4012 WRITE(*,*)
' BUG courant_mu '
4016 test(k) =
jexact_gauss(k, gaussp2, mode, one ,sigma(m2), &
4017 muhl2, time, mesh_id2, h_ext_l)/sigma(m2) &
4018 + muhl2 * sum(nl(h_mesh%jjs(1:n_ws2,ms2),k)*wws(1:n_ws2,ls))
4022 jsolh_anal(k) = jsolh_anal(k) + test(k)
4032 normi = rnorms(:,ls,ms1)
4036 normi = rnorms(:,ls,ms2)
4042 i = interface_h_mu%jjs1(ni,ms)
4044 i = interface_h_mu%jjs2(ni,ms)
4046 x = rjs(ls,ms2)*ray*wwsi(ni)/2
4047 src_h(i,1) = src_h(i,1)+x*(-jsolh_anal(3)*normi(2))
4048 src_h(i,2) = src_h(i,2)+x*(-jsolh_anal(4)*normi(2))
4049 src_h(i,3) = src_h(i,3)+x*(jsolh_anal(1)*normi(2)-jsolh_anal(5)*normi(1))
4050 src_h(i,4) = src_h(i,4)+x*(jsolh_anal(2)*normi(2)-jsolh_anal(6)*normi(1))
4051 src_h(i,5) = src_h(i,5)+x*(jsolh_anal(3)*normi(1))
4052 src_h(i,6) = src_h(i,6)+x*(jsolh_anal(4)*normi(1))
4058 IF (h_mesh%np /= 0)
THEN
4060 idxn = la_h%loc_to_glob(1,:)-1
4061 CALL vecsetvalues(vb_1, h_mesh%np, idxn, src_h(:,1), add_values, ierr)
4062 CALL vecsetvalues(vb_2, h_mesh%np, idxn, src_h(:,2), add_values, ierr)
4063 idxn = la_h%loc_to_glob(2,:)-1
4064 CALL vecsetvalues(vb_1, h_mesh%np, idxn, src_h(:,4), add_values, ierr)
4065 CALL vecsetvalues(vb_2, h_mesh%np, idxn, src_h(:,3), add_values, ierr)
4066 idxn = la_h%loc_to_glob(3,:)-1
4067 CALL vecsetvalues(vb_1, h_mesh%np, idxn, src_h(:,5), add_values, ierr)
4068 CALL vecsetvalues(vb_2, h_mesh%np, idxn, src_h(:,6), add_values, ierr)
4071 CALL vecassemblybegin(vb_1,ierr)
4072 CALL vecassemblyend(vb_1,ierr)
4073 CALL vecassemblybegin(vb_2,ierr)
4074 CALL vecassemblyend(vb_2,ierr)
4078 SUBROUTINE rhs_dirichlet(H_mesh,Dirichlet_bdy_H_sides,sigma,&
4079 mu_h_field,time,mode,nl,stab, la_h, vb_1, vb_2, h_ext, j_over_sigma, sigma_curl_bdy)
4088 INTEGER,
DIMENSION(:),
INTENT(IN) :: dirichlet_bdy_h_sides
4089 REAL(KIND=8),
INTENT(IN) :: time
4090 REAL(KIND=8),
DIMENSION(H_mesh%me),
INTENT(IN) :: sigma
4091 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: mu_h_field
4092 INTEGER,
INTENT(IN) :: mode
4093 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: nl
4094 REAL(KIND=8),
DIMENSION(3),
INTENT(IN) :: stab
4095 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: h_ext
4096 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: j_over_sigma
4097 REAL(KIND=8),
DIMENSION(:,:),
INTENT(IN) :: sigma_curl_bdy
4098 REAL(KIND=8),
DIMENSION(H_mesh%np,6) :: src_h
4099 REAL(KIND=8),
DIMENSION(2) :: gaussp1
4100 REAL(KIND=8) :: x, ray, stab_colle_h_mu
4101 INTEGER :: i, ni, ms, k, ls, m1, count
4103 REAL(KIND=8),
DIMENSION(6) :: jsolh_anal, h_ext_l
4104 REAL(KIND=8) :: muhl1, hm1
4105 REAL(KIND=8),
DIMENSION(6,H_mesh%gauss%l_Gs) :: hloc, hlocxn
4106 REAL(KIND=8),
DIMENSION(2,H_mesh%gauss%l_Gs) :: rloc
4107 REAL(KIND=8),
DIMENSION(1) :: muloc
4115 INTEGER,
DIMENSION(H_mesh%np) :: idxn
4118 #include "petsc/finclude/petsc.h"
4119 petscerrorcode :: ierr
4133 stab_colle_h_mu = stab(3)
4136 DO count = 1,
SIZE(dirichlet_bdy_h_sides)
4137 ms = dirichlet_bdy_h_sides(count)
4138 hm1 = stab_colle_h_mu/sum(h_mesh%gauss%rjs(:,ms))
4139 m1 = h_mesh%neighs(ms)
4140 mesh_id1 = h_mesh%i_d(m1)
4141 muloc(1) = mu_h_field(h_mesh%jj(1,m1))
4143 DO ls = 1, h_mesh%gauss%l_Gs
4144 rloc(1,ls) = sum(h_mesh%rr(1,h_mesh%jjs(:,ms))*h_mesh%gauss%wws(:,ls))
4145 rloc(2,ls) = sum(h_mesh%rr(2,h_mesh%jjs(:,ms))*h_mesh%gauss%wws(:,ls))
4149 hloc(k,:) =
hexact(h_mesh, k, rloc, mode, muloc, time)
4152 hlocxn(1,:) = hloc(3,:)*h_mesh%gauss%rnorms(2,:,ms)
4153 hlocxn(2,:) = hloc(4,:)*h_mesh%gauss%rnorms(2,:,ms)
4154 hlocxn(3,:) = hloc(5,:)*h_mesh%gauss%rnorms(1,:,ms)-hloc(1,:)*h_mesh%gauss%rnorms(2,:,ms)
4155 hlocxn(4,:) = hloc(6,:)*h_mesh%gauss%rnorms(1,:,ms)-hloc(2,:)*h_mesh%gauss%rnorms(2,:,ms)
4156 hlocxn(5,:) = -hloc(3,:)*h_mesh%gauss%rnorms(1,:,ms)
4157 hlocxn(6,:) = -hloc(4,:)*h_mesh%gauss%rnorms(1,:,ms)
4159 DO ls = 1, h_mesh%gauss%l_Gs
4164 h_ext_l(k) = sum(h_ext(h_mesh%jjs(:,ms),k)*h_mesh%gauss%wws(:,ls))
4168 muhl1=sum(mu_h_field(h_mesh%jjs(:,ms))*h_mesh%gauss%wws(:,ls))
4169 gaussp1(1) = rloc(1,ls)
4170 gaussp1(2) = rloc(2,ls)
4178 IF (inputs%if_level_set.AND.inputs%variation_sigma_fluid)
THEN
4180 jsolh_anal(k) = sum(j_over_sigma(h_mesh%jjs(:,ms),k)*h_mesh%gauss%wws(:,ls)) &
4181 + sigma_curl_bdy(index,k) &
4182 + sum(nl(h_mesh%jjs(:,ms),k)*h_mesh%gauss%wws(:,ls)) &
4187 jsolh_anal(k) =
jexact_gauss(k, gaussp1, mode, one ,sigma(m1), muhl1, &
4188 time, mesh_id1, h_ext_l)/sigma(m1) &
4189 + sum(nl(h_mesh%jjs(:,ms),k)*h_mesh%gauss%wws(:,ls)) &
4195 DO ni = 1, h_mesh%gauss%n_ws
4196 i = h_mesh%jjs(ni,ms)
4197 x = h_mesh%gauss%rjs(ls,ms)*ray*h_mesh%gauss%wws(ni,ls)
4199 src_h(i,1) = src_h(i,1)+x*(-jsolh_anal(3)*h_mesh%gauss%rnorms(2,ls,ms))
4200 src_h(i,2) = src_h(i,2)+x*(-jsolh_anal(4)*h_mesh%gauss%rnorms(2,ls,ms))
4201 src_h(i,3) = src_h(i,3)+x*(jsolh_anal(1)*h_mesh%gauss%rnorms(2,ls,ms)&
4202 -jsolh_anal(5)*h_mesh%gauss%rnorms(1,ls,ms))
4203 src_h(i,4) = src_h(i,4)+x*(jsolh_anal(2)*h_mesh%gauss%rnorms(2,ls,ms)&
4204 -jsolh_anal(6)*h_mesh%gauss%rnorms(1,ls,ms))
4205 src_h(i,5) = src_h(i,5)+x*(jsolh_anal(3)*h_mesh%gauss%rnorms(1,ls,ms))
4206 src_h(i,6) = src_h(i,6)+x*(jsolh_anal(4)*h_mesh%gauss%rnorms(1,ls,ms))
4213 IF (h_mesh%np /= 0)
THEN
4215 idxn = la_h%loc_to_glob(1,:)-1
4216 CALL vecsetvalues(vb_1, h_mesh%np, idxn, src_h(:,1), add_values, ierr)
4217 CALL vecsetvalues(vb_2, h_mesh%np, idxn, src_h(:,2), add_values, ierr)
4218 idxn = la_h%loc_to_glob(2,:)-1
4219 CALL vecsetvalues(vb_1, h_mesh%np, idxn, src_h(:,4), add_values, ierr)
4220 CALL vecsetvalues(vb_2, h_mesh%np, idxn, src_h(:,3), add_values, ierr)
4221 idxn = la_h%loc_to_glob(3,:)-1
4222 CALL vecsetvalues(vb_1, h_mesh%np, idxn, src_h(:,5), add_values, ierr)
4223 CALL vecsetvalues(vb_2, h_mesh%np, idxn, src_h(:,6), add_values, ierr)
4226 CALL vecassemblybegin(vb_1,ierr)
4227 CALL vecassemblyend(vb_1,ierr)
4228 CALL vecassemblybegin(vb_2,ierr)
4229 CALL vecassemblyend(vb_2,ierr)
4241 INTEGER,
POINTER,
DIMENSION(:) :: js_d
4242 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: on_proc_loc, on_proc, not_cav_loc, not_cav
4243 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: is_ok, j_tmp
4244 INTEGER,
DIMENSION(1) :: loc
4245 INTEGER :: m, ms, i, nb_dom, idx, nb_cav, ni
4247 #include "petsc/finclude/petsc.h"
4248 mpi_comm,
INTENT(IN) :: communicator
4250 petscerrorcode :: ierr
4252 IF (inputs%nb_dom_phi==0)
RETURN
4254 CALL mpi_comm_rank(communicator, rank, ierr)
4256 nb_dom = inputs%nb_dom_phi
4257 ALLOCATE(on_proc_loc(nb_dom), on_proc(nb_dom))
4258 ALLOCATE(not_cav_loc(nb_dom), not_cav(nb_dom))
4266 IF (minval(abs(inputs%list_dom_phi-i)) /= 0)
THEN
4267 WRITE(*,*)
'error in dirichlet cavities'
4269 loc = minloc(abs(inputs%list_dom_phi-i))
4270 on_proc_loc(loc(1)) = rank
4272 IF (mesh%mes /= 0)
THEN
4273 ALLOCATE(is_ok(mesh%mes))
4274 is_ok = mesh%i_d(mesh%neighs)
4275 IF (interface_h_phi%mes /=0)
THEN
4276 is_ok(interface_h_phi%mesh2) = 0
4279 IF (sum(abs(mesh%rr(1,mesh%jjs(:,ms)))) .LT. 1.d-12)
THEN
4282 IF (inputs%my_periodic%nb_periodic_pairs /=0)
THEN
4283 IF (minval(abs(inputs%my_periodic%list_periodic-mesh%sides(ms))) == 0)
THEN
4290 IF (is_ok(ms) == 0) cycle
4292 IF (minval(abs(inputs%list_dom_phi-i)) /= 0)
THEN
4293 WRITE(*,*)
'error in dirichlet cavities'
4295 loc = minloc(abs(inputs%list_dom_phi-i))
4296 not_cav_loc(loc(1)) = rank
4299 CALL mpi_allreduce(on_proc_loc, on_proc, nb_dom, mpi_integer, mpi_max, communicator, ierr)
4300 CALL mpi_allreduce(not_cav_loc, not_cav, nb_dom, mpi_integer, mpi_max, communicator, ierr)
4302 ALLOCATE(j_tmp(
SIZE(js_d)+nb_dom))
4303 j_tmp(1:
SIZE(js_d)) = js_d
4306 IF ( (not_cav(i)==-1) .AND. (on_proc(i)==rank) )
THEN
4310 IF (mesh%i_d(m) == inputs%list_dom_phi(i))
THEN
4311 DO ni = 1, mesh%gauss%n_w
4312 IF (minval(abs(mesh%jjs-mesh%jj(ni,m))) /=0)
THEN
4313 j_tmp(idx) = mesh%jj(ni,m)
4319 WRITE(*,*)
'add ', j_tmp(idx),
'in dom ', inputs%list_dom_phi(i),
' : proc ', rank
4320 WRITE(*,*)
'add ', mesh%rr(:,j_tmp(idx)), mesh%i_d(m)
4328 nb_cav = idx -
SIZE(js_d)
4329 IF (nb_cav /= 0)
THEN
4335 DEALLOCATE(on_proc_loc, on_proc, j_tmp)
4336 DEALLOCATE(not_cav_loc, not_cav)
4337 IF (
ALLOCATED(is_ok))
DEALLOCATE(is_ok)
4339 WRITE(*,
'(a,x,i2,x,a,x,i2)')
'I have detected', nb_cav,
' cavity(ies) on proc', rank
4343 SUBROUTINE smb_sigma_prod_curl(communicator, mesh, list_mode, H_in, sigma_bar, sigma_in, V_out)
4353 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
4354 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: h_in
4355 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: sigma_bar
4356 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: sigma_in
4357 REAL(KIND=8),
DIMENSION(:,:,:) :: v_out
4359 REAL(KIND=8),
DIMENSION(mesh%gauss%l_G*mesh%me,6,SIZE(list_mode)) :: h_gauss, roth
4360 REAL(KIND=8),
DIMENSION(mesh%gauss%l_G*mesh%me,2,SIZE(list_mode)) :: sigma_gauss
4361 REAL(KIND=8),
DIMENSION(mesh%gauss%l_G*mesh%me,6,SIZE(list_mode)) :: roth_bar
4362 INTEGER,
DIMENSION(mesh%gauss%n_w) :: j_loc
4363 REAL(KIND=8),
DIMENSION(mesh%gauss%k_d,mesh%gauss%n_w) :: dw_loc
4364 INTEGER :: m, l , i, mode, index, k
4365 REAL(KIND=8),
DIMENSION(mesh%gauss%n_w,6) :: h_in_loc
4366 REAL(KIND=8),
DIMENSION(mesh%gauss%n_w,2) :: sigma_in_loc
4369 INTEGER :: nb_procs, bloc_size, m_max_pad, code
4370 #include "petsc/finclude/petsc.h"
4371 mpi_comm :: communicator
4373 DO i = 1,
SIZE(list_mode)
4377 j_loc = mesh%jj(:,m)
4379 h_in_loc(:,k) = h_in(j_loc,k,i)
4382 sigma_in_loc(:,k) = sigma_in(j_loc,k,i)
4385 DO l = 1, mesh%gauss%l_G
4387 dw_loc = mesh%gauss%dw(:,:,l,m)
4390 ray = sum(mesh%rr(1,j_loc)*mesh%gauss%ww(:,l))
4393 h_gauss(index,1,i) = sum(h_in_loc(:,1)*mesh%gauss%ww(:,l))
4394 h_gauss(index,3,i) = sum(h_in_loc(:,3)*mesh%gauss%ww(:,l))
4395 h_gauss(index,5,i) = sum(h_in_loc(:,5)*mesh%gauss%ww(:,l))
4397 h_gauss(index,2,i) = sum(h_in_loc(:,2)*mesh%gauss%ww(:,l))
4398 h_gauss(index,4,i) = sum(h_in_loc(:,4)*mesh%gauss%ww(:,l))
4399 h_gauss(index,6,i) = sum(h_in_loc(:,6)*mesh%gauss%ww(:,l))
4401 sigma_gauss(index,1,i) = sum(sigma_in_loc(:,1)*mesh%gauss%ww(:,l))
4402 sigma_gauss(index,2,i) = sum(sigma_in_loc(:,2)*mesh%gauss%ww(:,l))
4405 roth(index,1,i) = mode/ray*h_gauss(index,6,i) &
4406 -sum(h_in_loc(:,3)*dw_loc(2,:))
4407 roth(index,4,i) = sum(h_in_loc(:,2)*dw_loc(2,:)) &
4408 -sum(h_in_loc(:,6)*dw_loc(1,:))
4409 roth(index,5,i) = 1/ray*h_gauss(index,3,i) &
4410 +sum(h_in_loc(:,3)*dw_loc(1,:)) &
4411 -mode/ray*h_gauss(index,2,i)
4413 roth(index,2,i) =-mode/ray*h_gauss(index,5,i) &
4414 -sum(h_in_loc(:,4)*dw_loc(2,:))
4415 roth(index,3,i) = sum(h_in_loc(:,1)*dw_loc(2,:)) &
4416 -sum(h_in_loc(:,5)*dw_loc(1,:))
4417 roth(index,6,i) = 1/ray*h_gauss(index,4,i) &
4418 +sum(h_in_loc(:,4)*dw_loc(1,:))&
4419 +mode/ray*h_gauss(index,1,i)
4422 roth_bar(index,k,i) = roth(index,k,i)/sum(sigma_bar(j_loc)*mesh%gauss%ww(:,l))
4429 CALL mpi_comm_size(communicator, nb_procs, code)
4430 bloc_size =
SIZE(sigma_gauss,1)/nb_procs+1
4431 m_max_pad = 3*
SIZE(list_mode)*nb_procs/2
4434 bloc_size, m_max_pad)
4436 v_out = roth_bar - v_out
4444 SUBROUTINE smb_sigma_prod_curl_bdy(communicator, mesh, Dirichlet_bdy_H_sides, list_mode, H_in, sigma_bar, sigma_in, V_out)
4454 INTEGER,
DIMENSION(:),
INTENT(IN) :: dirichlet_bdy_h_sides
4455 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
4456 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: h_in
4457 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: sigma_bar
4458 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: sigma_in
4459 REAL(KIND=8),
DIMENSION(:,:,:) :: v_out
4461 REAL(KIND=8),
DIMENSION(mesh%gauss%l_Gs*SIZE(Dirichlet_bdy_H_sides),6,SIZE(list_mode)) :: h_gauss, roth
4462 REAL(KIND=8),
DIMENSION(mesh%gauss%l_Gs*SIZE(Dirichlet_bdy_H_sides),6,SIZE(list_mode)) :: roth_bar
4463 REAL(KIND=8),
DIMENSION(mesh%gauss%l_Gs*SIZE(Dirichlet_bdy_H_sides),2,SIZE(list_mode)) :: sigma_gauss
4464 REAL(KIND=8),
DIMENSION(mesh%gauss%k_d,mesh%gauss%n_w) :: dw_loc
4465 INTEGER :: ms, ls , i, mode, index, k
4466 INTEGER,
DIMENSION(mesh%gauss%n_ws) :: j_loc
4467 REAL(KIND=8),
DIMENSION(mesh%gauss%n_ws,6) :: h_in_loc
4468 REAL(KIND=8),
DIMENSION(mesh%gauss%n_ws,2) :: sigma_in_loc
4471 INTEGER :: nb_procs, bloc_size, m_max_pad, code, count, m1
4472 #include "petsc/finclude/petsc.h"
4473 mpi_comm :: communicator
4475 DO i = 1,
SIZE(list_mode)
4478 DO count = 1,
SIZE(dirichlet_bdy_h_sides)
4479 ms = dirichlet_bdy_h_sides(count)
4480 m1 = mesh%neighs(ms)
4482 j_loc = mesh%jjs(:,ms)
4484 h_in_loc(:,k) = h_in(j_loc,k,i)
4487 sigma_in_loc(:,k) = sigma_in(j_loc,k,i)
4490 DO ls = 1, mesh%gauss%l_Gs
4492 dw_loc = mesh%gauss%dw_s(:,:,ls,ms)
4495 ray = sum(mesh%rr(1,mesh%jjs(:,ms))*mesh%gauss%wws(:,ls))
4498 h_gauss(index,1,i) = sum(h_in_loc(:,1)*mesh%gauss%wws(:,ls))
4499 h_gauss(index,3,i) = sum(h_in_loc(:,3)*mesh%gauss%wws(:,ls))
4500 h_gauss(index,5,i) = sum(h_in_loc(:,5)*mesh%gauss%wws(:,ls))
4502 h_gauss(index,2,i) = sum(h_in_loc(:,2)*mesh%gauss%wws(:,ls))
4503 h_gauss(index,4,i) = sum(h_in_loc(:,4)*mesh%gauss%wws(:,ls))
4504 h_gauss(index,6,i) = sum(h_in_loc(:,6)*mesh%gauss%wws(:,ls))
4506 sigma_gauss(index,1,i) = sum(sigma_in_loc(:,1)*mesh%gauss%wws(:,ls))
4507 sigma_gauss(index,2,i) = sum(sigma_in_loc(:,2)*mesh%gauss%wws(:,ls))
4510 roth(index,1,i) = mode/ray*h_gauss(index,6,i) &
4512 -sum(h_in(mesh%jj(:,m1),3,i)*dw_loc(2,:))
4516 roth(index,4,i) = sum(h_in(mesh%jj(:,m1),2,i)*dw_loc(2,:)) &
4517 -sum(h_in(mesh%jj(:,m1),6,i)*dw_loc(1,:))
4519 roth(index,5,i) = 1/ray*h_gauss(index,3,i) &
4521 +sum(h_in(mesh%jj(:,m1),3,i)*dw_loc(1,:)) &
4522 -mode/ray*h_gauss(index,2,i)
4525 roth(index,2,i) =-mode/ray*h_gauss(index,5,i) &
4527 -sum(h_in(mesh%jj(:,m1),4,i)*dw_loc(2,:))
4531 roth(index,3,i) = sum(h_in(mesh%jj(:,m1),1,i)*dw_loc(2,:)) &
4532 -sum(h_in(mesh%jj(:,m1),5,i)*dw_loc(1,:))
4534 roth(index,6,i) = 1/ray*h_gauss(index,4,i) &
4536 +sum(h_in(mesh%jj(:,m1),4,i)*dw_loc(1,:))&
4537 +mode/ray*h_gauss(index,1,i)
4540 roth_bar(index,k,i) = roth(index,k,i)/(sum(sigma_bar(j_loc)*mesh%gauss%wws(:,ls)))
4546 IF (
SIZE(dirichlet_bdy_h_sides).GE.1)
THEN
4548 CALL mpi_comm_size(communicator, nb_procs, code)
4549 bloc_size =
SIZE(sigma_gauss,1)/nb_procs+1
4550 m_max_pad = 3*
SIZE(list_mode)*nb_procs/2
4553 bloc_size, m_max_pad)
4555 v_out = roth_bar - v_out
4564 mu_h_field, mu_phi, sigma_tot, time, j_over_sigma)
4572 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
4573 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: sigma_tot
4574 REAL(KIND=8),
DIMENSION(:),
INTENT(IN) :: mu_h_field
4575 REAL(KIND=8),
INTENT(IN) :: mu_phi, time
4576 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(OUT) :: j_over_sigma
4577 REAL(KIND=8),
DIMENSION(SIZE(mesh%rr,2),6,SIZE(list_mode)) :: j_node
4578 REAL(KIND=8),
DIMENSION(6) :: b_ext_l
4579 REAL(KIND=8) :: muhl
4580 INTEGER :: mode, mesh_id1, k, i, n
4581 INTEGER :: nb_procs, bloc_size, m_max_pad, code
4582 #include "petsc/finclude/petsc.h"
4583 mpi_comm :: communicator
4589 muhl=minval(mu_h_field)
4593 DO i = 1,
SIZE(list_mode)
4596 DO n = 1,
SIZE(mesh%rr,2)
4597 j_node(n,k,i) =
jexact_gauss(k, mesh%rr(:,n), mode, mu_phi, 1.d0, muhl, &
4598 time, mesh_id1, b_ext_l)
4603 CALL mpi_comm_size(communicator, nb_procs, code)
4604 bloc_size =
SIZE(j_node,1)/nb_procs+1
4605 m_max_pad = 3*
SIZE(list_mode)*nb_procs/2
4607 nb_procs, bloc_size, m_max_pad)
4612
subroutine surf_int(H_mesh, phi_mesh, interface_H_phi, interface_H_mu, list_dirichlet_sides_H, sigma, mu_phi, mu_H_field, time, mode, LA_H, LA_phi, vb_1, vb_2, R_fourier, index_fourier)
subroutine courant_int_by_parts(H_mesh, phi_mesh, interface_H_phi, sigma, mu_phi, mu_H_field, time, mode, rhs_H, nl, LA_H, LA_phi, vb_1, vb_2, B_ext, H_pert, sigma_curl, J_over_sigma)
subroutine, public create_my_ghost(mesh, LA, ifrom)
subroutine dirichlet_rhs(js_D, bs_D, b)
real(kind=8) function, dimension(size(h_mesh%rr, 2)), public sigma_bar_in_fourier_space(H_mesh)
subroutine init_solver(my_par, my_ksp, matrix, communicator, solver, precond, opt_re_init)
subroutine smb_sigma_prod_curl_bdy(communicator, mesh, Dirichlet_bdy_H_sides, list_mode, H_in, sigma_bar, sigma_in, V_out)
subroutine mat_dirichlet_maxwell(H_mesh, Dirichlet_bdy_H_sides, mode, stab, mu_H_field, LA_H, H_p_phi_mat1, H_p_phi_mat2, sigma_np)
subroutine dirichlet_nodes_parallel(mesh, list_dirichlet_sides, js_d)
subroutine mat_maxwell_mu(H_mesh, interface_H_mu, mode, stab, mu_H_field, sigma, LA_H, H_p_phi_mat1, H_p_phi_mat2)
real(kind=8) function, public jexact_gauss(TYPE, rr, m, mu_phi, sigma, mu_H, t, mesh_id, opt_B_ext)
subroutine solver(my_ksp, b, x, reinit, verbose)
subroutine dirichlet_m_parallel(matrix, glob_js_D)
subroutine, public maxwell_decouple_with_h(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, H_phi_per, LA_H, LA_pmag, LA_phi, LA_mhd, sigma_ns_in, jj_v_to_H)
real(kind=8) function, dimension(size(rr, 2)), public phiexact(TYPE, rr, m, mu_phi, t)
subroutine mat_h_p_phi_maxwell(H_mesh, pmag_mesh, phi_mesh, interface_H_phi, mode, mu_H_field, mu_phi, c_mass, stab, R_fourier, index_fourier, LA_H, LA_pmag, LA_phi, H_p_phi_mat1, H_p_phi_mat2, sigma_np)
subroutine, public ref(communicator, V1_in, V2_in, V_out, temps)
subroutine, public fft_scalar_vect_dcl(communicator, V1_in, V2_in, V_out, pb, nb_procs, bloc_size, m_max_pad, temps)
real(kind=8) function norm_sf(communicator, norm_type, mesh, list_mode, v)
subroutine dirichlet_nodes(jjs_in, sides_in, dir_in, js_d)
real(kind=8) function, public eexact_gauss(TYPE, rr, m, mu_phi, sigma, mu_H, t)
real(kind=8) function user_time()
subroutine, public periodic_rhs_petsc(n_bord, list, perlist, v_rhs, LA)
subroutine courant_mu(H_mesh, interface_H_mu, sigma, mu_H_field, time, mode, nl, LA_H, vb_1, vb_2, B_ext)
subroutine rhs_dirichlet(H_mesh, Dirichlet_bdy_H_sides, sigma, mu_H_field, time, mode, nl, stab, LA_H, vb_1, vb_2, B_ext, J_over_sigma, sigma_curl_bdy_in)
subroutine dirichlet_cavities(communicator, interface_H_phi, mesh, js_D)
subroutine error_petsc(string)
subroutine, public fft_par_cross_prod_dcl(communicator, V1_in, V2_in, V_out, nb_procs, bloc_size, m_max_pad, temps)
subroutine, public periodic_matrix_petsc(n_bord, list, perlist, matrix, LA)
subroutine, public extract(xghost, ks, ke, LA, phi)
subroutine create_local_petsc_matrix(communicator, LA, matrix, clean)
real(kind=8) function, dimension(size(rr, 2)), public hexact(H_mesh, TYPE, rr, m, mu_H_field, t)
section doc_intro_frame_work_num_app Numerical approximation subsection doc_intro_fram_work_num_app_Fourier_FEM Fourier Finite element representation The SFEMaNS code uses a hybrid Fourier Finite element formulation The Fourier decomposition allows to approximate the problem’s solutions for each Fourier mode modulo nonlinear terms that are made explicit The variables are then approximated on a meridian section of the domain with a finite element method The numerical approximation of a function f $f f is written in the following generic z
subroutine smb_current_over_sigma(communicator, mesh, list_mode, mu_H_field, mu_phi, sigma_tot, time, J_over_sigma)
subroutine smb_sigma_prod_curl(communicator, mesh, list_mode, H_in, sigma_bar, sigma_in, V_out)