1 subroutine remesh(a, nrnew, npnew, meshno, cx, cy, xaxis, yaxis, &
31 real(r8),
intent(in) :: a, xaxis, yaxis, rax, sax
32 integer(itm_i4),
intent(in) :: nrnew, npnew, nax
33 integer(itm_i4),
intent(inout) :: meshno
35 real(r8),
intent(inout) :: cx, cy
37 real(r8),
parameter :: psitol = 1.e-8_r8
38 real(r8),
parameter :: toltht = 1.e-10_r8
39 real(r8),
parameter :: tolpsi = 1.e-10_r8
41 real(r8) :: thtkn(npnew)
43 real(r8) :: rpsi, psid, dpsid, ddpsid
44 real(r8) :: psival, thtval
45 real(r8) :: rr, r,
r2, r3
46 real(r8) :: psim, psimr, psip, psipr
47 real(r8) :: psimin, psimax
48 real(r8) :: ps, dpsir, dpsis
49 real(r8) :: a0, a1, a2, a3
50 real(r8) :: zx, dxr, dxs, zxr, zxs
51 real(r8) :: zy, dyr, dys, zyr, zys
52 real(r8) :: tht, tht0, tht1, tht2
54 real(r8) :: x, xr, xs, xrs, xrr, xss
55 real(r8) :: y, yr, ys, yrs, yrr, yss
56 real(r8) :: zpsi, zpsir, zpsis, zpsirs, zpsirr, zpsiss
58 real(r8) :: thx, thy, thxx, thxy, thyy
59 real(r8) :: ths, thr, thrr, thrs, thss
60 real(r8) :: ptjac, ptjr, ptjs
62 real(r8) :: rpt, spt, xpt, ypt
64 real(r8) :: psix, psiy
66 real(r8) :: etap, ejac
67 real(r8) :: fvec1, fvec2
68 real(r8) :: fjac11, fjac12, fjac21, fjac22
69 real(r8) :: dis, dr, ds, dtot
71 real(r8) :: s, psis, psir, psrs, psrr, psss
72 real(r8) :: rx, ry, sx, sy
73 real(r8) :: psixx, psiyy, psiyy0
74 real(r8) :: tn, tn2, cn
76 real(r8) :: trr, tss, ttht, tx, txr, txs, ty, tyr, tys, tpsi, tpsir, tpsis
77 real(r8) :: step, stepr, steps
79 real(r8) :: psi_bar, psi_min, psi_max, psi_cnt
80 real(r8) :: rr_exclusion_zone = +0.00_r8
82 integer(itm_i4) :: tjn, tjns, tnode, ttn1, ttn2, ttn3, ttn4
83 integer(itm_i4) :: nnsave1, nnsave2
84 integer(itm_i4) :: psi_prob, psi_prob_arr(1)
85 integer(itm_i4) :: nsym(2 * nr - 2), ssym(2 * nr - 2)
86 integer(itm_i4) :: i, j, k, n, ns, itn
88 integer(itm_i4) :: n1, n2, n3, n4
89 integer(itm_i4) :: node, in, jn, j0, n0
90 integer(itm_i4) :: ifail
91 integer(itm_i4) :: iprev, jprev
92 integer(itm_i4) :: itmax, ittest
93 integer(itm_i4) :: jindex
94 logical :: chagr(nrnew * npnew)
95 logical :: nobrack, found
97 real(r8),
dimension(3) :: abltg
98 real(r8) :: alfa_t, beta_t, tmp1
99 integer(itm_i4) :: typ_t
100 logical :: modified_psi
106 if (ias == 0) factas = 2._r8
109 nsym(i) = (i - 1) * (np - 1) + 1
111 nsym(nr - 1 + i) = (nr - 1) * (np - 1) - (i - 1) * (np - 1)
116 if (nr /= nrnew)
then
123 allocate(ddsg(nrnew))
125 sig(1 : n_acc_points), weights(1 : n_acc_points), equidistant, &
126 sg, dsg, ddsg, .false.)
129 psikn(nrnew - i + 1) = sg(i)**2
130 dpsikn(nrnew - i + 1) = 2._r8 * sg(i) * dsg(i)
131 ddpsikn(nrnew - i + 1) = 2._r8 * sg(i) * ddsg(i) + 2._r8 &
133 radpsi(nrnew - i + 1) = dble(i - 1) / dble(nrnew - 1)
135 else if (imesh == 3)
then
136 if (nr /= nrnew)
then
143 allocate(ddsg(nrnew))
145 sig(1 : n_acc_points), weights(1 : n_acc_points), equidistant, &
146 sg, dsg, ddsg, .true.)
149 psikn(nrnew - i + 1) = sg(i)**2
150 dpsikn(nrnew - i + 1) = 2._r8 * sg(i) * dsg(i)
151 ddpsikn(nrnew - i + 1) = 2._r8 * sg(i) * ddsg(i) + 2._r8 &
153 radpsi(nrnew - i + 1) = dble(i - 1) / dble(nrnew - 1)
157 rpsi = dble(i - 1) / dble(nrnew - 1)
159 psikn(nrnew - i + 1) = psid
160 dpsikn(nrnew - i + 1) = dpsid
161 ddpsikn(nrnew - i + 1) = ddpsid
162 radpsi(nrnew - i + 1) = rpsi
165 radpsi(nrnew) = 0._r8
168 thtkn(j) = (1._r8 + dble(ias)) * pi * dble(j - 1) / dble(npnew -1)
172 do i = 1, nrnew * npnew
177 xxold(k, i) = xx(k, i)
178 yyold(k, i) = yy(k, i)
179 psiold(4 * (i - 1) + k) = psi(4 * (i - 1) + k)
187 rr = rr_exclusion_zone
189 do nn = (nr - 2) * (np - 1) + 1, (nr - 1) * (np - 1)
190 in = (nn - 1) / (np - 1) + 1
191 jn = mod(nn - 1, np - 1) + 1
194 call
interpolation(0, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 - 1) + 1), &
195 psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), rr, ss, psim)
197 psi_bar = psi_bar + psim
198 psi_cnt = psi_cnt + 1._r8
199 psi_min = min(psi_min, psim)
200 psi_max = max(psi_max, psim)
202 psi_bar = psi_bar / psi_cnt
203 if (verbosity > 1)
write(iu6, *)
'psi_bar, psi_min, psi_max = ', psi_bar, &
205 modified_psi = .false.
206 if (psikn(nrnew) < psi_bar)
then
208 do while (psikn(i) > psi_bar)
216 if (psikn(i) < psi_max)
then
217 modified_psi = .true.
218 if (verbosity > 3)
write(iu6, *)
"Before: ", psikn(1 : i)
219 psikn(1 : i) = 1 - (1 - psikn(1 : i)) * (1 - psi_max) / (1 - psikn(i))
220 if (verbosity > 3)
write(iu6, *)
"After: ", psikn(1 : i)
225 if (psikn(i) > psi_min)
then
226 modified_psi = .true.
227 if (verbosity > 3)
write(iu6, *)
"Before: ", psikn(i : nrnew)
228 psikn(i : nrnew) = psikn(i : nrnew) * psi_min / psikn(i)
229 if (verbosity > 3)
write(iu6, *)
"After: ", psikn(i : nrnew)
233 if (verbosity > 0)
write(iu6, *)
'modified_psi = ', modified_psi
234 if (modified_psi)
then
239 call
spline(nrnew, radpsi, psikn, alfa_t, beta_t, typ_t, f_spline)
240 if (verbosity > 5)
write(iu6, *)
'Compare psikn and its derivatives ' &
241 //
'with spline calculations of same'
243 tmp1 =
spwert(nrnew, radpsi(i), f_spline, radpsi, abltg, 2)
244 if (verbosity > 5)
write(iu6,*) radpsi(i), psikn(i), tmp1, dpsikn(i), &
245 abltg(1), ddpsikn(i), abltg(2)
253 deallocate(xx, yy, psi)
254 allocate(psi(4 * nrnew * npnew))
255 allocate(xx(4, nrnew * npnew))
256 allocate(yy(4, nrnew * npnew))
265 if (verbosity > 6)
write(iu6, *)
' finding surface : ', psival, nax
267 do n = nax, 1, 1 - np
271 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 - 1) &
272 + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
273 rr, sax, psim, psimr, dpsis)
275 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 - 1) &
276 + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
277 rr, sax, psip, psipr, dpsis)
278 tol = 1._r8 + 1.e-5_r8
280 if (abs(r) > 1._r8)
then
281 psimin = min(psim, psip)
282 psimax = max(psim, psip)
284 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 - 1) &
285 + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
286 r, sax, ps, dpsir, dpsis)
287 psimin = min(min(psim, ps), psip)
288 psimax = max(max(psim, ps), psip)
290 if (psival >= psimin - psitol .and. psival <= psimax + psitol)
then
291 a3 = (psim + psimr - psip + psipr) / 4._r8
292 a2 = (-psimr + psipr) / 4._r8
293 a1 = (-3._r8 * psim - psimr + 3._r8 * psip - psipr) / 4._r8
294 a0 = (2._r8 * psim + psimr + 2._r8 * psip - psipr) / 4._r8 &
297 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 - 1) &
298 + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
299 rr, sax, ps, dpsir, dpsis)
300 call
interpolation(1, xxold(1, n1), xxold(1, n2), xxold(1, n3), &
301 xxold(1, n4), rr, sax, zx, dxr, dxs)
303 if (verbosity > 5)
then
304 write(iu6, *)
'node on wrong side : ', zx, xaxis
305 write(iu6, *)
'Roots are ', rr,
r2, r3
306 write(iu6, *)
'First solution for psi had value ',ps
309 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 &
310 - 1) + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
311 rr, sax, ps, dpsir, dpsis)
312 call
interpolation(1, xxold(1, n1), xxold(1, n2), xxold(1, n3), &
313 xxold(1, n4), rr, sax, zx, dxr, dxs)
314 if (verbosity > 5)
then
315 write(iu6, *)
'Second solution for psi had value ', ps
316 write(iu6, *)
'zx, xaxis = ', zx, xaxis
319 if (abs(rr) <= 1._r8 + 1.e-5_r8 .and. zx >= xaxis) goto 45
321 if (i == 1 .and. abs(ps - psival) < 1.e-5_r8)
then
328 write(iu6, *)
' starting value not found : ', psival, rr, ps
332 call
interpolation(1, yyold(1, n1), yyold(1, n2), yyold(1, n3), &
333 yyold(1, n4), rr, sax, zy, dyr, dys)
334 tht0 = atan2(zy - yaxis, zx - xaxis)
335 if (tht0 < 0._r8) tht0 = tht0 + 2._r8 * pi
337 dd = 0.25_r8 * (psival)**0.33_r8 / factas
349 47
if (ias == 1)
then
350 jindex = mod(int(tht0 / (2._r8 * pi) * npnew) + j, npnew) + 1
354 thtval = thtkn(jindex)
355 if (crashed .and. verbosity > 6) &
356 write(iu6, *)
"value of theta sought ", thtval
360 if (j == npnew .and. ias == 0)
then
362 do ns = 1, 2 * nr - 2
367 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 &
368 - 1) + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
369 rr, ss, psim, psimr, dpsis)
371 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 &
372 - 1) + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
373 rr, ss, psip, psipr, dpsis)
374 a3 = (psim + psimr - psip + psipr) / 4._r8
375 a2 = (-psimr + psipr) / 4._r8
376 a1 = (-3._r8 * psim - psimr + 3._r8 * psip - psipr) / 4._r8
377 a0 = (2._r8 * psim + psimr + 2._r8 * psip - psipr) &
380 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 &
381 - 1) + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
382 rr, ss, ps, dpsir, dpsis)
383 call
interpolation(1, xxold(1, n1), xxold(1, n2), xxold(1, n3), &
384 xxold(1, n4), rr, ss, zx, dxr, dxs)
386 if (verbosity > 3)
write(iu6, *)
' node on wrong side : ', zx, &
389 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 &
390 - 1) + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 &
391 - 1) + 1), rr, ss, ps, dpsir, dpsis)
392 call
interpolation(1, xxold(1, n1), xxold(1, n2), xxold(1, n3), &
393 xxold(1, n4), rr, ss, zx, dxr, dxs)
395 if (abs(rr) <= 1._r8 + 1.e-5_r8 .and. zx < xaxis &
396 .and. zx >= -1._r8 - 1.e-8_r8)
then
406 if (crashed .and. verbosity > 6) &
407 write(iu6, *)
"found, nobrack = ", found, nobrack
408 if (crashed .and. verbosity > 6) &
409 write(iu6, *)
"nn before itn loop ", nn
416 in = (nn - 1) / (np - 1) + 1
417 jn = mod(nn - 1, np - 1) + 1
422 if (itn == 1000)
then
424 if (verbosity > 0)
write(iu6,*)
"step changed to ", step
426 if (itn == 10000)
then
428 if (verbosity > 0)
write(iu6,*)
"step changed to ", step
430 if (itn == 100000)
then
432 if (verbosity > 0)
write(iu6,*)
"step changed to ", step
436 if (crashed .and. verbosity > 6)
write(iu6,*)
"itn = ", itn
438 call
interpolation(1, xxold(1, n1), xxold(1, n2), xxold(1, n3), &
439 xxold(1, n4), rr, ss, zx, zxr, zxs)
440 call
interpolation(1, yyold(1, n1), yyold(1, n2), yyold(1, n3), &
441 yyold(1, n4), rr, ss, zy, zyr, zys)
442 call
interpolation(1, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 - 1) &
443 + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
444 rr, ss, ps, dpsir, dpsis)
445 tht = atan2(zy - yaxis, zx - xaxis)
446 if (tht < 0._r8) tht = tht + 2._r8 * pi
447 if (crashed .and. verbosity > 6) &
448 write(iu6, *)
"thtval, tht = ", thtval, tht
455 if (crashed .and. verbosity > 6) &
456 write(iu6, *)
"theta error and tol = ", &
457 min(abs(thtval - tht), abs(thtval - tht + 2._r8 * pi), &
458 abs(thtval - tht - 2._r8 * pi)), toltht
459 if (crashed .and. verbosity > 6) &
460 write(iu6, *)
"psi error and tol = ", abs(psival - ps), &
462 if ((abs(thtval - tht) < toltht .or. abs(thtval - tht &
463 + 2._r8 * pi) < toltht .or. abs(thtval - tht - 2._r8 * pi) &
464 < toltht) .and. abs(psival - ps) < tolpsi)
then
474 if (crashed .and. verbosity > 6)
write(iu6,*)
"Found"
476 if (abs(rr) > 1._r8 + tolpsi .or. abs(ss) > 1._r8 &
479 write(iu6, *)
' warning : ', rr, ss
481 node = (i - 1) * npnew + jindex
483 call
interpolation(2, xxold(1, n1), xxold(1, n2), xxold(1, n3), &
484 xxold(1, n4), rr, ss, x, xr, xs, xrs, xrr, xss)
485 call
interpolation(2, yyold(1, n1), yyold(1, n2), yyold(1, n3), &
486 yyold(1, n4), rr, ss, y, yr, ys, yrs, yrr, yss)
487 call
interpolation(2, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 &
488 - 1) + 1), psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), &
489 rr, ss, zpsi, zpsir, zpsis, zpsirs, zpsirr, zpsiss)
491 rad = (x - xaxis)**2 + (y - yaxis)**2
492 thy = (x - xaxis) / rad
493 thx = -(y - yaxis) / rad
494 thxx = 2._r8 * (y - yaxis) * (x - xaxis) / rad**2
496 thxy = ((y - yaxis)**2 - (x - xaxis)**2) / rad**2
497 ths = thx * xs + thy * ys
498 thr = thx * xr + thy * yr
499 thrr = thxx * xr * xr + 2._r8 * thxy * xr * yr + thx * xrr &
500 + thyy * yr * yr + thy * yrr
501 thrs = thxx * xr * xs + thxy * xr * ys + thx * xrs &
502 + thxy * yr * xs + thyy * yr * ys + thy * yrs
503 thss = thxx * xs * xs + 2._r8 * thxy * xs * ys + thx * xss &
504 + thyy * ys * ys + thy * yss
505 ptjac = zpsir * ths - zpsis * thr
508 ptjr = zpsirr * ths + zpsir * thrs - zpsirs * thr - zpsis &
510 ptjs = zpsirs * ths + zpsir * thss - zpsiss * thr - zpsis &
512 rpt = (-ptjr * ths / ptjac**2 + thrs / ptjac) * rt &
513 + (-ptjs * ths / ptjac**2 + thss / ptjac) * st
514 spt = (ptjr * thr / ptjac**2 - thrr / ptjac) * rt &
515 + (ptjs * thr / ptjac**2 - thrs / ptjac) * st
516 xpt = -xrr * ths * zpsis / ptjac**2 + xrs * (ths * zpsir &
517 + thr * zpsis) / ptjac**2 + xr * rpt + xs * spt - xss &
518 * thr * zpsir / ptjac**2
519 ypt = -yrr * ths * zpsis / ptjac**2 + yrs * (ths * zpsir &
520 + thr * zpsis) / ptjac**2 + yr * rpt + ys * spt - yss &
521 * thr * zpsir / ptjac**2
522 xyjac = xr * ys - xs * yr
523 psix = (ys * zpsir - yr * zpsis) / xyjac
524 psiy = (-xs * zpsir + xr * zpsis) / xyjac
526 etap = 1._r8 / dpsikn(i)
527 ejac = etap * (psix * thy - psiy * thx)
531 xx(2, node) = -(thy / ejac) / (2._r8 * (nrnew - 1))
532 yy(2, node) = -(-thx / ejac) / (2._r8 * (nrnew - 1))
533 xx(3, node) = (-etap * psiy / ejac) / (factas * (npnew &
535 yy(3, node) = (etap * psix / ejac) / (factas * (npnew &
537 xx(4, node) = -(xpt / etap) / (2._r8 * factas * (nrnew - 1) &
539 yy(4, node) = -(ypt / etap) / (2._r8 * factas * (nrnew - 1) &
541 psi(4 * (node - 1) + 1) = zpsi
542 psi(4 * (node - 1) + 2) = -dpsikn(i) / (2._r8 * (nrnew - 1.))
543 psi(4 * (node - 1) + 3) = 0._r8
544 psi(4 * (node - 1) + 4) = 0._r8
546 if (itn > ittest) ittest = itn
547 if (crashed .and. verbosity > 6) &
548 write(iu6,*)
"goto 50 after itn = ", itn
550 else if ((tht1 <= thtval + 1.e-5_r8 .and. tht2 >= thtval - 1.e-5_r8) &
551 .or. (ias == 1 .and. tht1 > tht2 + 1.57_r8 &
552 .and. tht1 <= thtval + 1.e-5_r8 &
553 .and. tht2 + 2._r8 * pi >= thtval - 1.e-5_r8) &
554 .or. (ias == 1 .and. tht1 > tht2 + 1.57_r8 &
555 .and. tht1 - 2._r8 * pi <= thtval + 1.e-5_r8 &
556 .and. tht2 >= thtval - 1.e-5_r8))
then
560 if (crashed .and. verbosity > 6)
write(iu6,*)
"Bracketed"
561 fvec1 = -(zy - yaxis) + (zx - xaxis) * tan(thtval)
563 if (crashed .and. verbosity > 6) &
564 write(iu6, *)
"fvec1, fvec2 = ", fvec1, fvec2
565 if (crashed .and. verbosity > 6) &
566 write(iu6, *)
"zyr, zxr, zys, zxs = ", zyr, zxr, zys, zxs
567 if (crashed .and. verbosity > 6) &
568 write(iu6, *)
"thtval, tan(thtval) = ",thtval, tan(thtval)
569 fjac11 = zyr - zxr * tan(thtval)
570 fjac12 = zys - zxs * tan(thtval)
573 if (crashed .and. verbosity > 6) &
574 write(iu6, *)
"fjac11, fjac12, fjac21, fjac22 = ", &
575 fjac11, fjac12, fjac21, fjac22
576 dis = fjac22 * fjac11 - fjac12 * fjac21
577 dr = (fjac22 * fvec1 - fjac12 * fvec2) / dis
578 ds = (fjac11 * fvec2 - fjac21 * fvec1) / dis
579 dtot = sqrt(dr * dr + ds * ds)
580 if (dis * dis_old < 0._r8)
then
581 write(iu6, *)
"Sign change in dis: old, new = ", dis_old, dis
584 trr = rr_exclusion_zone
585 trr = 1 - (1 - rr_exclusion_zone) / 2._r8
591 open(133, file=
'data.dump')
593 tnode = (in - 1) * (np - 1) + tjn
596 tss =
real(tjns) /
real(100)
598 xxold(1, ttn3), xxold(1, ttn4), trr, tss, tx, txr, txs)
600 yyold(1, ttn3), yyold(1, ttn4), trr, tss, ty, tyr, tys)
602 psiold(4 * (ttn2 - 1) + 1), psiold(4 * (ttn3 - 1) + 1), &
603 psiold(4 * (ttn4 - 1) + 1), trr, tss, tpsi, tpsir, tpsis)
604 ttht = atan2(ty - yaxis, tx - xaxis)
605 write(133, *) tjn, tjns, tss, tx, ty, tpsi, ttht
612 if (crashed .and. verbosity > 6) &
613 write(iu6,*)
"dtot, dis = ", dtot, dis
616 if (in == nr - 1)
then
617 stepr = max(min(step, (1._r8 - rr) / 2._r8), 0._r8)
618 if (verbosity > 6)
write(iu6,*)
'Bracketed: Step in r changed ' &
620 ds = ds * step / stepr
621 if (verbosity > 6)
write(iu6, *)
'ds rescaled by ', &
622 step / stepr,
' to ', ds
623 if (abs(ds) > 10._r8)
then
625 if (verbosity > 6)
write(iu6, *)
'dr rescaled by ', &
626 1._r8 / abs(ds),
' to ', dr
629 dr = sign(min(abs(dr), stepr), dr)
630 ds = sign(min(abs(ds), steps), ds)
632 if (dtot > step)
then
633 dr = dr / dtot * step
634 ds = ds / dtot * step
636 if (in == nr - 1)
then
637 dr = min(dr, (1._r8 - rr) / 2._r8)
638 if (verbosity > 6)
write(iu6, *)
'Bracketed: dr changed to ',dr
643 if (crashed .and. verbosity > 0) &
644 write(iu6,*)
"Incremented rr & ss to ", rr, ss
650 if (crashed .and. verbosity > 6)
write(iu6, *)
"Not bracketed"
653 ds = - dd * dpsir / abs(dpsir)
654 if(itn.gt.1 .and. abs(ds + ds_old).lt.1e-10_r8)
then
655 write(*,*)
'seem to have an oscillation in ds'
656 write(*,*) ds_old, ds, nn, rr, ss
658 write(*,*)
'step changed to ',step
660 if (crashed .and. verbosity > 6)
write(iu6, *)
"ds = ",ds
661 if (abs((psival - ps) / psival) > 0.01_r8)
then
662 if (crashed .and. verbosity > 6)
write(iu6, *)
"moving in ps"
664 dr = (psival - ps) / dpsir
665 if (in == nr - 1)
then
666 stepr = max(min(step, (1._r8 - rr) / 2._r8), 0._r8)
667 if (verbosity > 6)
write(iu6, *)
'Not bracketed (1): Step in ' &
668 //
'r changed to ', stepr
670 dr = sign(min(abs(dr), stepr), dr)
671 if (dr == 0._r8)
then
672 if (verbosity > 6)
then
673 write(iu6, *)
'Only taking a step in r and dr == 0'
674 write(iu6, *)
'We will try to take a step in ds'
676 if (psival > psi_bar)
then
681 ds = sign(min(abs(ds), steps), ds)
682 if (verbosity > 6)
write(iu6, *)
'ds = ', ds
686 if (crashed .and. verbosity > 6) &
687 write(iu6, *)
"Incremented rr to ", rr
689 dr = (psival - ps - dpsis * ds) / dpsir
690 dtot = sqrt(dr * dr + ds * ds)
695 if (in == nr - 1)
then
696 stepr = max(min(step, (1._r8 - rr) / 2._r8), 0._r8)
698 write(iu6, *)
'Not bracketed (2): Step in r changed to ', stepr
700 dr = sign(min(abs(dr), stepr), dr)
701 ds = sign(min(abs(ds), steps), ds)
703 dtot = sqrt(dr * dr + ds * ds)
704 if (dtot > step)
then
705 dr = dr / dtot * step
706 ds = ds / dtot * step
708 if (in == nr - 1)
then
709 dr = min(dr, (1._r8 - rr) / 2._r8)
711 write(iu6, *)
'Not bracketed (2): dr changed to ', dr
716 if (crashed .and. verbosity > 6) &
717 write(iu6, *)
"Incremented rr & ss to ", rr, ss
721 if (in == nr - 1 .and. verbosity > 6)
then
722 write(iu6, *)
'Entered danger zone; in, rr, jn, ss, step = ', &
724 write(iu6, *)
'Searching for psi, theta = ', psival, thtval
725 write(iu6, *)
'Current position is ', ps, tht
726 write(iu6, *)
'psi_min, psi_bar, psi_max = ', psi_min, psi_bar, &
729 if (crashed .and. verbosity > 6) &
730 write(iu6, *)
'in, jn = ', in, jn
731 if (ss < -1._r8)
then
732 if (jprev == -1)
then
734 if (crashed .and. verbosity > 6) &
735 write(iu6, *)
"Decrementing nn by 1 to ", nn
738 if (crashed .and. verbosity > 6) &
739 write(iu6, *)
"Skipping nn up to ", nn
745 if (crashed .and. verbosity > 6) &
746 write(iu6, *)
"Set ss = -1"
749 else if (ss > 1)
then
752 if (crashed .and. verbosity > 6) &
753 write(iu6, *)
"Incrementing nn by 1 to ", nn
754 if (jn == np - 1)
then
756 if (crashed .and. verbosity > 6) &
757 write(iu6, *)
"Skipping nn down to ", nn
762 if (crashed .and. verbosity > 6) &
763 write(iu6, *)
"Set ss = +1"
768 if (rr < -1._r8)
then
769 if (in > 1 .and. iprev == -1)
then
771 if (crashed .and. verbosity > 6) &
772 write(iu6, *)
"Decrementing nn by np to ", nn
777 if (crashed .and. verbosity > 6) &
778 write(iu6, *)
"Set rr = -1"
781 else if (rr > 1._r8)
then
782 if (in < nr - 1 .and. iprev == 1)
then
784 if (crashed .and. verbosity > 6) &
785 write(iu6, *)
"Incrementing nn by np to ", nn
790 if (crashed .and. verbosity > 6) &
791 write(iu6, *)
"Set rr = +1"
796 if (standard_output) &
797 write(out_he, *)
' fatal node not found : ',i, j, psival, thtval
798 write(iu6, *)
' fatal error: node not found in remesh !'
810 if (ittest > 2500)
then
812 write(iu6, *)
' high max number of iterations : ', ittest
820 node = (i - 1) * npnew + j
822 n0 = (i - 1) * npnew + j0
823 xx(1, node) = xx(1, n0)
824 xx(2, node) = xx(2, n0)
825 xx(3, node) = xx(3, n0)
826 xx(4, node) = xx(4, n0)
827 yy(1, node) = yy(1, n0)
828 yy(2, node) = yy(2, n0)
829 yy(3, node) = yy(3, n0)
830 yy(4, node) = yy(4, n0)
831 psi(4 * (node - 1) + 1) = psi(4 * (n0 - 1) + 1)
832 psi(4 * (node - 1) + 2) = psi(4 * (n0 - 1) + 2)
833 psi(4 * (node - 1) + 3) = psi(4 * (n0 - 1) + 3)
834 psi(4 * (node - 1) + 4) = psi(4 * (n0 - 1) + 4)
842 call
interpolation(2, xxold(1, n1), xxold(1, n2), xxold(1, n3), &
843 xxold(1, n4), r, s, x, xr, xs, xrs, xrr, xss)
844 call
interpolation(2, yyold(1, n1), yyold(1, n2), yyold(1, n3), &
845 yyold(1, n4), r, s, y, yr, ys, yrs, yrr, yss)
846 call
interpolation(2, psiold(4 * (n1 - 1) + 1), psiold(4 * (n2 - 1) + 1), &
847 psiold(4 * (n3 - 1) + 1), psiold(4 * (n4 - 1) + 1), r, s, eqpsi, &
848 psir, psis, psrs, psrr, psss)
849 ejac = xr * ys - xs * yr
854 psixx = psrr * rx * rx + 2._r8 * psrs * rx * sx + psss * sx * sx
855 psiyy = psrr * ry * ry + 2._r8 * psrs * ry * sy + psss * sy * sy
857 psiyy0 = a * (1._r8 + b * x * (1._r8 + eps * x / 2._r8)) - psixx
859 psiyy0 = a * (1._r8 + b * (1._r8 + eps * x)**2) - psixx
864 node = (nrnew - 1) * npnew + j
870 if (thtkn(j) == pi / 2._r8)
then
872 yy(2, node) = -1._r8 / (sqrt(cy) * 2._r8 * (nrnew - 1))
873 xx(4, node) = 1._r8 / (sqrt(cy) * 2._r8 * factas * (nrnew - 1) &
876 elseif (thtkn(j) == (3._r8 * pi / 2._r8))
then
878 yy(2, node) = -1._r8 / (sqrt(cy) * 2._r8 * (nrnew - 1))
879 xx(4, node) = 1._r8 / (sqrt(cy) * 2._r8 * factas * (nrnew - 1) &
883 xx(2, node) = -sign(1._r8, cn) / (sqrt(cx + cy * tn2) * 2._r8 &
885 yy(2, node) = -abs(tn) / (sqrt(cx + cy * tn2) * 2._r8 * (nrnew - 1))
886 xx(4, node) = (cx + cy * tn2)**(-1.5_r8) * cy * abs(tn) / (cn**2 &
887 * 2._r8* factas * (nrnew - 1) * (npnew - 1) / pi)
888 yy(4, node) = -cx * (cx + cy * tn2)**(-1.5_r8) / (cn * abs(cn) &
889 * 2._r8 * factas * (nrnew - 1) * (npnew - 1) / pi)
891 if (thtkn(j) > pi)
then
892 yy(2, node) = -yy(2, node)
893 xx(4, node) = -xx(4, node)
897 psi(4 * (node - 1) + 1) = 0._r8
898 psi(4 * (node - 1) + 2) = 0._r8
899 psi(4 * (node - 1) + 3) = 0._r8
900 psi(4 * (node - 1) + 4) = 0._r8
903 do i = 1, nrnew * npnew
904 if (standard_output)
then
905 if (.not. chagr(i))
write(out_he, *)
'node missed at i = ', i
910 if (nr /= nrnew .or. np /= npnew)
then
914 allocate(nodeno((nr - 1) * (np - 1), 4))
subroutine radial_mesh(rpsi, zpsi, dzpsi, ddzpsi)
subroutine interpolation(type_interp, xn1, xn2, xn3, xn4, r, s, x, xr, xs, xrs, xrr, xss, yn1, yn2, yn3, yn4, pn1, pn2, pn3, pn4, yr, ys, ps)
subroutine allocate_spline_coefficients(spline, n)
subroutine remesh(a, nrnew, npnew, meshno, cx, cy, xaxis, yaxis, nax, rax, sax)
subroutine spline(N, X, Y, ALFA, BETA, TYP, A, B, C, D)
REAL *8 function spwert(N, XWERT, A, B, C, D, X, ABLTG)
subroutine, public quad_equation(p_m, p_mr, p_p, p_pr, tol, r, ifail)
subroutine solve_cubic(c0, c1, c2, c3, x1, x2, x3, ifail)
subroutine deallocate_spline_coefficients(spline)
subroutine mesh_accumulation(nrtmp, nv, s_acc, sig, weights, equidistant, sg, dsg, ddsg, in_psi)
real(r8) function r2(a, x, xr, xs, yr, ys, psi, psir, F_dia)
subroutine set_node_number(n_node, n1, n2, n3, n4)