47 #include "sll_memory.h"
48 #include "sll_working_precision.h"
66 use sll_m_mudpack_curvilinear,
only: &
67 sll_p_non_separable_with_cross_terms, &
68 sll_p_non_separable_without_cross_terms, &
87 sll_real64,
dimension(:, :),
pointer :: cxx_2d
89 sll_real64,
dimension(:, :),
pointer :: cxy_2d
91 sll_real64,
dimension(:, :),
pointer :: cyy_2d
93 sll_real64,
dimension(:, :),
pointer :: cx_2d
95 sll_real64,
dimension(:, :),
pointer :: cy_2d
97 sll_real64,
dimension(:, :),
pointer :: ce_2d
99 sll_real64,
dimension(:),
pointer :: cxx_1d
101 sll_real64,
dimension(:),
pointer :: cyy_1d
103 sll_real64,
dimension(:),
pointer :: cx_1d
105 sll_real64,
dimension(:),
pointer :: cy_1d
107 sll_real64,
dimension(:),
pointer :: cex_1d
109 sll_real64,
dimension(:),
pointer :: cey_1d
121 sll_int32 :: mudpack_case
147 sll_real64,
dimension(:),
pointer :: work
148 sll_int32 :: mgopt(4)
149 sll_int32 :: iprm(16)
150 sll_real64 :: fprm(6)
212 sll_real64,
intent(in) :: eta1_min
213 sll_real64,
intent(in) :: eta1_max
214 sll_int32,
intent(in) :: nc_eta1
215 sll_real64,
intent(in) :: eta2_min
216 sll_real64,
intent(in) :: eta2_max
217 sll_int32,
intent(in) :: nc_eta2
218 sll_int32,
intent(in) :: bc_eta1_left
219 sll_int32,
intent(in) :: bc_eta1_right
220 sll_int32,
intent(in) :: bc_eta2_left
221 sll_int32,
intent(in) :: bc_eta2_right
222 sll_int32,
intent(in) :: mudpack_case
223 sll_real64,
dimension(:, :),
intent(in),
optional :: cxx_2d
224 sll_real64,
dimension(:, :),
intent(in),
optional :: cxy_2d
225 sll_real64,
dimension(:, :),
intent(in),
optional :: cyy_2d
226 sll_real64,
dimension(:, :),
intent(in),
optional :: cx_2d
227 sll_real64,
dimension(:, :),
intent(in),
optional :: cy_2d
228 sll_real64,
dimension(:, :),
intent(in),
optional :: ce_2d
229 sll_real64,
dimension(:),
intent(in),
optional :: cxx_1d
230 sll_real64,
dimension(:),
intent(in),
optional :: cyy_1d
231 sll_real64,
dimension(:),
intent(in),
optional :: cx_1d
232 sll_real64,
dimension(:),
intent(in),
optional :: cy_1d
233 sll_real64,
dimension(:),
intent(in),
optional :: cex_1d
234 sll_real64,
dimension(:),
intent(in),
optional :: cey_1d
235 sll_real64,
intent(in),
optional :: cxx
236 sll_real64,
intent(in),
optional :: cxy
237 sll_real64,
intent(in),
optional :: cyy
238 sll_real64,
intent(in),
optional :: cx
239 sll_real64,
intent(in),
optional :: cy
240 sll_real64,
intent(in),
optional :: ce
244 sll_allocate(poisson, ierr)
311 sll_real64,
intent(in) :: eta1_min
312 sll_real64,
intent(in) :: eta1_max
313 sll_int32,
intent(in) :: nc_eta1
314 sll_real64,
intent(in) :: eta2_min
315 sll_real64,
intent(in) :: eta2_max
316 sll_int32,
intent(in) :: nc_eta2
317 sll_int32,
intent(in) :: bc_eta1_left
318 sll_int32,
intent(in) :: bc_eta1_right
319 sll_int32,
intent(in) :: bc_eta2_left
320 sll_int32,
intent(in) :: bc_eta2_right
321 sll_int32,
intent(in) :: mudpack_case
322 sll_real64,
dimension(:, :),
intent(in),
optional :: cxx_2d
323 sll_real64,
dimension(:, :),
intent(in),
optional :: cxy_2d
324 sll_real64,
dimension(:, :),
intent(in),
optional :: cyy_2d
325 sll_real64,
dimension(:, :),
intent(in),
optional :: cx_2d
326 sll_real64,
dimension(:, :),
intent(in),
optional :: cy_2d
327 sll_real64,
dimension(:, :),
intent(in),
optional :: ce_2d
328 sll_real64,
dimension(:),
intent(in),
optional :: cxx_1d
329 sll_real64,
dimension(:),
intent(in),
optional :: cyy_1d
330 sll_real64,
dimension(:),
intent(in),
optional :: cx_1d
331 sll_real64,
dimension(:),
intent(in),
optional :: cy_1d
332 sll_real64,
dimension(:),
intent(in),
optional :: cex_1d
333 sll_real64,
dimension(:),
intent(in),
optional :: cey_1d
334 sll_real64,
intent(in),
optional :: cxx
335 sll_real64,
intent(in),
optional :: cxy
336 sll_real64,
intent(in),
optional :: cyy
337 sll_real64,
intent(in),
optional :: cx
338 sll_real64,
intent(in),
optional :: cy
339 sll_real64,
intent(in),
optional :: ce
343 sll_int32,
parameter :: iixp = 2, jjyq = 2
344 sll_int32 :: icall, iiex, jjey, llwork
345 sll_real64,
pointer :: phi(:)
346 sll_real64,
pointer :: rhs(:)
349 sll_int32 :: iprm(16)
350 sll_real64 :: fprm(6)
353 sll_int32 :: intl, nxa, nxb, nyc, nyd, ixp, jyq, iex, jey, nx, ny
354 sll_int32 :: iguess, maxcy, method, nwork, lwrkqd, itero
355 common/itmud2sp/intl, nxa, nxb, nyc, nyd, ixp, jyq, iex, jey, nx, ny, &
356 iguess, maxcy, method, nwork, lwrkqd, itero
357 sll_real64 :: xa, xb, yc, yd, tolmax, relmax
358 common/ftmud2sp/xa, xb, yc, yd, tolmax, relmax
359 equivalence(intl, iprm)
360 equivalence(xa, fprm)
365 allocate (phi(nx*ny))
366 allocate (rhs(nx*ny))
368 llwork = (7*(nx + 2)*(ny + 2) + 44*nx*ny)/3
370 allocate (poisson%work(llwork))
372 iiex = ceiling(log((nx - 1.)/iixp)/log(2.)) + 1
373 jjey = ceiling(log((ny - 1.)/jjyq)/log(2.)) + 1
390 nx = ixp*(2**(iex - 1)) + 1
391 ny = jyq*(2**(jey - 1)) + 1
393 if (nx /= nc_eta1 + 1 .or. ny /= nc_eta2 + 1)
then
394 print *,
"nx,nc_eta1+1=", nx, nc_eta1 + 1
395 print *,
"ny,nc_eta2+1=", ny, nc_eta2 + 1
396 stop
' nx or ny different in sll_mudpack_cartesian '
411 iguess = poisson%iguess
435 poisson%mudpack_case = mudpack_case
437 poisson%cxx_2d_interp => null()
438 poisson%cxy_2d_interp => null()
439 poisson%cyy_2d_interp => null()
440 poisson%cx_2d_interp => null()
441 poisson%cy_2d_interp => null()
442 poisson%ce_2d_interp => null()
444 poisson%cxx_1d_interp => null()
445 poisson%cyy_1d_interp => null()
446 poisson%cx_1d_interp => null()
447 poisson%cy_1d_interp => null()
448 poisson%cex_1d_interp => null()
449 poisson%cey_1d_interp => null()
451 select case (mudpack_case)
452 case (sll_p_separable)
453 if (
present(cxx_2d) .or.
present(cxy_2d) .or.
present(cyy_2d) &
454 .or.
present(cx_2d) .or.
present(cy_2d) .or.
present(ce_2d))
then
455 print *,
'#2d arrays should not be here'
456 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
460 if ((.not. (
present(cxx_1d))) .and. (.not. (
present(cxx))))
then
461 print *,
'#1d/0d array should be here for cxx'
462 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
465 if (
present(cxx_1d) .and.
present(cxx))
then
466 print *,
'#please choose between 1d or 0d array for cxx'
467 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
470 if (
present(cxx_1d))
then
471 if (
size(cxx_1d) < nc_eta1 + 1)
then
472 print *,
'#Bad size for cxx_1d',
size(cxx_1d), nc_eta1 + 1
475 sll_allocate(poisson%cxx_1d(nc_eta1 + 1), ierr)
476 poisson%cxx_1d(1:nc_eta1 + 1) = cxx_1d(1:nc_eta1 + 1)
478 if (
present(cxx))
then
479 sll_allocate(poisson%cxx_1d(nc_eta1 + 1), ierr)
480 poisson%cxx_1d(1:nc_eta1 + 1) = cxx
483 if ((.not. (
present(cyy_1d))) .and. (.not. (
present(cyy))))
then
484 print *,
'#1d/0d array should be here for cyy !'
485 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
488 if (
present(cyy_1d) .and.
present(cyy))
then
489 print *,
'#please choose between 1d or 0d array for cyy'
490 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
493 if (
present(cyy_1d))
then
494 if (
size(cyy_1d) < nc_eta2 + 1)
then
495 print *,
'#Bad size for cyy_1d',
size(cyy_1d), nc_eta2 + 1
498 sll_allocate(poisson%cyy_1d(nc_eta2 + 1), ierr)
499 poisson%cyy_1d(1:nc_eta2 + 1) = cyy_1d(1:nc_eta2 + 1)
501 if (
present(cyy))
then
502 sll_allocate(poisson%cyy_1d(nc_eta2 + 1), ierr)
503 poisson%cyy_1d(1:nc_eta2 + 1) = cyy
506 if ((.not. (
present(cx_1d))) .and. (.not. (
present(cx))))
then
507 sll_allocate(poisson%cx_1d(nc_eta1 + 1), ierr)
508 poisson%cx_1d(1:nc_eta1 + 1) = 0._f64
510 if (
present(cx_1d) .and.
present(cx))
then
511 print *,
'#please choose between 1d or 0d array for cx'
512 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
515 if (
present(cx_1d))
then
516 if (
size(cx_1d) < nc_eta1 + 1)
then
517 print *,
'#Bad size for cx_1d',
size(cx_1d), nc_eta1 + 1
520 sll_allocate(poisson%cx_1d(nc_eta1 + 1), ierr)
521 poisson%cx_1d(1:nc_eta1 + 1) = cx_1d(1:nc_eta1 + 1)
523 if (
present(cx))
then
524 sll_allocate(poisson%cx_1d(nc_eta1 + 1), ierr)
525 poisson%cx_1d(1:nc_eta1 + 1) = cx
528 if ((.not. (
present(cy_1d))) .and. (.not. (
present(cy))))
then
529 sll_allocate(poisson%cy_1d(nc_eta2 + 1), ierr)
530 poisson%cy_1d(1:nc_eta2 + 1) = 0._f64
532 if (
present(cy_1d) .and.
present(cy))
then
533 print *,
'#please choose between 1d or 0d array for cy'
534 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
537 if (
present(cy_1d))
then
538 if (
size(cy_1d) < nc_eta2 + 1)
then
539 print *,
'#Bad size for cy_1d',
size(cy_1d), nc_eta2 + 1
542 sll_allocate(poisson%cy_1d(nc_eta2 + 1), ierr)
543 poisson%cy_1d(1:nc_eta2 + 1) = cy_1d(1:nc_eta2 + 1)
545 if (
present(cy))
then
546 sll_allocate(poisson%cy_1d(nc_eta2 + 1), ierr)
547 poisson%cy_1d(1:nc_eta2 + 1) = cy
550 if ((.not. (
present(cex_1d))) .and. (.not. (
present(ce))))
then
551 sll_allocate(poisson%cex_1d(nc_eta1 + 1), ierr)
552 poisson%cex_1d = 0._f64
554 if (
present(cex_1d) .and.
present(ce))
then
555 print *,
'#please choose between 1d or 0d array for cex'
556 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
559 if (
present(cex_1d))
then
560 if (
size(cex_1d) < nc_eta1 + 1)
then
561 print *,
'#Bad size for cex_1d',
size(cex_1d), nc_eta1 + 1
564 sll_allocate(poisson%cex_1d(nc_eta1 + 1), ierr)
565 poisson%cex_1d(1:nc_eta1 + 1) = cex_1d(1:nc_eta1 + 1)
567 if (
present(ce))
then
568 sll_allocate(poisson%cex_1d(nc_eta1 + 1), ierr)
569 poisson%cex_1d(1:nc_eta1 + 1) = 0.5_f64*ce
572 if ((.not. (
present(cey_1d))) .and. (.not. (
present(ce))))
then
573 sll_allocate(poisson%cey_1d(nc_eta2 + 1), ierr)
574 poisson%cey_1d(1:nc_eta2 + 1) = 0._f64
576 if (
present(cey_1d) .and.
present(ce))
then
577 print *,
'#please choose between 1d or 0d array for cey'
578 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
581 if (
present(cey_1d))
then
582 if (
size(cey_1d) < nc_eta2 + 1)
then
583 print *,
'#Bad size for cey_1d',
size(cey_1d), nc_eta2 + 1
586 sll_allocate(poisson%cey_1d(nc_eta2 + 1), ierr)
587 poisson%cey_1d(1:nc_eta2 + 1) = cey_1d(1:nc_eta2 + 1)
589 if (
present(ce))
then
590 sll_allocate(poisson%cey_1d(nc_eta2 + 1), ierr)
591 poisson%cey_1d(1:nc_eta2 + 1) = 0.5_f64*ce
599 call poisson%cxx_1d_interp%compute_interpolants(poisson%cxx_1d)
606 call poisson%cyy_1d_interp%compute_interpolants(poisson%cyy_1d)
613 call poisson%cx_1d_interp%compute_interpolants(poisson%cx_1d)
620 call poisson%cy_1d_interp%compute_interpolants(poisson%cy_1d)
627 call poisson%cex_1d_interp%compute_interpolants(poisson%cex_1d)
634 call poisson%cey_1d_interp%compute_interpolants(poisson%cey_1d)
637 print *,
'#Problem mudpack_wrapper is not null()'
641 call mud2sp(iprm, fprm, poisson%work, &
651 case (sll_p_non_separable_without_cross_terms)
653 if (
present(cxx_1d) .or.
present(cyy_1d) .or.
present(cx_1d) &
654 .or.
present(cy_1d) .or.
present(cex_1d) .or.
present(cey_1d))
then
655 print *,
'#1d arrays should not be here'
656 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
660 if ((.not. (
present(cxx_2d))) .and. (.not. (
present(cxx))))
then
661 print *,
'#2d/0d array should be here for cxx'
662 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
665 if (
present(cxx_2d) .and.
present(cxx))
then
666 print *,
'#please choose between 2d or 0d array for cxx'
667 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
670 if (
present(cxx_2d))
then
671 if (
size(cxx_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
672 print *,
'#Bad size for cxx_2d',
size(cxx_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
675 sll_allocate(poisson%cxx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
676 poisson%cxx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cxx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
678 if (
present(cxx))
then
679 sll_allocate(poisson%cxx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
680 poisson%cxx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cxx
683 if ((.not. (
present(cyy_2d))) .and. (.not. (
present(cyy))))
then
684 print *,
'#2d/0d array should be here for cyy !'
685 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
688 if (
present(cyy_2d) .and.
present(cyy))
then
689 print *,
'#please choose between 2d or 0d array for cyy'
690 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
693 if (
present(cyy_2d))
then
694 if (
size(cyy_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
695 print *,
'#Bad size for cyy_2d',
size(cyy_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
698 sll_allocate(poisson%cyy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
699 poisson%cyy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cyy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
701 if (
present(cyy))
then
702 sll_allocate(poisson%cyy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
703 poisson%cyy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cyy
706 if ((.not. (
present(cx_2d))) .and. (.not. (
present(cx))))
then
707 sll_allocate(poisson%cx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
708 poisson%cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = 0._f64
710 if (
present(cx_2d) .and.
present(cx))
then
711 print *,
'#please choose between 2d or 0d array for cx'
712 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
715 if (
present(cx_2d))
then
716 if (
size(cx_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
717 print *,
'#Bad size for cx_2d',
size(cx_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
720 sll_allocate(poisson%cx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
721 poisson%cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
723 if (
present(cx))
then
724 sll_allocate(poisson%cx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
725 poisson%cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cx
728 if ((.not. (
present(cy_2d))) .and. (.not. (
present(cy))))
then
729 sll_allocate(poisson%cy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
730 poisson%cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = 0._f64
732 if (
present(cy_2d) .and.
present(cy))
then
733 print *,
'#please choose between 2d or 0d array for cy'
734 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
737 if (
present(cy_2d))
then
738 if (
size(cy_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
739 print *,
'#Bad size for cy_2d',
size(cy_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
742 sll_allocate(poisson%cy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
743 poisson%cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
745 if (
present(cy))
then
746 sll_allocate(poisson%cy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
747 poisson%cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cy
750 if ((.not. (
present(ce_2d))) .and. (.not. (
present(ce))))
then
751 sll_allocate(poisson%ce_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
752 poisson%ce_2d = 0._f64
754 if (
present(ce_2d) .and.
present(ce))
then
755 print *,
'#please choose between 2d or 0d array for ce'
756 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
759 if (
present(ce_2d))
then
760 if (
size(ce_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
761 print *,
'#Bad size for ce_2d',
size(ce_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
764 sll_allocate(poisson%ce_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
765 poisson%ce_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = ce_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
767 if (
present(ce))
then
768 sll_allocate(poisson%ce_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
769 poisson%ce_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = ce
781 call poisson%cxx_2d_interp%compute_interpolants(poisson%cxx_2d)
792 call poisson%cyy_2d_interp%compute_interpolants(poisson%cyy_2d)
803 call poisson%cx_2d_interp%compute_interpolants(poisson%cx_2d)
814 call poisson%cy_2d_interp%compute_interpolants(poisson%cy_2d)
825 call poisson%ce_2d_interp%compute_interpolants(poisson%ce_2d)
828 print *,
'#Problem mudpack_wrapper is not null()'
832 call mud2(iprm, fprm, poisson%work, &
841 case (sll_p_non_separable_with_cross_terms)
843 if (
present(cxx_1d) .or.
present(cyy_1d) .or.
present(cx_1d) &
844 .or.
present(cy_1d) .or.
present(cex_1d) .or.
present(cey_1d))
then
845 print *,
'#1d arrays should not be here'
846 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
850 if ((.not. (
present(cxx_2d))) .and. (.not. (
present(cxx))))
then
851 print *,
'#2d/0d array should be here for cxx'
852 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
855 if (
present(cxx_2d) .and.
present(cxx))
then
856 print *,
'#please choose between 2d or 0d array for cxx'
857 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
860 if (
present(cxx_2d))
then
861 if (
size(cxx_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
862 print *,
'#Bad size for cxx_2d',
size(cxx_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
865 sll_allocate(poisson%cxx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
866 poisson%cxx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cxx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
868 if (
present(cxx))
then
869 sll_allocate(poisson%cxx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
870 poisson%cxx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cxx
873 if ((.not. (
present(cxy_2d))) .and. (.not. (
present(cxy))))
then
874 print *,
'#2d array should be here for cxy'
875 print *,
'# cxy=0. use another method'
876 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
879 if (
present(cxy_2d) .and.
present(cxy))
then
880 print *,
'#please choose between 2d or 0d array for cxy'
881 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
884 if (
present(cxy_2d))
then
885 if (
size(cxy_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
886 print *,
'#Bad size for cxy_2d',
size(cxy_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
889 sll_allocate(poisson%cxy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
890 poisson%cxy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cxy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
892 if (
present(cxy))
then
893 sll_allocate(poisson%cxy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
894 poisson%cxy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cxy
896 if ((.not. (
present(cyy_2d))) .and. (.not. (
present(cyy))))
then
897 print *,
'#2d/0d array should be here for cyy !'
898 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
901 if (
present(cyy_2d) .and.
present(cyy))
then
902 print *,
'#please choose between 2d or 0d array for cyy'
903 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
906 if (
present(cyy_2d))
then
907 if (
size(cyy_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
908 print *,
'#Bad size for cyy_2d',
size(cyy_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
911 sll_allocate(poisson%cyy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
912 poisson%cyy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cyy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
914 if (
present(cyy))
then
915 sll_allocate(poisson%cyy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
916 poisson%cyy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cyy
919 if ((.not. (
present(cx_2d))) .and. (.not. (
present(cx))))
then
920 sll_allocate(poisson%cx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
921 poisson%cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = 0._f64
923 if (
present(cx_2d) .and.
present(cx))
then
924 print *,
'#please choose between 2d or 0d array for cx'
925 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
928 if (
present(cx_2d))
then
929 if (
size(cx_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
930 print *,
'#Bad size for cx_2d',
size(cx_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
933 sll_allocate(poisson%cx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
934 poisson%cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
936 if (
present(cx))
then
937 sll_allocate(poisson%cx_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
938 poisson%cx_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cx
941 if ((.not. (
present(cy_2d))) .and. (.not. (
present(cy))))
then
942 sll_allocate(poisson%cy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
943 poisson%cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = 0._f64
945 if (
present(cy_2d) .and.
present(cy))
then
946 print *,
'#please choose between 2d or 0d array for cy'
947 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
950 if (
present(cy_2d))
then
951 if (
size(cy_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
952 print *,
'#Bad size for cy_2d',
size(cy_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
955 sll_allocate(poisson%cy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
956 poisson%cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
958 if (
present(cy))
then
959 sll_allocate(poisson%cy_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
960 poisson%cy_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = cy
963 if ((.not. (
present(ce_2d))) .and. (.not. (
present(ce))))
then
964 sll_allocate(poisson%ce_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
965 poisson%ce_2d = 0._f64
967 if (
present(ce_2d) .and.
present(ce))
then
968 print *,
'#please choose between 2d or 0d array for ce'
969 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
972 if (
present(ce_2d))
then
973 if (
size(ce_2d) < (nc_eta1 + 1)*(nc_eta2 + 1))
then
974 print *,
'#Bad size for ce_2d',
size(ce_2d), (nc_eta1 + 1)*(nc_eta2 + 1)
977 sll_allocate(poisson%ce_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
978 poisson%ce_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = ce_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1)
980 if (
present(ce))
then
981 sll_allocate(poisson%ce_2d(nc_eta1 + 1, nc_eta2 + 1), ierr)
982 poisson%ce_2d(1:nc_eta1 + 1, 1:nc_eta2 + 1) = ce
994 call poisson%cxx_2d_interp%compute_interpolants(poisson%cxx_2d)
1005 call poisson%cxy_2d_interp%compute_interpolants(poisson%cxy_2d)
1016 call poisson%cyy_2d_interp%compute_interpolants(poisson%cyy_2d)
1027 call poisson%cx_2d_interp%compute_interpolants(poisson%cx_2d)
1038 call poisson%cy_2d_interp%compute_interpolants(poisson%cy_2d)
1049 call poisson%ce_2d_interp%compute_interpolants(poisson%ce_2d)
1052 print *,
'#Problem mudpack_wrapper is not null()'
1056 call mud2cr(iprm, fprm, poisson%work, &
1066 print *,
'#bad mudpack_case', mudpack_case
1067 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
1076 sll_real64,
dimension(:, :),
intent(in) :: rho
1077 sll_real64,
dimension(:, :),
intent(out) :: phi
1082 sll_int32 :: iprm(16)
1083 sll_real64 :: fprm(6)
1087 sll_int32 :: intl, nxa, nxb, nyc, nyd, ixp, jyq, iex, jey, nx, ny
1088 sll_int32 :: iguess, maxcy, method, nwork, lwrkqd, itero
1089 common/itmud2sp/intl, nxa, nxb, nyc, nyd, ixp, jyq, iex, jey, nx, ny, &
1090 iguess, maxcy, method, nwork, lwrkqd, itero
1091 sll_real64 :: xa, xb, yc, yd, tolmax, relmax
1092 common/ftmud2sp/xa, xb, yc, yd, tolmax, relmax
1094 equivalence(intl, iprm)
1095 equivalence(xa, fprm)
1099 iguess = poisson%iguess
1105 if (nxa == sll_p_dirichlet)
then
1110 if (nxb == sll_p_dirichlet)
then
1112 phi(nx, i2) = 0._f64
1115 if (nyc == sll_p_dirichlet)
then
1120 if (nyd == sll_p_dirichlet)
then
1122 phi(i1, ny) = 0._f64
1125 select case (poisson%mudpack_case)
1126 case (sll_p_separable)
1128 print *,
'#Problem mudpack_wrapper is not null()'
1144 if (error > 0) stop 0
1146 call mud24sp(poisson%work, phi, error)
1148 if (error > 0) stop 0
1152 case (sll_p_non_separable_without_cross_terms)
1154 print *,
'#Problem mudpack_wrapper is not null()'
1169 if (error > 0) stop 0
1171 call mud24(poisson%work, phi, error)
1173 if (error > 0) stop 0
1177 case (sll_p_non_separable_with_cross_terms)
1179 print *,
'#Problem mudpack_wrapper is not null()'
1194 if (error > 0) stop 0
1196 call mud24cr(poisson%work, &
1202 if (error > 0) stop 0
1207 print *,
'#bad mudpack_case', poisson%mudpack_case
1208 print *,
'#in subroutine initialize_poisson_2d_mudpack_curvilinear'
1217 sll_real64,
dimension(:, :),
intent(in) :: rho
1218 sll_real64,
dimension(:, :),
intent(out) :: e1
1219 sll_real64,
dimension(:, :),
intent(out) :: e2
1221 print *,
'#compute_E_from_rho_2d_mudpack'
1222 print *,
'#not implemented for the moment'
1226 print *, maxval(rho)
1228 if (.not. (
associated(poisson%cxx_2d)))
then
1229 print *,
'#poisson%cxx_2d is not associated'
1240 sll_real64,
intent(in) :: coefs_dofs(:, :)
1243 print *,
'l2norm_squared not implemented for poisson_2d_mudpack.'
1251 sll_real64,
intent(out) :: coefs_dofs(:)
1253 print *,
'compute_rhs_from_function not implemented for poisson_2d_mudpack.'
1264 real(8) :: x, cxx, cx, cex
1265 cxx =
mudpack_wrapper%cxx_1d_interp%interpolate_from_interpolant_value(x)
1266 cx =
mudpack_wrapper%cx_1d_interp%interpolate_from_interpolant_value(x)
1267 cex =
mudpack_wrapper%cex_1d_interp%interpolate_from_interpolant_value(x)
1272 real(8) :: y, cyy, cy, cey
1273 cyy =
mudpack_wrapper%cyy_1d_interp%interpolate_from_interpolant_value(y)
1274 cy =
mudpack_wrapper%cy_1d_interp%interpolate_from_interpolant_value(y)
1275 cey =
mudpack_wrapper%cey_1d_interp%interpolate_from_interpolant_value(y)
1279 real(8) :: x, cxx, cx
1280 real(8) :: y, cyy, cy, ce
1281 cxx =
mudpack_wrapper%cxx_2d_interp%interpolate_from_interpolant_value(x, y)
1282 cyy =
mudpack_wrapper%cyy_2d_interp%interpolate_from_interpolant_value(x, y)
1283 cx =
mudpack_wrapper%cx_2d_interp%interpolate_from_interpolant_value(x, y)
1284 cy =
mudpack_wrapper%cy_2d_interp%interpolate_from_interpolant_value(x, y)
1285 ce =
mudpack_wrapper%ce_2d_interp%interpolate_from_interpolant_value(x, y)
1289 real(8) :: x, cxx, cx, cxy
1290 real(8) :: y, cyy, cy, ce
1291 cxx =
mudpack_wrapper%cxx_2d_interp%interpolate_from_interpolant_value(x, y)
1292 cxy =
mudpack_wrapper%cxy_2d_interp%interpolate_from_interpolant_value(x, y)
1293 cyy =
mudpack_wrapper%cyy_2d_interp%interpolate_from_interpolant_value(x, y)
1294 cx =
mudpack_wrapper%cx_2d_interp%interpolate_from_interpolant_value(x, y)
1295 cy =
mudpack_wrapper%cy_2d_interp%interpolate_from_interpolant_value(x, y)
1296 ce =
mudpack_wrapper%ce_2d_interp%interpolate_from_interpolant_value(x, y)
1302 real(8) :: xory, alfa, gbdy, x, y, pe, px, py
1303 real(8) :: xa, xb, yc, yd, tolmax, relmax
1304 common/ftmud2sp/xa, xb, yc, yd, tolmax, relmax
Describe different boundary conditions.
Interpolator 1d using cubic splines on regular mesh.
type(sll_t_cubic_spline_interpolator_1d) function, pointer, public sll_f_new_cubic_spline_interpolator_1d(num_points, xmin, xmax, bc_type, slope_left, slope_right, fast_algorithm)
Class for the cubic spline sll_c_interpolator_2d.
type(sll_t_cubic_spline_interpolator_2d) function, pointer, public sll_f_new_cubic_spline_interpolator_2d(npts1, npts2, eta1_min, eta1_max, eta2_min, eta2_max, eta1_bc_type, eta2_bc_type, const_eta1_min_slope, const_eta1_max_slope, const_eta2_min_slope, const_eta2_max_slope, eta1_min_slopes, eta1_max_slopes, eta2_min_slopes, eta2_max_slopes)
Function that return a pointer to a cubic spline interpolator 2d object. The result can be the target...
Module for 1D interpolation and reconstruction.
abstract data type for 2d interpolation
Module interface to solve Poisson equation in 2D.
Solves Poisson equation on 2d curvilinear mesh.
type(poisson_2d_mudpack_curvilinear) function, pointer, public sll_f_new_poisson_2d_mudpack_curvilinear(eta1_min, eta1_max, nc_eta1, eta2_min, eta2_max, nc_eta2, bc_eta1_left, bc_eta1_right, bc_eta2_left, bc_eta2_right, mudpack_case, cxx_2d, cxy_2d, cyy_2d, cx_2d, cy_2d, ce_2d, cxx_1d, cyy_1d, cx_1d, cy_1d, cex_1d, cey_1d, cxx, cxy, cyy, cx, cy, ce)
subroutine delete_2d_mudpack(poisson)
class(poisson_2d_mudpack_curvilinear), pointer mudpack_wrapper
subroutine compute_rhs_from_function_2d_mudpack(poisson, func, coefs_dofs)
subroutine mudpack_cof(x, y, cxx, cyy, cx, cy, ce)
subroutine mudpack_cofy(y, cyy, cy, cey)
input y dependent coefficients
subroutine mudpack_cofcr(x, y, cxx, cxy, cyy, cx, cy, ce)
subroutine mudpack_cofx(x, cxx, cx, cex)
input x dependent coefficients
subroutine associate_poisson(poisson)
subroutine mudpack_bndsp(kbdy, xory, alfa, gbdy)
input mixed derivative b.c. to mud2sp
subroutine compute_e_from_rho_2d_mudpack(poisson, E1, E2, rho)
subroutine initialize_poisson_2d_mudpack_curvilinear(poisson, eta1_min, eta1_max, nc_eta1, eta2_min, eta2_max, nc_eta2, bc_eta1_left, bc_eta1_right, bc_eta2_left, bc_eta2_right, mudpack_case, cxx_2d, cxy_2d, cyy_2d, cx_2d, cy_2d, ce_2d, cxx_1d, cyy_1d, cx_1d, cy_1d, cex_1d, cey_1d, cxx, cxy, cyy, cx, cy, ce)
real(kind=f64) function l2norm_squarred_2d_mudpack(poisson, coefs_dofs)
subroutine compute_phi_from_rho_2d_mudpack(poisson, phi, rho)
Abstract class for 1D interpolation and reconstruction.
Base class/basic interface for 2D interpolators.
Derived type to solve Poisson equation on 2d curvilinear mesh.