9 FUNCTION dot_product_sf(communicator, mesh, list_mode, v, w) RESULT(norm)
15 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
16 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v, w
17 REAL(KIND=8) :: norm_loc, norm_tot, norm
20 #include "petsc/finclude/petsc.h"
21 mpi_comm,
DIMENSION(2) :: communicator
31 CALL mpi_allreduce(norm_loc,norm_tot,1,mpi_double_precision, mpi_sum, communicator(2), code)
32 CALL mpi_allreduce(norm_tot,norm,1,mpi_double_precision, mpi_sum, communicator(1), code)
38 FUNCTION norm_sf(communicator, norm_type, mesh, list_mode, v) RESULT(norm)
44 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
45 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
46 CHARACTER(*),
INTENT(IN) :: norm_type
47 REAL(KIND=8) :: norm_loc, norm_tot, norm
48 INTEGER :: deb, fin, code
50 #include "petsc/finclude/petsc.h"
51 mpi_comm,
DIMENSION(2) :: communicator
61 IF (norm_type(deb:fin)==
'L2')
THEN
63 ELSE IF (norm_type(deb:fin)==
'H1')
THEN
66 ELSE IF (norm_type(deb:fin)==
'sH1')
THEN
68 ELSE IF (norm_type(deb:fin)==
'div')
THEN
70 ELSE IF (norm_type(deb:fin)==
'curl')
THEN
73 WRITE(*,*)
' BUG in norm, norm_type not programmed yet' , norm_type(deb:fin)
77 CALL mpi_allreduce(norm_loc**2,norm_tot,1,mpi_double_precision, mpi_sum, communicator(2), code)
78 CALL mpi_allreduce(norm_tot,norm,1,mpi_double_precision, mpi_sum, communicator(1), code)
80 norm = sqrt(norm*2*pi)
85 FUNCTION norm_s(communicator, norm_type, mesh, list_mode, v) RESULT(norm)
91 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
92 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
93 CHARACTER(*),
INTENT(IN) :: norm_type
94 REAL(KIND=8) :: norm_loc, norm_tot, norm
95 INTEGER :: deb, fin, code
97 #include "petsc/finclude/petsc.h"
98 mpi_comm,
DIMENSION(2) :: communicator
108 IF (norm_type(deb:fin)==
'L2')
THEN
110 ELSE IF (norm_type(deb:fin)==
'H1')
THEN
113 ELSE IF (norm_type(deb:fin)==
'sH1')
THEN
115 ELSE IF (norm_type(deb:fin)==
'div')
THEN
117 ELSE IF (norm_type(deb:fin)==
'curl')
THEN
120 WRITE(*,*)
' BUG in norm, norm_type not programmed yet' , norm_type(deb:fin)
124 CALL mpi_allreduce(norm_loc**2,norm,1,mpi_double_precision, mpi_sum, communicator(1), code)
126 norm = sqrt(norm*2*pi)
137 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
138 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
139 REAL(KIND=8) :: norm_loc, norm_tot, norm
141 INTEGER,
DIMENSION(1) :: zero_mode
143 #include "petsc/finclude/petsc.h"
144 mpi_comm,
DIMENSION(2) :: communicator
151 IF (minval(list_mode)==0)
THEN
152 zero_mode = minloc(list_mode)
158 CALL mpi_allreduce(norm_loc,norm,1,mpi_double_precision, mpi_sum, communicator(1), code)
165 REAL(KIND=8),
INTENT(IN) :: norm_loc
166 REAL(KIND=8),
INTENT(OUT) :: norm_tot
169 #include "petsc/finclude/petsc.h"
170 mpi_comm :: communicator
173 CALL mpi_allreduce(norm_loc,norm_tot,1,mpi_double_precision, mpi_sum, communicator, code)
175 norm_tot = norm_tot*(2*pi)
184 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
185 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
186 REAL(KIND=8) :: norm_loc, norm
187 #include "petsc/finclude/petsc.h"
188 mpi_comm :: communicator
204 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
205 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
206 REAL(KIND=8) :: norm_loc, norm
207 #include "petsc/finclude/petsc.h"
208 mpi_comm :: communicator
220 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
221 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
222 REAL(KIND=8) :: norm_loc, norm
223 #include "petsc/finclude/petsc.h"
224 mpi_comm :: communicator
226 norm_loc =
norme_div(h_mesh, list_mode, v)
236 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
237 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
238 REAL(KIND=8) :: norm_loc, norm
239 #include "petsc/finclude/petsc.h"
240 mpi_comm :: communicator
251 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
252 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: field
253 REAL(KIND=8),
DIMENSION(3),
INTENT(OUT) :: moments_out
255 REAL(KIND=8),
DIMENSION(3) :: moments_loc
256 REAL(KIND=8) :: m_x, m_y, ray, zed, urc, urs, utc, uts, uzc, uzs
257 INTEGER :: m, l, code, i
258 #include "petsc/finclude/petsc.h"
262 DO i = 1,
SIZE(list_mode)
263 IF (list_mode(i)==0)
THEN
265 DO l = 1, mesh%gauss%l_G
266 ray = sum(mesh%rr(1,mesh%jj(:,m))*mesh%gauss%ww(:,l))
267 utc = sum(field(mesh%jj(:,m),3,i)*mesh%gauss%ww(:,l))
269 moments_loc(3) = moments_loc(3) + ray**2*utc*mesh%gauss%rj(l,m)
272 ELSE IF (list_mode(i)==1)
THEN
274 DO l = 1, mesh%gauss%l_G
275 ray = sum(mesh%rr(1,mesh%jj(:,m))*mesh%gauss%ww(:,l))
276 zed = sum(mesh%rr(2,mesh%jj(:,m))*mesh%gauss%ww(:,l))
278 urc = sum(field(mesh%jj(:,m),1,i)*mesh%gauss%ww(:,l))
279 urs = sum(field(mesh%jj(:,m),2,i)*mesh%gauss%ww(:,l))
280 utc = sum(field(mesh%jj(:,m),3,i)*mesh%gauss%ww(:,l))
281 uts = sum(field(mesh%jj(:,m),4,i)*mesh%gauss%ww(:,l))
282 uzc = sum(field(mesh%jj(:,m),5,i)*mesh%gauss%ww(:,l))
283 uzs = sum(field(mesh%jj(:,m),6,i)*mesh%gauss%ww(:,l))
285 m_x = ray*(-zed*(urs+utc)+ray*uzs)
286 m_y = ray*(zed*(urc-uts)-ray*uzc)
288 moments_loc(1) = moments_loc(1) + m_x*mesh%gauss%rj(l,m)
289 moments_loc(2) = moments_loc(2) + m_y*mesh%gauss%rj(l,m)
295 CALL mpi_allreduce(moments_loc, moments_out, 3, mpi_double_precision, mpi_sum, petsc_comm_world, code)
296 moments_out(1) = acos(-1.d0)*moments_out(1)
297 moments_out(2) = acos(-1.d0)*moments_out(2)
298 moments_out(3) = 2*acos(-1.d0)*moments_out(3)
302 SUBROUTINE moments(communicator, H_mesh, list_mode, v, dipole_out, quadripole_out)
306 INTEGER,
DIMENSION(:),
INTENT(IN) :: list_mode
307 REAL(KIND=8),
DIMENSION(:,:,:),
INTENT(IN) :: v
308 REAL(KIND=8),
DIMENSION(3),
INTENT(OUT):: dipole_out
309 REAL(KIND=8),
DIMENSION(3,3),
INTENT(OUT):: quadripole_out
310 REAL(KIND=8),
DIMENSION(3) :: dipole
311 REAL(KIND=8),
DIMENSION(3,3) :: quadripole
312 REAL(KIND=8) :: jr, ray, zed, pi
313 INTEGER :: m_max_c, mode, k, m, l, ni, i
315 REAL(KIND=8),
DIMENSION(6) :: c
316 #include "petsc/finclude/petsc.h"
317 mpi_comm :: communicator
320 m_max_c =
SIZE(list_mode)
324 IF (
SIZE(v,1)/=h_mesh%np .OR.
SIZE(v,2)/=6 .OR.
SIZE(v,3)/=m_max_c )
THEN
325 WRITE(*,*)
' BUG in MOMENTS',
SIZE(v,1), h_mesh%np
329 DO l = 1, h_mesh%gauss%l_G
334 DO ni = 1, h_mesh%gauss%n_w; i = h_mesh%jj(ni,m)
335 ray = ray + h_mesh%rr(1,i)*h_mesh%gauss%ww(ni,l)
336 zed = zed + h_mesh%rr(2,i)*h_mesh%gauss%ww(ni,l)
338 jr = ray * h_mesh%gauss%rj(l,m)
342 IF (mode /=0 .AND. mode /=1 .AND. mode /=2) cycle
346 DO ni = 1,h_mesh%gauss%n_w; i = h_mesh%jj(ni,m)
348 c(1) = c(1) + ( mode/ray*v(i,6,k)*h_mesh%gauss%ww(ni,l) &
349 - v(i,3,k)*h_mesh%gauss%dw(2,ni,l,m))
350 c(2) = c(2) + (-mode/ray*v(i,5,k)*h_mesh%gauss%ww(ni,l) &
351 - v(i,4,k)*h_mesh%gauss%dw(2,ni,l,m))
353 c(3) = c(3) + (v(i,1,k)*h_mesh%gauss%dw(2,ni,l,m) &
354 - v(i,5,k)*h_mesh%gauss%dw(1,ni,l,m))
355 c(4) = c(4) + (v(i,2,k)*h_mesh%gauss%dw(2,ni,l,m) &
356 - v(i,6,k)*h_mesh%gauss%dw(1,ni,l,m))
358 c(5) = c(5) + (v(i,3,k)*h_mesh%gauss%dw(1,ni,l,m) &
359 + v(i,3,k)*h_mesh%gauss%ww(ni,l)/ray &
360 - mode/ray*v(i,2,k)*h_mesh%gauss%ww(ni,l))
361 c(6) = c(6) + (v(i,4,k)*h_mesh%gauss%dw(1,ni,l,m) &
362 + v(i,4,k)*h_mesh%gauss%ww(ni,l)/ray &
363 + mode/ray*v(i,1,k)*h_mesh%gauss%ww(ni,l))
368 dipole(3) = dipole(3) + 2*pi*ray*c(3)*jr
369 quadripole(1,1) = quadripole(1,1) + pi*(-zed*ray*c(3))*jr
370 quadripole(1,2) = quadripole(1,2) + pi*(-zed*ray*c(1)+ray*ray*c(5))*jr
371 quadripole(2,1) = quadripole(2,1) + pi*( zed*ray*c(1)-ray*ray*c(5))*jr
372 quadripole(2,2) = quadripole(2,2) + pi*(-zed*ray*c(3))*jr
373 quadripole(3,3) = quadripole(3,3)+2*pi*( zed*ray*c(3))*jr
374 ELSE IF (mode == 1)
THEN
375 dipole(1) = dipole(1) + pi*(-zed*c(3) -zed*c(2) +ray*c(6))*jr
376 dipole(2) = dipole(2) + pi*(-zed*c(4) +zed*c(1) -ray*c(5))*jr
377 quadripole(1,3) = quadripole(1,3) + pi*(-zed*c(3)-zed*c(2)+ray*c(6))*zed*jr
378 quadripole(2,3) = quadripole(2,3) + pi*(-zed*c(4)+zed*c(1)-ray*c(5))*zed*jr
379 quadripole(3,1) = quadripole(3,1) + pi*(ray*ray*c(3))*jr
380 quadripole(3,2) = quadripole(3,2) + pi*(ray*ray*c(4))*jr
381 ELSE IF (mode == 2)
THEN
382 quadripole(1,1) = quadripole(1,1) + pi*(-zed*c(3)-zed*c(2)+ray*c(6))*ray*jr/2
383 quadripole(1,2) = quadripole(1,2) + pi*(-zed*c(4)+zed*c(1)-ray*c(5))*ray*jr/2
384 quadripole(2,1) = quadripole(2,1) + pi*(-zed*c(4)+zed*c(1)-ray*c(5))*ray*jr/2
385 quadripole(2,2) = quadripole(2,2) + pi*( zed*c(3)+zed*c(2)-ray*c(6))*ray*jr/2
393 CALL mpi_allreduce(dipole, dipole_out, 3,mpi_double_precision, &
394 mpi_sum, communicator, code)
395 CALL mpi_allreduce(quadripole,quadripole_out,9,mpi_double_precision, &
396 mpi_sum, communicator, code)
real(kind=8) function norm_s_l1_zero_mode(communicator, mesh, list_mode, v)
real(kind=8) function norme_h1_champ(mesh, list_mode, v)
subroutine angular_momentum(mesh, list_mode, field, moments_out)
real(kind=8) function norme_div(H_mesh, list_mode, v)
subroutine integration_mode(communicator, norm_loc, norm_tot)
real(kind=8) function dot_product_champ(mesh, list_mode, v, w)
real(kind=8) function norme_curl_par(communicator, H_mesh, list_mode, v)
real(kind=8) function norme_l2_champ(mesh, list_mode, v)
integer function, public start_of_string(string)
real(kind=8) function norme_h1_champ_par(communicator, mesh, list_mode, v)
real(kind=8) function norme_curl(H_mesh, list_mode, v)
real(kind=8) function norm_s(communicator, norm_type, mesh, list_mode, v)
integer function, public last_of_string(string)
real(kind=8) function norme_div_par(communicator, H_mesh, list_mode, v)
real(kind=8) function norm_sf(communicator, norm_type, mesh, list_mode, v)
subroutine moments(communicator, H_mesh, list_mode, v, dipole_out, quadripole_out)
real(kind=8) function norme_l1_one_mode(mesh, mode_idx, v)
real(kind=8) function norme_l2_champ_par(communicator, mesh, list_mode, v)
real(kind=8) function dot_product_sf(communicator, mesh, list_mode, v, w)